copy changes to role channel

This commit is contained in:
Hazelnoot 2025-06-03 17:59:25 -04:00
parent 2e5792f213
commit 00a9233229

View file

@ -9,6 +9,7 @@ import { bindThis } from '@/decorators.js';
import { RoleService } from '@/core/RoleService.js'; import { RoleService } from '@/core/RoleService.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js'; import type { GlobalEvents } from '@/core/GlobalEventService.js';
import type { JsonObject } from '@/misc/json-value.js'; import type { JsonObject } from '@/misc/json-value.js';
import { isQuotePacked, isRenotePacked } from '@/misc/is-renote.js';
import Channel, { type MiChannelService } from '../channel.js'; import Channel, { type MiChannelService } from '../channel.js';
class RoleTimelineChannel extends Channel { class RoleTimelineChannel extends Channel {
@ -40,7 +41,9 @@ class RoleTimelineChannel extends Channel {
private async onEvent(data: GlobalEvents['roleTimeline']['payload']) { private async onEvent(data: GlobalEvents['roleTimeline']['payload']) {
if (data.type === 'note') { if (data.type === 'note') {
const note = data.body; const note = data.body;
const isMe = this.user?.id === note.userId;
// TODO this should be cached
if (!(await this.roleservice.isExplorable({ id: this.roleId }))) { if (!(await this.roleservice.isExplorable({ id: this.roleId }))) {
return; return;
} }
@ -48,6 +51,25 @@ class RoleTimelineChannel extends Channel {
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 (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);