fix scheduled replies becoming quote-boosts

thanks to @CenTdemeern1 for triggering this bug!
see https://kitsunes.club/notes/a2h1y2rq9n

also compare with https://s.thenautilus.net/notes/a2h1y2rqx9

my instance errored out with:

> WARN 1	[remote ap]	Failed to resolve quote
> https://mastodon.social/users/DrALJONES/statuses/110586222749407429
>  for note https://kitsunes.club/notes/a2h1y2rq9n: StatusError: 404 Not
> Found

What happened?

* Charlotte scheduled a reply
* the processor called `findOneBy` with an undefined `note.renote`,
  which probably caused a `select` without any `where`
* a random note was attached as a quote
* that note has been deleted on the original instance but not on
kitsuclub's database
* the rest of fedi didn't notice the quote
This commit is contained in:
dakkar 2025-01-01 16:33:01 +00:00
parent 4c0bbddd0f
commit f4aa986abd

View file

@ -43,7 +43,7 @@ export class ScheduleNotePostProcessorService {
@bindThis
private async isValidNoteSchedule(note: MiScheduleNoteType, id: string): Promise<boolean> {
const reply = note.reply ? await this.notesRepository.findOneBy({ id: note.reply }) : undefined;
const renote = note.reply ? await this.notesRepository.findOneBy({ id: note.renote }) : undefined;
const renote = note.renote ? await this.notesRepository.findOneBy({ id: note.renote }) : undefined;
const channel = note.channel ? await this.channelsRepository.findOneBy({ id: note.channel, isArchived: false }) : undefined;
if (note.reply && !reply) {
this.logger.warn('Schedule Note Failed Reason: parent note to reply does not exist');
@ -78,7 +78,7 @@ export class ScheduleNotePostProcessorService {
const me = await this.usersRepository.findOneBy({ id: data.userId });
const note = data.note;
const reply = note.reply ? await this.notesRepository.findOneBy({ id: note.reply }) : undefined;
const renote = note.reply ? await this.notesRepository.findOneBy({ id: note.renote }) : undefined;
const renote = note.renote ? await this.notesRepository.findOneBy({ id: note.renote }) : undefined;
const channel = note.channel ? await this.channelsRepository.findOneBy({ id: note.channel, isArchived: false }) : undefined;
let files: MiDriveFile[] = [];