summaryrefslogtreecommitdiff
path: root/src/services/note/create.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-06-24 15:51:03 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-06-24 15:51:03 +0900
commitdb6018884773295d94fe10fad60ebff9f44c480e (patch)
tree0c9cad0cc3143a35b87803efda523e8a14409a48 /src/services/note/create.ts
parent4.12.0 (diff)
downloadsharkey-db6018884773295d94fe10fad60ebff9f44c480e.tar.gz
sharkey-db6018884773295d94fe10fad60ebff9f44c480e.tar.bz2
sharkey-db6018884773295d94fe10fad60ebff9f44c480e.zip
Fix bug
Diffstat (limited to 'src/services/note/create.ts')
-rw-r--r--src/services/note/create.ts43
1 files changed, 11 insertions, 32 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index feabe2f0b7..7e2fb4ff6a 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -27,50 +27,29 @@ type Type = 'reply' | 'renote' | 'quote' | 'mention';
class NotificationManager {
private notifier: IUser;
private note: any;
- private queue: Array<{
- notifiee: ILocalUser['_id'],
- type: Type;
- }> = [];
constructor(notifier: IUser, note: any) {
this.notifier = notifier;
this.note = note;
}
- public push(notifiee: ILocalUser['_id'], type: Type) {
+ public async push(notifiee: ILocalUser['_id'], type: Type) {
// 自分自身へは通知しない
if (this.notifier._id.equals(notifiee)) return;
- const exist = this.queue.find(x => x.notifiee.equals(notifiee));
+ // ミュート情報を取得
+ const mentioneeMutes = await Mute.find({
+ muterId: notifiee
+ });
- if (exist) {
- // 「メンションされているかつ返信されている」場合は、メンションとしての通知ではなく返信としての通知にする
- if (type != 'mention') {
- exist.type = type;
- }
- } else {
- this.queue.push({
- notifiee, type
- });
- }
- }
+ const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId.toString());
- public deliver() {
- this.queue.forEach(async x => {
- // ミュート情報を取得
- const mentioneeMutes = await Mute.find({
- muterId: x.notifiee
+ // 通知される側のユーザーが通知する側のユーザーをミュートしていない限りは通知する
+ if (!mentioneesMutedUserIds.includes(this.notifier._id.toString())) {
+ notify(notifiee, this.notifier._id, type, {
+ noteId: this.note._id
});
-
- const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId.toString());
-
- // 通知される側のユーザーが通知する側のユーザーをミュートしていない限りは通知する
- if (!mentioneesMutedUserIds.includes(this.notifier._id.toString())) {
- notify(x.notifiee, this.notifier._id, x.type, {
- noteId: this.note._id
- });
- }
- });
+ }
}
}