diff options
Diffstat (limited to 'src/api/common/notify.ts')
| -rw-r--r-- | src/api/common/notify.ts | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/api/common/notify.ts b/src/api/common/notify.ts index 4b3e6a5d54..ae5669b84c 100644 --- a/src/api/common/notify.ts +++ b/src/api/common/notify.ts @@ -1,7 +1,8 @@ import * as mongo from 'mongodb'; import Notification from '../models/notification'; +import Mute from '../models/mute'; import event from '../event'; -import serialize from '../serializers/notification'; +import { pack } from '../models/notification'; export default ( notifiee: mongo.ObjectID, @@ -26,13 +27,24 @@ export default ( // Publish notification event event(notifiee, 'notification', - await serialize(notification)); + await pack(notification)); // 3秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する setTimeout(async () => { const fresh = await Notification.findOne({ _id: notification._id }, { is_read: true }); if (!fresh.is_read) { - event(notifiee, 'unread_notification', await serialize(notification)); + //#region ただしミュートしているユーザーからの通知なら無視 + const mute = await Mute.find({ + muter_id: notifiee, + deleted_at: { $exists: false } + }); + const mutedUserIds = mute.map(m => m.mutee_id.toString()); + if (mutedUserIds.indexOf(notifier.toString()) != -1) { + return; + } + //#endregion + + event(notifiee, 'unread_notification', await pack(notification)); } }, 3000); }); |