sync up logic between notes/bubble-timeline.ts and channels/bubble-timeline.ts

This commit is contained in:
Hazelnoot 2025-06-01 15:02:57 -04:00
parent b7abc5b3b4
commit bce38c295f
3 changed files with 21 additions and 4 deletions

View file

@ -81,7 +81,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.visibility = \'public\'') .andWhere('note.visibility = \'public\'')
.andWhere('note.channelId IS NULL') .andWhere('note.channelId IS NULL')
.andWhere('note.userHost IS NULL') .andWhere('note.userHost IS NOT NULL')
.andWhere('userInstance.isBubbled = true') // This comes from generateBlockedHostQueryForNote below .andWhere('userInstance.isBubbled = true') // This comes from generateBlockedHostQueryForNote below
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply') .leftJoinAndSelect('note.reply', 'reply')
@ -94,6 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (me) this.queryService.generateMutedUserQueryForNotes(query, me); if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me); if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me); if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
if (!me) query.andWhere('user.requireSigninToViewContents = false');
if (ps.withFiles) { if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\''); query.andWhere('note.fileIds != \'{}\'');
@ -115,7 +116,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
let timeline = await query.limit(ps.limit).getMany(); let timeline = await query.limit(ps.limit).getMany();
timeline = timeline.filter(note => { timeline = timeline.filter(note => {
if (note.user?.isSilenced && me && followings && note.userId !== me.id && !followings[note.userId]) return false; if (note.user?.isSilenced) {
if (!me) return false;
if (!followings) return false;
if (note.userId !== me.id) {
return followings[note.userId];
}
}
return true; return true;
}); });

View file

@ -65,6 +65,9 @@ export default abstract class Channel {
* *
*/ */
protected isNoteMutedOrBlocked(note: Packed<'Note'>): boolean { protected isNoteMutedOrBlocked(note: Packed<'Note'>): boolean {
// Ignore notes that require sign-in
if (note.user.requireSigninToViewContents && !this.user) return true;
// 流れてきたNoteがインスタンスミュートしたインスタンスが関わる // 流れてきたNoteがインスタンスミュートしたインスタンスが関わる
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? [])) && !this.following[note.userId]) return true; if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? [])) && !this.following[note.userId]) return true;

View file

@ -12,6 +12,7 @@ import { RoleService } from '@/core/RoleService.js';
import type { MiMeta } from '@/models/Meta.js'; import type { MiMeta } from '@/models/Meta.js';
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js'; import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
import type { JsonObject } from '@/misc/json-value.js'; import type { JsonObject } from '@/misc/json-value.js';
import { UtilityService } from '@/core/UtilityService.js';
import Channel, { MiChannelService } from '../channel.js'; import Channel, { MiChannelService } from '../channel.js';
class BubbleTimelineChannel extends Channel { class BubbleTimelineChannel extends Channel {
@ -26,6 +27,7 @@ class BubbleTimelineChannel extends Channel {
constructor( constructor(
private metaService: MetaService, private metaService: MetaService,
private roleService: RoleService, private roleService: RoleService,
private readonly utilityService: UtilityService,
noteEntityService: NoteEntityService, noteEntityService: NoteEntityService,
id: string, id: string,
@ -56,12 +58,15 @@ class BubbleTimelineChannel extends Channel {
if (note.visibility !== 'public') return; if (note.visibility !== 'public') return;
if (note.channelId != null) return; if (note.channelId != null) return;
if (note.user.host == null) return; if (note.user.host == null) return;
if (!this.instance.bubbleInstances.includes(note.user.host)) return; if (!this.utilityService.isBubbledHost(note.user.host)) return;
if (note.user.requireSigninToViewContents && this.user == null) return; if (note.user.requireSigninToViewContents && this.user == null) return;
if (isRenotePacked(note) && !isQuotePacked(note) && !this.withRenotes) return; if (isRenotePacked(note) && !isQuotePacked(note) && !this.withRenotes) return;
if (note.user.isSilenced && !this.following[note.userId] && note.userId !== this.user!.id) return; if (note.user.isSilenced) {
if (!this.user) return;
if (note.userId !== this.user.id && !this.following[note.userId]) return;
}
if (this.isNoteMutedOrBlocked(note)) return; if (this.isNoteMutedOrBlocked(note)) return;
@ -88,6 +93,7 @@ export class BubbleTimelineChannelService implements MiChannelService<false> {
private metaService: MetaService, private metaService: MetaService,
private roleService: RoleService, private roleService: RoleService,
private noteEntityService: NoteEntityService, private noteEntityService: NoteEntityService,
private readonly utilityService: UtilityService,
) { ) {
} }
@ -96,6 +102,7 @@ export class BubbleTimelineChannelService implements MiChannelService<false> {
return new BubbleTimelineChannel( return new BubbleTimelineChannel(
this.metaService, this.metaService,
this.roleService, this.roleService,
this.utilityService,
this.noteEntityService, this.noteEntityService,
id, id,
connection, connection,