diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-01-30 04:37:25 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-30 04:37:25 +0900 |
| commit | f6154dc0af1a0d65819e87240f4385f9573095cb (patch) | |
| tree | 699a5ca07d6727b7f8497d4769f25d6d62f94b5a /src/server/api/common/read-notification.ts | |
| parent | Add Event activity-type support (#5785) (diff) | |
| download | sharkey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.gz sharkey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.bz2 sharkey-f6154dc0af1a0d65819e87240f4385f9573095cb.zip | |
v12 (#5712)
Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com>
Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
Diffstat (limited to 'src/server/api/common/read-notification.ts')
| -rw-r--r-- | src/server/api/common/read-notification.ts | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/server/api/common/read-notification.ts b/src/server/api/common/read-notification.ts index c8d43ba286..f686446c5c 100644 --- a/src/server/api/common/read-notification.ts +++ b/src/server/api/common/read-notification.ts @@ -1,8 +1,8 @@ import { publishMainStream } from '../../../services/stream'; import { User } from '../../../models/entities/user'; import { Notification } from '../../../models/entities/notification'; -import { Mutings, Notifications } from '../../../models'; -import { In, Not } from 'typeorm'; +import { Notifications, Users } from '../../../models'; +import { In } from 'typeorm'; /** * Mark notifications as read @@ -11,11 +11,6 @@ export async function readNotification( userId: User['id'], notificationIds: Notification['id'][] ) { - const mute = await Mutings.find({ - muterId: userId - }); - const mutedUserIds = mute.map(m => m.muteeId); - // Update documents await Notifications.update({ id: In(notificationIds), @@ -24,14 +19,7 @@ export async function readNotification( isRead: true }); - // Calc count of my unread notifications - const count = await Notifications.count({ - notifieeId: userId, - ...(mutedUserIds.length > 0 ? { notifierId: Not(In(mutedUserIds)) } : {}), - isRead: false - }); - - if (count === 0) { + if (!await Users.getHasUnreadNotification(userId)) { // 全ての(いままで未読だった)通知を(これで)読みましたよというイベントを発行 publishMainStream(userId, 'readAllNotifications'); } |