some fixes for note edits

This commit is contained in:
dakkar 2024-02-22 18:23:46 +00:00 committed by Amelia Yukii
parent 8197148209
commit 4afbf3b91e
2 changed files with 14 additions and 2 deletions

View file

@ -66,7 +66,11 @@ export class NoteReadService implements OnApplicationShutdown {
noteUserId: note.userId,
};
await this.noteUnreadsRepository.insert(unread);
/* we may be called from NoteEditService, for a note that's
already present in the `note_unread` table: `upsert` makes sure
we don't throw a "duplicate key" error, while still updating
the other columns if they've changed */
await this.noteUnreadsRepository.upsert(unread,['userId', 'noteId']);
// 2秒経っても既読にならなかったら「未読の投稿がありますよ」イベントを発行する
setTimeout(2000, 'unread note', { signal: this.#shutdownController.signal }).then(async () => {