summaryrefslogtreecommitdiff
path: root/src/services/note/unread.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-11-12 02:02:25 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-11-12 02:02:25 +0900
commit0e4a111f81cceed275d9bec2695f6e401fb654d8 (patch)
tree40874799472fa07416f17b50a398ac33b7771905 /src/services/note/unread.ts
parentupdate deps (diff)
downloadmisskey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.gz
misskey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.bz2
misskey-0e4a111f81cceed275d9bec2695f6e401fb654d8.zip
refactoring
Resolve #7779
Diffstat (limited to 'src/services/note/unread.ts')
-rw-r--r--src/services/note/unread.ts55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/services/note/unread.ts b/src/services/note/unread.ts
deleted file mode 100644
index 29d2b54af8..0000000000
--- a/src/services/note/unread.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { Note } from '@/models/entities/note';
-import { publishMainStream } from '@/services/stream';
-import { User } from '@/models/entities/user';
-import { Mutings, NoteThreadMutings, NoteUnreads } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-
-export async function insertNoteUnread(userId: User['id'], note: Note, params: {
- // NOTE: isSpecifiedがtrueならisMentionedは必ずfalse
- isSpecified: boolean;
- isMentioned: boolean;
-}) {
- //#region ミュートしているなら無視
- // TODO: 現在の仕様ではChannelにミュートは適用されないのでよしなにケアする
- const mute = await Mutings.find({
- muterId: userId
- });
- if (mute.map(m => m.muteeId).includes(note.userId)) return;
- //#endregion
-
- // スレッドミュート
- const threadMute = await NoteThreadMutings.findOne({
- userId: userId,
- threadId: note.threadId || note.id,
- });
- if (threadMute) return;
-
- const unread = {
- id: genId(),
- noteId: note.id,
- userId: userId,
- isSpecified: params.isSpecified,
- isMentioned: params.isMentioned,
- noteChannelId: note.channelId,
- noteUserId: note.userId,
- };
-
- await NoteUnreads.insert(unread);
-
- // 2秒経っても既読にならなかったら「未読の投稿がありますよ」イベントを発行する
- setTimeout(async () => {
- const exist = await NoteUnreads.findOne(unread.id);
-
- if (exist == null) return;
-
- if (params.isMentioned) {
- publishMainStream(userId, 'unreadMention', note.id);
- }
- if (params.isSpecified) {
- publishMainStream(userId, 'unreadSpecifiedNote', note.id);
- }
- if (note.channelId) {
- publishMainStream(userId, 'unreadChannel', note.id);
- }
- }, 2000);
-}