diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 631d7074bd..d51315f71f 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -627,6 +627,14 @@ export class NoteCreateService implements OnApplicationShutdown { userHost: user.host, }); + // should really not happen, but better safe than sorry + if (data.reply?.id === insert.id) { + throw new Error("A note can't reply to itself"); + } + if (data.renote?.id === insert.id) { + throw new Error("A note can't renote itself"); + } + if (data.uri != null) insert.uri = data.uri; if (data.url != null) insert.url = data.url; diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts index 399461dd70..6949136e69 100644 --- a/packages/backend/src/core/NoteEditService.ts +++ b/packages/backend/src/core/NoteEditService.ts @@ -299,6 +299,10 @@ export class NoteEditService implements OnApplicationShutdown { } if (data.renote) { + if (data.renote.id === oldnote.id) { + throw new Error("A note can't renote itself"); + } + switch (data.renote.visibility) { case 'public': // public noteは無条件にrenote可能 diff --git a/packages/backend/src/core/activitypub/models/ApNoteService.ts b/packages/backend/src/core/activitypub/models/ApNoteService.ts index 6d9dc86c16..ad7b3b145c 100644 --- a/packages/backend/src/core/activitypub/models/ApNoteService.ts +++ b/packages/backend/src/core/activitypub/models/ApNoteService.ts @@ -251,7 +251,7 @@ export class ApNoteService { > => { if (typeof uri !== 'string' || !/^https?:/.test(uri)) return { status: 'permerror' }; try { - const res = await this.resolveNote(uri); + const res = await this.resolveNote(uri, { resolver }); if (res == null) return { status: 'permerror' }; return { status: 'ok', res }; } catch (e) { @@ -478,7 +478,7 @@ export class ApNoteService { > => { if (!/^https?:/.test(uri)) return { status: 'permerror' }; try { - const res = await this.resolveNote(uri); + const res = await this.resolveNote(uri, { resolver }); if (res == null) return { status: 'permerror' }; return { status: 'ok', res }; } catch (e) {