diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-12-22 07:38:57 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-12-22 07:38:57 +0900 |
| commit | 8b515b4dae8c272257ee8892713fe954f0ff9c4a (patch) | |
| tree | edadde7900fa4caa61b23b96242c7758665062f8 /src/api/common/notify.ts | |
| parent | wip (diff) | |
| download | sharkey-8b515b4dae8c272257ee8892713fe954f0ff9c4a.tar.gz sharkey-8b515b4dae8c272257ee8892713fe954f0ff9c4a.tar.bz2 sharkey-8b515b4dae8c272257ee8892713fe954f0ff9c4a.zip | |
wip
Diffstat (limited to 'src/api/common/notify.ts')
| -rw-r--r-- | src/api/common/notify.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/api/common/notify.ts b/src/api/common/notify.ts index 4b3e6a5d54..f06622f912 100644 --- a/src/api/common/notify.ts +++ b/src/api/common/notify.ts @@ -1,5 +1,6 @@ import * as mongo from 'mongodb'; import Notification from '../models/notification'; +import Mute from '../models/mute'; import event from '../event'; import serialize from '../serializers/notification'; @@ -32,6 +33,17 @@ export default ( setTimeout(async () => { const fresh = await Notification.findOne({ _id: notification._id }, { is_read: true }); if (!fresh.is_read) { + //#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.toHexString()) != -1) { + return; + } + //#endregion + event(notifiee, 'unread_notification', await serialize(notification)); } }, 3000); |