diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2017-12-22 17:42:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-22 17:42:03 +0900 |
| commit | e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c (patch) | |
| tree | 5e9dc021c78288097cc02671f0c9a4ef04a83e2d /src/api/common/notify.ts | |
| parent | Fix bug (diff) | |
| parent | Update create.ts (diff) | |
| download | sharkey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.tar.gz sharkey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.tar.bz2 sharkey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.zip | |
Merge pull request #1028 from syuilo/mute
Mute
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..2b79416a30 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.toString()) != -1) { + return; + } + //#endregion + event(notifiee, 'unread_notification', await serialize(notification)); } }, 3000); |