Skip to content

Commit 77b8b4d

Browse files
committed
feat: can filter by topic
1 parent 553b4ff commit 77b8b4d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

api/src/events/router.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ router.get('', async (req, res, next) => {
1515
const sessionState = await session.reqAuthenticated(req)
1616
const { account, lang } = sessionState
1717

18-
const query: Filter<FullEvent> = { 'sender.type': account.type, 'sender.id': account.id }
18+
const query: Filter<FullEvent> = { }
19+
if (req.query.showAll === 'true') {
20+
if (!sessionState.user.adminMode) throw httpError(400, 'Only super admins can override permissions filter with showAll parameter')
21+
} else {
22+
query['sender.type'] = account.type
23+
query['sender.id'] = account.id
24+
}
1925
if (req.query.q && typeof req.query.q === 'string') query.$text = { $search: req.query.q, $language: lang || config.i18n.defaultLocale }
26+
if (typeof req.query.topics === 'string') query['topics.key'] = { $in: req.query.topics.split(',') }
2027
if (typeof req.query.resource === 'string') {
2128
const [type, id] = req.query.resource.split('/')
2229
query['resource.type'] = type

0 commit comments

Comments
 (0)