From ec05c073217a0c754032ac92de9d91fe03808dd0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 9 Oct 2021 12:44:19 +0900 Subject: feat: 未読の通知のみ表示する機能 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints/i/notifications.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/server/api/endpoints') diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts index 3c265a10c1..0c5586054f 100644 --- a/src/server/api/endpoints/i/notifications.ts +++ b/src/server/api/endpoints/i/notifications.ts @@ -33,6 +33,11 @@ export const meta = { default: false }, + unreadOnly: { + validator: $.optional.bool, + default: false + }, + markAsRead: { validator: $.optional.bool, default: true @@ -105,6 +110,10 @@ export default define(meta, async (ps, user) => { query.andWhere(`notification.type NOT IN (:...excludeTypes)`, { excludeTypes: ps.excludeTypes }); } + if (ps.unreadOnly) { + query.andWhere(`notification.isRead = false`); + } + const notifications = await query.take(ps.limit!).getMany(); // Mark all as read -- cgit v1.2.3-freya