From 2d147775738379d45eaed6c60ed5376c257b7f00 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 29 Jul 2022 08:57:53 -0700 Subject: [PATCH] try to fix streaming --- .../stream/channels/recommended-timeline.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts index 03fc33b3a..f64af2104 100644 --- a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts @@ -2,12 +2,13 @@ import Channel from '../channel.js'; import { fetchMeta } from '@/misc/fetch-meta.js'; import { checkWordMute } from '@/misc/check-word-mute.js'; import { isUserRelated } from '@/misc/is-user-related.js'; +import { isInstanceMuted } from '@/misc/is-instance-muted.js'; import { Packed } from '@/misc/schema.js'; export default class extends Channel { public readonly chName = 'recommendedTimeline'; public static shouldShare = true; - public static requireCredential = false; + public static requireCredential = true; constructor(id: string, connection: Channel['connection']) { super(id, connection); @@ -16,19 +17,24 @@ export default class extends Channel { public async init(params: any) { const meta = await fetchMeta(); - if (meta.disableRecommendedTimeline) { - if (this.user == null || (!this.user.isAdmin && !this.user.isModerator)) return; - } + if (meta.disableLocalTimeline && !this.user!.isAdmin && !this.user!.isModerator) return; // Subscribe events this.subscriber.on('notesStream', this.onNote); } private async onNote(note: Packed<'Note'>) { + // チャンネルの投稿ではなく、自分自身の投稿 または + // チャンネルの投稿ではなく、その投稿のユーザーをフォローしている または + // チャンネルの投稿ではなく、全体公開のローカルの投稿 または + // フォローしているチャンネルの投稿 の場合だけ const meta = await fetchMeta(); - if (note.user.host !== null && !meta.recommendedInstances.includes(note.user.host)) return; - if (note.visibility !== 'public') return; - if (note.channelId != null && !this.followingChannels.has(note.channelId)) return; + if (!( + ((note.user.host == null || meta.recommendedInstances.includes(note.user.host)) && note.visibility === 'public') + )) return; + + // Ignore notes from instances the user has muted + if (isInstanceMuted(note, new Set(this.userProfile?.mutedInstances ?? []))) return; // 関係ない返信は除外 if (note.reply && !this.user!.showTimelineReplies) {