054417354c
* Update ja-JP.yml * Added settable config for muted instances * added psql query for removal of muted notes * Added filtering and trimming for instance mutes * cleaned up filtering of bad instance mutes and added a refresh at the end for the list on the client * Added notification & streaming timeline muting * Updated changelog * Added missing semicolon * Apply japanese string suggestions from robflop Co-authored-by: Robin B. <robflop98@outlook.com> * Changed Ja-JP instance mute title string to one suggested by sousuke Co-authored-by: sousuke0422 <sousuke20xx@gmail.com> * Update ja-JP instanceMuteDescription based on sousuke's suggestion Co-authored-by: sousuke0422 <sousuke20xx@gmail.com> * added notification mute * added notification and note children muting * Fixed a bug where local notifications were getting filtered on cold start * Fixed instance mute imports * Fixed not saving/loading instance mutes * removed en-US translations for instance mute * moved instance mute migration to js * changed settings index back to spaces * removed destructuring assignment from notification stream in instance mute check call Co-authored-by: tamaina <tamaina@hotmail.co.jp> * added .note accessor for checking note data instead of notification data * changed note to use Packed<'Note'> instead of any and removed usage of snake case Co-authored-by: tamaina <tamaina@hotmail.co.jp> * changed notification mute check to check specifically for notification host * changed to using single quotes * moved @click to the end for the linter * revert unnecessary changes * restored newlines * whitespace removal Co-authored-by: syuilo <syuilotan@yahoo.co.jp> Co-authored-by: Robin B. <robflop98@outlook.com> Co-authored-by: sousuke0422 <sousuke20xx@gmail.com> Co-authored-by: puffaboo <emilis@jigglypuff.club> Co-authored-by: tamaina <tamaina@hotmail.co.jp>
77 lines
3.1 KiB
TypeScript
77 lines
3.1 KiB
TypeScript
import autobind from 'autobind-decorator';
|
|
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
|
import Channel from '../channel';
|
|
import { fetchMeta } from '@/misc/fetch-meta';
|
|
import { Notes } from '@/models/index';
|
|
import { checkWordMute } from '@/misc/check-word-mute';
|
|
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
|
import { isInstanceMuted } from '@/misc/is-instance-muted';
|
|
import { Packed } from '@/misc/schema';
|
|
|
|
export default class extends Channel {
|
|
public readonly chName = 'globalTimeline';
|
|
public static shouldShare = true;
|
|
public static requireCredential = false;
|
|
|
|
@autobind
|
|
public async init(params: any) {
|
|
const meta = await fetchMeta();
|
|
if (meta.disableGlobalTimeline) {
|
|
if (this.user == null || (!this.user.isAdmin && !this.user.isModerator)) return;
|
|
}
|
|
|
|
// Subscribe events
|
|
this.subscriber.on('notesStream', this.onNote);
|
|
}
|
|
|
|
@autobind
|
|
private async onNote(note: Packed<'Note'>) {
|
|
if (note.visibility !== 'public') return;
|
|
if (note.channelId != null) return;
|
|
|
|
// リプライなら再pack
|
|
if (note.replyId != null) {
|
|
note.reply = await Notes.pack(note.replyId, this.user, {
|
|
detail: true
|
|
});
|
|
}
|
|
// Renoteなら再pack
|
|
if (note.renoteId != null) {
|
|
note.renote = await Notes.pack(note.renoteId, this.user, {
|
|
detail: true
|
|
});
|
|
}
|
|
|
|
// 関係ない返信は除外
|
|
if (note.reply) {
|
|
const reply = note.reply;
|
|
// 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合
|
|
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
|
|
}
|
|
|
|
// Ignore notes from instances the user has muted
|
|
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return;
|
|
|
|
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
|
if (isMutedUserRelated(note, this.muting)) return;
|
|
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
if (isBlockerUserRelated(note, this.blocking)) return;
|
|
|
|
// 流れてきたNoteがミュートすべきNoteだったら無視する
|
|
// TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある)
|
|
// 現状では、ワードミュートにおけるMutedNoteレコードの追加処理はストリーミングに流す処理と並列で行われるため、
|
|
// レコードが追加されるNoteでも追加されるより先にここのストリーミングの処理に到達することが起こる。
|
|
// そのためレコードが存在するかのチェックでは不十分なので、改めてcheckWordMuteを呼んでいる
|
|
if (this.userProfile && await checkWordMute(note, this.user, this.userProfile.mutedWords)) return;
|
|
|
|
this.connection.cacheNote(note);
|
|
|
|
this.send('note', note);
|
|
}
|
|
|
|
@autobind
|
|
public dispose() {
|
|
// Unsubscribe events
|
|
this.subscriber.off('notesStream', this.onNote);
|
|
}
|
|
}
|