Channel (#6621)
* wip * wip * wip * wip * wip * wip * wip * wip * wop * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * add notes * wip * wip * wip * wip * sound * wip * add kick_gaba2 * wip
This commit is contained in:
parent
122076e8ea
commit
9855405b89
70 changed files with 2191 additions and 184 deletions
|
@ -1,16 +1,18 @@
|
|||
import { Note } from '../../models/entities/note';
|
||||
import { publishMainStream } from '../stream';
|
||||
import { User } from '../../models/entities/user';
|
||||
import { Mutings, NoteUnreads, Users } from '../../models';
|
||||
import { Mutings, NoteUnreads } from '../../models';
|
||||
import { genId } from '../../misc/gen-id';
|
||||
|
||||
export default async function(user: User, note: Note, isSpecified = false) {
|
||||
// ローカルユーザーのみ
|
||||
if (!Users.isLocalUser(user)) return;
|
||||
|
||||
export default async function(userId: User['id'], note: Note, params: {
|
||||
// NOTE: isSpecifiedがtrueならisMentionedは必ずfalse
|
||||
isSpecified: boolean;
|
||||
isMentioned: boolean;
|
||||
}) {
|
||||
//#region ミュートしているなら無視
|
||||
// TODO: 現在の仕様ではChannelにミュートは適用されないのでよしなにケアする
|
||||
const mute = await Mutings.find({
|
||||
muterId: user.id
|
||||
muterId: userId
|
||||
});
|
||||
if (mute.map(m => m.muteeId).includes(note.userId)) return;
|
||||
//#endregion
|
||||
|
@ -18,20 +20,27 @@ export default async function(user: User, note: Note, isSpecified = false) {
|
|||
const unread = await NoteUnreads.save({
|
||||
id: genId(),
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
isSpecified,
|
||||
noteUserId: note.userId
|
||||
userId: userId,
|
||||
isSpecified: params.isSpecified,
|
||||
isMentioned: params.isMentioned,
|
||||
noteChannelId: note.channelId,
|
||||
noteUserId: note.userId,
|
||||
});
|
||||
|
||||
// 2秒経っても既読にならなかったら「未読の投稿がありますよ」イベントを発行する
|
||||
setTimeout(async () => {
|
||||
const exist = await NoteUnreads.findOne(unread.id);
|
||||
|
||||
if (exist == null) return;
|
||||
|
||||
publishMainStream(user.id, 'unreadMention', note.id);
|
||||
|
||||
if (isSpecified) {
|
||||
publishMainStream(user.id, 'unreadSpecifiedNote', note.id);
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue