copy changes to bubble channel

This commit is contained in:
Hazelnoot 2025-06-03 17:58:39 -04:00
parent 0866e87ce6
commit 2e5792f213

View file

@ -5,11 +5,9 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import type { Packed } from '@/misc/json-schema.js'; import type { Packed } from '@/misc/json-schema.js';
import { MetaService } from '@/core/MetaService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { RoleService } from '@/core/RoleService.js'; import { RoleService } from '@/core/RoleService.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 { UtilityService } from '@/core/UtilityService.js';
@ -22,10 +20,8 @@ class BubbleTimelineChannel extends Channel {
private withRenotes: boolean; private withRenotes: boolean;
private withFiles: boolean; private withFiles: boolean;
private withBots: boolean; private withBots: boolean;
private instance: MiMeta;
constructor( constructor(
private metaService: MetaService,
private roleService: RoleService, private roleService: RoleService,
private readonly utilityService: UtilityService, private readonly utilityService: UtilityService,
noteEntityService: NoteEntityService, noteEntityService: NoteEntityService,
@ -44,7 +40,6 @@ class BubbleTimelineChannel extends Channel {
this.withRenotes = !!(params.withRenotes ?? true); this.withRenotes = !!(params.withRenotes ?? true);
this.withFiles = !!(params.withFiles ?? false); this.withFiles = !!(params.withFiles ?? false);
this.withBots = !!(params.withBots ?? true); this.withBots = !!(params.withBots ?? true);
this.instance = await this.metaService.fetch();
// Subscribe events // Subscribe events
this.subscriber.on('notesStream', this.onNote); this.subscriber.on('notesStream', this.onNote);
@ -52,6 +47,8 @@ class BubbleTimelineChannel extends Channel {
@bindThis @bindThis
private async onNote(note: Packed<'Note'>) { private async onNote(note: Packed<'Note'>) {
const isMe = this.user?.id === note.userId;
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return; if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
if (!this.withBots && note.user.isBot) return; if (!this.withBots && note.user.isBot) return;
@ -59,9 +56,28 @@ class BubbleTimelineChannel extends Channel {
if (note.channelId != null) return; if (note.channelId != null) return;
if (!this.utilityService.isBubbledHost(note.user.host)) return; if (!this.utilityService.isBubbledHost(note.user.host)) return;
if (isRenotePacked(note) && !isQuotePacked(note) && !this.withRenotes) return;
if (this.isNoteMutedOrBlocked(note)) return; if (this.isNoteMutedOrBlocked(note)) return;
if (note.reply) {
const reply = note.reply;
// 自分のフォローしていないユーザーの visibility: followers な投稿への返信は弾く
if (!this.isNoteVisibleToMe(reply)) return;
if (!this.following[note.userId]?.withReplies) {
// 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合
if (reply.userId !== this.user?.id && !isMe && reply.userId !== note.userId) return;
}
}
// 純粋なリノート(引用リノートでないリノート)の場合
if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) {
if (!this.withRenotes) return;
if (note.renote.reply) {
const reply = note.renote.reply;
// 自分のフォローしていないユーザーの visibility: followers な投稿への返信のリノートは弾く
if (!this.isNoteVisibleToMe(reply)) return;
}
}
const clonedNote = await this.assignMyReaction(note); const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote); await this.hideNote(clonedNote);
@ -82,7 +98,6 @@ export class BubbleTimelineChannelService implements MiChannelService<false> {
public readonly kind = BubbleTimelineChannel.kind; public readonly kind = BubbleTimelineChannel.kind;
constructor( constructor(
private metaService: MetaService,
private roleService: RoleService, private roleService: RoleService,
private noteEntityService: NoteEntityService, private noteEntityService: NoteEntityService,
private readonly utilityService: UtilityService, private readonly utilityService: UtilityService,
@ -92,7 +107,6 @@ export class BubbleTimelineChannelService implements MiChannelService<false> {
@bindThis @bindThis
public create(id: string, connection: Channel['connection']): BubbleTimelineChannel { public create(id: string, connection: Channel['connection']): BubbleTimelineChannel {
return new BubbleTimelineChannel( return new BubbleTimelineChannel(
this.metaService,
this.roleService, this.roleService,
this.utilityService, this.utilityService,
this.noteEntityService, this.noteEntityService,