Skip to content

Commit

Permalink
fix: search permission (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
panghaibin authored Oct 7, 2024
1 parent 50f0813 commit 0110656
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/src/services/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,12 @@ export function FeedService() {
}
const cacheKey = `search_${keyword}`;
const searchKeyword = `%${keyword}%`;
const feed_list = (await cache.getOrSet(cacheKey, () => db.query.feeds.findMany({
where: or(like(feeds.title, searchKeyword),
const where = or(like(feeds.title, searchKeyword),
like(feeds.content, searchKeyword),
like(feeds.summary, searchKeyword),
like(feeds.alias, searchKeyword)),
like(feeds.alias, searchKeyword));
const feed_list = (await cache.getOrSet(cacheKey, () => db.query.feeds.findMany({
where: admin ? where : and(where, eq(feeds.draft, 0)),
columns: admin ? undefined : {
draft: false,
listed: false
Expand Down Expand Up @@ -484,4 +485,4 @@ async function clearFeedCache(id: number, alias: string | null, newAlias: string
await cache.delete(`feed_${alias}`, false);
if (newAlias)
await cache.delete(`feed_${newAlias}`, false);
}
}

0 comments on commit 0110656

Please sign in to comment.