From d95543d05b89579e2a48fd7c62e2ff956b3a2bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Fri, 15 Nov 2024 22:26:33 +0900 Subject: [PATCH] exclude -> include --- packages/backend/src/core/FanoutTimelineEndpointService.ts | 6 +++--- .../backend/src/server/api/endpoints/channels/timeline.ts | 1 + .../src/server/api/endpoints/notes/hybrid-timeline.ts | 3 +-- .../src/server/api/endpoints/notes/local-timeline.ts | 1 - packages/backend/src/server/api/endpoints/notes/timeline.ts | 1 - .../src/server/api/endpoints/notes/user-list-timeline.ts | 3 +-- packages/backend/src/server/api/endpoints/users/notes.ts | 1 - 7 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/backend/src/core/FanoutTimelineEndpointService.ts b/packages/backend/src/core/FanoutTimelineEndpointService.ts index fcf6b5f84b..87bc5e79f0 100644 --- a/packages/backend/src/core/FanoutTimelineEndpointService.ts +++ b/packages/backend/src/core/FanoutTimelineEndpointService.ts @@ -35,7 +35,7 @@ type TimelineOptions = { excludeNoFiles?: boolean; excludeReplies?: boolean; excludePureRenotes: boolean; - excludeMutedChannels?: boolean; + includeMutedChannels?: boolean; dbFallback: (untilId: string | null, sinceId: string | null, limit: number) => Promise, }; @@ -111,7 +111,7 @@ export class FanoutTimelineEndpointService { this.cacheService.renoteMutingsCache.fetch(ps.me.id), this.cacheService.userBlockedCache.fetch(ps.me.id), this.cacheService.userProfileCache.fetch(me.id).then(p => new Set(p.mutedInstances)), - ps.excludeMutedChannels ? this.channelMutingService.mutingChannelsCache.fetch(me.id) : Promise.resolve(new Set()), + ps.includeMutedChannels ? Promise.resolve(new Set()) : this.channelMutingService.mutingChannelsCache.fetch(me.id), ]); const parentFilter = filter; @@ -120,7 +120,7 @@ export class FanoutTimelineEndpointService { if (isUserRelated(note, userIdsWhoMeMuting, ps.ignoreAuthorFromMute)) return false; if (!ps.ignoreAuthorFromMute && isRenote(note) && !isQuote(note) && userIdsWhoMeMutingRenotes.has(note.userId)) return false; if (isInstanceMuted(note, userMutedInstances)) return false; - if (ps.excludeMutedChannels && isChannelRelated(note, userMutedChannels)) return false; + if (!ps.includeMutedChannels && isChannelRelated(note, userMutedChannels)) return false; return parentFilter(note); }; diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts index 04d83c58ce..b818282341 100644 --- a/packages/backend/src/server/api/endpoints/channels/timeline.ts +++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts @@ -104,6 +104,7 @@ export default class extends Endpoint { // eslint- useDbFallback: true, redisTimelines: [`channelTimeline:${channel.id}`], excludePureRenotes: false, + includeMutedChannels: true, noteFilter: note => { // 共通機能を使うと見ているチャンネルそのものもミュートしてしまうので閲覧中のチャンネル以外を除く形にする if (note.channelId === channel.id && (note.renoteChannelId === null || note.renoteChannelId === channel.id)) return true; diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index 2a190e48a7..d514f5bb43 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -19,8 +19,8 @@ import { UserFollowingService } from '@/core/UserFollowingService.js'; import { MiLocalUser } from '@/models/User.js'; import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js'; import { ChannelMutingService } from '@/core/ChannelMutingService.js'; +import { ChannelFollowingService } from '@/core/ChannelFollowingService.js'; import { ApiError } from '../../error.js'; -import { ChannelFollowingService } from "@/core/ChannelFollowingService.js"; export const meta = { tags: ['notes'], @@ -159,7 +159,6 @@ export default class extends Endpoint { // eslint- useDbFallback: this.serverSettings.enableFanoutTimelineDbFallback, alwaysIncludeMyNotes: true, excludePureRenotes: !ps.withRenotes, - excludeMutedChannels: true, noteFilter: note => { if (note.reply && note.reply.visibility === 'followers') { if (!Object.hasOwn(followings, note.reply.userId) && note.reply.userId !== me.id) return false; diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index bf569593da..9c4812cbbf 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -122,7 +122,6 @@ export default class extends Endpoint { // eslint- : ['localTimeline'], alwaysIncludeMyNotes: true, excludePureRenotes: !ps.withRenotes, - excludeMutedChannels: true, dbFallback: async (untilId, sinceId, limit) => await this.getFromDb({ untilId, sinceId, diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index 0235d39685..b745167ec8 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -112,7 +112,6 @@ export default class extends Endpoint { // eslint- redisTimelines: ps.withFiles ? [`homeTimelineWithFiles:${me.id}`] : [`homeTimeline:${me.id}`], alwaysIncludeMyNotes: true, excludePureRenotes: !ps.withRenotes, - excludeMutedChannels: true, noteFilter: note => { if (note.reply && note.reply.visibility === 'followers') { if (!Object.hasOwn(followings, note.reply.userId) && note.reply.userId !== me.id) return false; diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts index fd683891f4..d1bd27cf40 100644 --- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts @@ -14,8 +14,8 @@ import { IdService } from '@/core/IdService.js'; import { QueryService } from '@/core/QueryService.js'; import { MiLocalUser } from '@/models/User.js'; import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js'; +import { ChannelMutingService } from '@/core/ChannelMutingService.js'; import { ApiError } from '../../error.js'; -import { ChannelMutingService } from "@/core/ChannelMutingService.js"; export const meta = { tags: ['notes', 'lists'], @@ -127,7 +127,6 @@ export default class extends Endpoint { // eslint- redisTimelines: ps.withFiles ? [`userListTimelineWithFiles:${list.id}`] : [`userListTimeline:${list.id}`], alwaysIncludeMyNotes: true, excludePureRenotes: !ps.withRenotes, - excludeMutedChannels: true, dbFallback: async (untilId, sinceId, limit) => await this.getFromDb(list, { untilId, sinceId, diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index ed77ca75a0..72561dfa92 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -133,7 +133,6 @@ export default class extends Endpoint { // eslint- excludeReplies: ps.withChannelNotes && !ps.withReplies, // userTimelineWithChannel may include replies excludeNoFiles: ps.withChannelNotes && ps.withFiles, // userTimelineWithChannel may include notes without files excludePureRenotes: !ps.withRenotes, - excludeMutedChannels: true, noteFilter: note => { if (note.channel?.isSensitive && !isSelf) return false; if (note.visibility === 'specified' && (!me || (me.id !== note.userId && !note.visibleUserIds.some(v => v === me.id)))) return false;