From 4c8ab73ecd803a40af57573d7175b8c3e849295c Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Wed, 8 Oct 2025 21:24:19 -0400 Subject: [PATCH] fix rebase errors --- .../backend/src/core/NoteCreateService.ts | 8 +++- packages/backend/src/core/NoteEditService.ts | 5 ++- .../src/core/entities/NoteEntityService.ts | 40 +++++++++---------- .../src/server/api/endpoints/notes/create.ts | 2 - .../src/server/api/endpoints/notes/edit.ts | 2 - 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 59f9c32191..a168126a2f 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -57,6 +57,7 @@ import { IdentifiableError } from '@/misc/identifiable-error.js'; import { LatestNoteService } from '@/core/LatestNoteService.js'; import { CollapsedQueue } from '@/misc/collapsed-queue.js'; import { CacheService } from '@/core/CacheService.js'; +import { NoteVisibilityService } from '@/core/NoteVisibilityService.js'; import { isPureRenote } from '@/misc/is-renote.js'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -224,6 +225,7 @@ export class NoteCreateService implements OnApplicationShutdown { private userBlockingService: UserBlockingService, private cacheService: CacheService, private latestNoteService: LatestNoteService, + private readonly noteVisibilityService: NoteVisibilityService, ) { this.updateNotesCountQueue = new CollapsedQueue(process.env.NODE_ENV !== 'test' ? 60 * 1000 * 5 : 0, this.collapseNotesCount, this.performUpdateNotesCount); } @@ -320,7 +322,8 @@ export class NoteCreateService implements OnApplicationShutdown { } // Check visibility - if (!await this.noteEntityService.isVisibleForMe(data.renote, user.id)) { + const visibilityCheck = await this.noteVisibilityService.checkNoteVisibilityAsync(data.renote, user.id); + if (!visibilityCheck.accessible) { throw new IdentifiableError('be9529e9-fe72-4de0-ae43-0b363c4938af', 'Cannot renote an invisible note'); } @@ -343,7 +346,8 @@ export class NoteCreateService implements OnApplicationShutdown { } // Check visibility - if (!await this.noteEntityService.isVisibleForMe(data.reply, user.id)) { + const visibilityCheck = await this.noteVisibilityService.checkNoteVisibilityAsync(data.reply, user.id); + if (!visibilityCheck.accessible) { throw new IdentifiableError('b98980fa-3780-406c-a935-b6d0eeee10d1', 'Cannot reply to an invisible note'); } diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts index 7b51ce2022..af9538dc50 100644 --- a/packages/backend/src/core/NoteEditService.ts +++ b/packages/backend/src/core/NoteEditService.ts @@ -52,6 +52,7 @@ import { IdentifiableError } from '@/misc/identifiable-error.js'; import { LatestNoteService } from '@/core/LatestNoteService.js'; import { CollapsedQueue } from '@/misc/collapsed-queue.js'; import { NoteCreateService } from '@/core/NoteCreateService.js'; +import { NoteVisibilityService } from '@/core/NoteVisibilityService.js'; import { isPureRenote } from '@/misc/is-renote.js'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention' | 'edited'; @@ -221,6 +222,7 @@ export class NoteEditService implements OnApplicationShutdown { private cacheService: CacheService, private latestNoteService: LatestNoteService, private noteCreateService: NoteCreateService, + private readonly noteVisibilityService: NoteVisibilityService, ) { this.updateNotesCountQueue = new CollapsedQueue(process.env.NODE_ENV !== 'test' ? 60 * 1000 * 5 : 0, this.collapseNotesCount, this.performUpdateNotesCount); } @@ -339,7 +341,8 @@ export class NoteEditService implements OnApplicationShutdown { } // Check visibility - if (!await this.noteEntityService.isVisibleForMe(data.renote, user.id)) { + const visibilityCheck = await this.noteVisibilityService.checkNoteVisibilityAsync(data.renote, user.id); + if (!visibilityCheck.accessible) { throw new IdentifiableError('be9529e9-fe72-4de0-ae43-0b363c4938af', 'Cannot renote an invisible note'); } diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 95b464c56f..2b3defb189 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -19,7 +19,6 @@ import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js'; import { QueryService } from '@/core/QueryService.js'; import type { Config } from '@/config.js'; import { NoteVisibilityService } from '@/core/NoteVisibilityService.js'; -import type { PopulatedNote } from '@/core/NoteVisibilityService.js'; import type { NoteVisibilityData } from '@/core/NoteVisibilityService.js'; import type { OnModuleInit } from '@nestjs/common'; import type { CacheService } from '../CacheService.js'; @@ -653,29 +652,28 @@ export class NoteEntityService implements OnModuleInit { processErrors: note.processErrors, } : {}), - reply: opts.recurseReply && note.replyId ? this.pack(note.reply ?? opts._hint_?.notes.get(note.replyId) ?? note.replyId, me, { - detail: false, - skipHide: opts.skipHide, - withReactionAndUserPairCache: opts.withReactionAndUserPairCache, - _hint_: options?._hint_, + reply: opts.recurseReply && note.replyId ? this.pack(note.reply ?? opts._hint_?.notes.get(note.replyId) ?? note.replyId, me, { + detail: false, + skipHide: opts.skipHide, + withReactionAndUserPairCache: opts.withReactionAndUserPairCache, + _hint_: options?._hint_, - // Don't silence target of self-reply, since the outer note will already be silenced. - bypassSilence: bypassSilence || note.userId === note.replyUserId, - }) : undefined, + // Don't silence target of self-reply, since the outer note will already be silenced. + bypassSilence: bypassSilence || note.userId === note.replyUserId, + }) : undefined, - // The renote target needs to be packed with the reply, but we *must not* recurse any further. - // Pass detail=false and recurseReply=true to make sure we only include the right data. - renote: opts.recurseRenote && note.renoteId ? this.pack(note.renote ?? opts._hint_?.notes.get(note.renoteId) ?? note.renoteId, me, { - detail: false, - recurseReply: true, - skipHide: opts.skipHide, - withReactionAndUserPairCache: opts.withReactionAndUserPairCache, - _hint_: options?._hint_, + // The renote target needs to be packed with the reply, but we *must not* recurse any further. + // Pass detail=false and recurseReply=true to make sure we only include the right data. + renote: opts.recurseRenote && note.renoteId ? this.pack(note.renote ?? opts._hint_?.notes.get(note.renoteId) ?? note.renoteId, me, { + detail: false, + recurseReply: true, + skipHide: opts.skipHide, + withReactionAndUserPairCache: opts.withReactionAndUserPairCache, + _hint_: options?._hint_, - // Don't silence target of self-renote, since the outer note will already be silenced. - bypassSilence: bypassSilence || note.userId === note.renoteUserId, - }) : undefined, - } : {}), + // Don't silence target of self-renote, since the outer note will already be silenced. + bypassSilence: bypassSilence || note.userId === note.renoteUserId, + }) : undefined, }); this.noteVisibilityService.syncVisibility(packed); diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index cf61a297b0..4aece5353e 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -18,7 +18,6 @@ import { NoteCreateService } from '@/core/NoteCreateService.js'; import { DI } from '@/di-symbols.js'; import { isQuote, isRenote } from '@/misc/is-renote.js'; import { IdentifiableError } from '@/misc/identifiable-error.js'; -import { NoteVisibilityService } from '@/core/NoteVisibilityService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -262,7 +261,6 @@ export default class extends Endpoint { // eslint- private noteEntityService: NoteEntityService, private noteCreateService: NoteCreateService, - private readonly noteVisibilityService: NoteVisibilityService, ) { super(meta, paramDef, async (ps, me) => { if (ps.text && ps.text.length > this.config.maxNoteLength) { diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index 2794d7376a..276f2672d0 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -17,7 +17,6 @@ import { NoteEditService } from '@/core/NoteEditService.js'; import { DI } from '@/di-symbols.js'; import { isQuote, isRenote } from '@/misc/is-renote.js'; import { IdentifiableError } from '@/misc/identifiable-error.js'; -import { NoteVisibilityService } from '@/core/NoteVisibilityService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -312,7 +311,6 @@ export default class extends Endpoint { // eslint- private noteEntityService: NoteEntityService, private noteEditService: NoteEditService, - private readonly noteVisibilityService: NoteVisibilityService, ) { super(meta, paramDef, async (ps, me) => { if (ps.text && ps.text.length > this.config.maxNoteLength) {