From 35e7dca2bb96d26dab4eaf1d9fdd029faa6a2cb0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 8 Jan 2019 13:32:28 +0900 Subject: [PATCH] Resolve #3847 (#3849) * Update notifications.ts * Update notifications.ts * Update notifications.ts * Update notifications.ts * Add missing semicolon * Improve readability * Fix typo --- src/server/api/endpoints/i/notifications.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts index b1ddd40d13..028d67a018 100644 --- a/src/server/api/endpoints/i/notifications.ts +++ b/src/server/api/endpoints/i/notifications.ts @@ -40,6 +40,16 @@ export const meta = { markAsRead: { validator: $.bool.optional, default: true + }, + + includeTypes: { + validator: $.arr($.str.or(['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'poll_vote', 'receiveFollowRequest'])).optional, + default: [] as string[] + }, + + excludeTypes: { + validator: $.arr($.str.or(['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'poll_vote', 'receiveFollowRequest'])).optional, + default: [] as string[] } } }; @@ -89,6 +99,16 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { }; } + if (ps.includeTypes.length > 0) { + query.type = { + $in: ps.includeTypes + }; + } else if (ps.excludeTypes.length > 0) { + query.type = { + $nin: ps.excludeTypes + }; + } + const notifications = await Notification .find(query, { limit: ps.limit,