exclude -> include

This commit is contained in:
おさむのひと 2024-11-15 22:26:33 +09:00
parent 4827fbdd10
commit d95543d05b
7 changed files with 6 additions and 10 deletions

View File

@ -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<MiNote[]>,
};
@ -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<string>()),
ps.includeMutedChannels ? Promise.resolve(new Set<string>()) : 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);
};

View File

@ -104,6 +104,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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;

View File

@ -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<typeof meta, typeof paramDef> { // 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;

View File

@ -122,7 +122,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
: ['localTimeline'],
alwaysIncludeMyNotes: true,
excludePureRenotes: !ps.withRenotes,
excludeMutedChannels: true,
dbFallback: async (untilId, sinceId, limit) => await this.getFromDb({
untilId,
sinceId,

View File

@ -112,7 +112,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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;

View File

@ -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<typeof meta, typeof paramDef> { // 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,

View File

@ -133,7 +133,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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;