Fix post searching

This commit is contained in:
Max Leiter 2023-01-13 00:01:32 -08:00
parent e49ca2e749
commit 5b7efc8a06
2 changed files with 3 additions and 16 deletions

View file

@ -259,10 +259,9 @@ export const searchPosts = async (
OR: [ OR: [
{ {
title: { title: {
search: query contains: query
}, },
authorId: userId, authorId: userId
visibility: publicOnly ? "public" : undefined
}, },
{ {
files: { files: {
@ -272,13 +271,9 @@ export const searchPosts = async (
} }
} }
}, },
authorId: userId, authorId: userId
visibility: publicOnly ? "public" : undefined
} }
] ]
},
include: {
files: withFiles
} }
}) })

View file

@ -10,14 +10,6 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const publicSearch = parseQueryParam(query.public) const publicSearch = parseQueryParam(query.public)
const searchQuery = parseQueryParam(q) const searchQuery = parseQueryParam(q)
console.log(
"searchQuery",
searchQuery,
"publicSearch",
publicSearch,
"userId",
query.userId
)
if (!searchQuery) { if (!searchQuery) {
res.status(400).json({ error: "Invalid query" }) res.status(400).json({ error: "Invalid query" })
return return