This commit is contained in:
syuilo 2018-09-19 14:18:34 +09:00
parent 195f676500
commit d9f0e158a3
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
25 changed files with 239 additions and 39 deletions

View file

@ -25,6 +25,7 @@ import { TextElementMention } from '../../mfm/parse/elements/mention';
import { TextElementHashtag } from '../../mfm/parse/elements/hashtag';
import { updateNoteStats } from '../update-chart';
import { erase, unique } from '../../prelude/array';
import insertNoteUnread from './unread';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
@ -170,6 +171,17 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
// Increment notes count (user)
incNotesCountOfUser(user);
// 未読通知を作成
if (data.visibility == 'specified') {
data.visibleUsers.forEach(u => {
insertNoteUnread(u, note, true);
});
} else {
mentionedUsers.forEach(u => {
insertNoteUnread(u, note, false);
});
}
if (data.reply) {
saveReply(data.reply, note);
}
@ -314,16 +326,6 @@ async function publish(user: IUser, note: INote, noteObj: any, reply: INote, ren
publishGlobalTimelineStream(noteObj);
}
if (note.visibility == 'specified') {
visibleUsers.forEach(async (u) => {
const n = await pack(note, u, {
detail: true
});
publishUserStream(u._id, 'note', n);
publishHybridTimelineStream(u._id, n);
});
}
if (['public', 'home', 'followers'].includes(note.visibility)) {
// フォロワーに配信
publishToFollowers(note, user, noteActivity);