diff --git a/CHANGELOG.md b/CHANGELOG.md index a07096b3d..705c093a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ ### Bugfixes - クライアント: テーマの管理が行えない問題を修正 +- API: アプリケーション通知が取得できない問題を修正 ## 12.92.0 (2021/10/16) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ec8baaac..76267ab30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,6 +171,9 @@ const users = userIds.length > 0 ? await Users.find({ SQLでは配列のインデックスは**1始まり**。 `[a, b, c]`の `a`にアクセスしたいなら`[0]`ではなく`[1]`と書く +### null IN +nullが含まれる可能性のあるカラムにINするときは、そのままだとおかしくなるのでORなどでnullのハンドリングをしよう。 + ### `undefined`にご用心 MongoDBの時とは違い、findOneでレコードを取得する時に対象レコードが存在しない場合 **`undefined`** が返ってくるので注意。 MongoDBは`null`で返してきてたので、その感覚で`if (x === null)`とか書くとバグる。代わりに`if (x == null)`と書いてください diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts index fcabbbc3d..56668d03b 100644 --- a/src/server/api/endpoints/i/notifications.ts +++ b/src/server/api/endpoints/i/notifications.ts @@ -6,6 +6,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notifications, Followings, Mutings, Users } from '@/models/index'; import { notificationTypes } from '@/types'; import read from '@/services/note/read'; +import { Brackets } from 'typeorm'; export const meta = { tags: ['account', 'notifications'], @@ -94,10 +95,16 @@ export default define(meta, async (ps, user) => { .leftJoinAndSelect('reply.user', 'replyUser') .leftJoinAndSelect('renote.user', 'renoteUser'); - query.andWhere(`notification.notifierId NOT IN (${ mutingQuery.getQuery() })`); + query.andWhere(new Brackets(qb => { qb + .where(`notification.notifierId NOT IN (${ mutingQuery.getQuery() })`) + .orWhere('notification.notifierId IS NULL'); + })); query.setParameters(mutingQuery.getParameters()); - query.andWhere(`notification.notifierId NOT IN (${ suspendedQuery.getQuery() })`); + query.andWhere(new Brackets(qb => { qb + .where(`notification.notifierId NOT IN (${ suspendedQuery.getQuery() })`) + .orWhere('notification.notifierId IS NULL'); + })); if (ps.following) { query.andWhere(`((notification.notifierId IN (${ followingQuery.getQuery() })) OR (notification.notifierId = :meId))`, { meId: user.id });