From 1b014bc3e5b11cf153207df461a5cf0095ab5ea7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 6 Sep 2022 20:54:49 +0900 Subject: [PATCH] =?UTF-8?q?fix(server):=20=E4=BB=96=E4=BA=BA=E3=81=AE?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E3=82=92=E6=97=A2=E8=AA=AD=E3=81=AB=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E5=8F=AF=E8=83=BD=E6=80=A7=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ .../backend/src/server/api/common/read-notification.ts | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34ec7a642..383eff769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ You should also include the user name that made the change. ### Improvements - Client: Add following badge to user preview popup @nvisser +### Bugfixes +- Server: 他人の通知を既読にできる可能性があるのを修正 @syuilo + ## 12.118.1 (2022/08/08) ### Bugfixes diff --git a/packages/backend/src/server/api/common/read-notification.ts b/packages/backend/src/server/api/common/read-notification.ts index cf993ade3..b0d38a9e3 100644 --- a/packages/backend/src/server/api/common/read-notification.ts +++ b/packages/backend/src/server/api/common/read-notification.ts @@ -1,18 +1,19 @@ +import { In } from 'typeorm'; import { publishMainStream } from '@/services/stream.js'; import { pushNotification } from '@/services/push-notification.js'; import { User } from '@/models/entities/user.js'; import { Notification } from '@/models/entities/notification.js'; import { Notifications, Users } from '@/models/index.js'; -import { In } from 'typeorm'; export async function readNotification( userId: User['id'], - notificationIds: Notification['id'][] + notificationIds: Notification['id'][], ) { if (notificationIds.length === 0) return; // Update documents const result = await Notifications.update({ + notifieeId: userId, id: In(notificationIds), isRead: false, }, { @@ -27,7 +28,7 @@ export async function readNotification( export async function readNotificationByQuery( userId: User['id'], - query: Record + query: Record, ) { const notificationIds = await Notifications.findBy({ ...query,