summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/i/notifications.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints/i/notifications.ts')
-rw-r--r--src/server/api/endpoints/i/notifications.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts
index db6772beb3..fd355dab83 100644
--- a/src/server/api/endpoints/i/notifications.ts
+++ b/src/server/api/endpoints/i/notifications.ts
@@ -44,12 +44,10 @@ export const meta = {
includeTypes: {
validator: $.optional.arr($.str.or(notificationTypes as unknown as string[])),
- default: [] as string[]
},
excludeTypes: {
validator: $.optional.arr($.str.or(notificationTypes as unknown as string[])),
- default: [] as string[]
}
},
@@ -65,6 +63,14 @@ export const meta = {
};
export default define(meta, async (ps, user) => {
+ // includeTypes が空の場合はクエリしない
+ if (ps.includeTypes && ps.includeTypes.length === 0) {
+ return [];
+ }
+ // excludeTypes に全指定されている場合はクエリしない
+ if (notificationTypes.every(type => ps.excludeTypes?.includes(type))) {
+ return [];
+ }
const followingQuery = Followings.createQueryBuilder('following')
.select('following.followeeId')
.where('following.followerId = :followerId', { followerId: user.id });
@@ -91,9 +97,9 @@ export default define(meta, async (ps, user) => {
query.setParameters(followingQuery.getParameters());
}
- if (ps.includeTypes!.length > 0) {
+ if (ps.includeTypes?.length > 0) {
query.andWhere(`notification.type IN (:...includeTypes)`, { includeTypes: ps.includeTypes });
- } else if (ps.excludeTypes!.length > 0) {
+ } else if (ps.excludeTypes?.length > 0) {
query.andWhere(`notification.type NOT IN (:...excludeTypes)`, { excludeTypes: ps.excludeTypes });
}