summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteReadService.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-02-22 18:23:46 +0000
committerAmelia Yukii <amelia.yukii@shourai.de>2024-02-22 18:23:46 +0000
commit4afbf3b91e058554f80768d198ab203e43c5ff6b (patch)
tree107d4728af2636734a5705a910f04ba9adf3102b /packages/backend/src/core/NoteReadService.ts
parentmerge: Add fail safe for sponsors endpoint in case of not being able to conne... (diff)
downloadsharkey-4afbf3b91e058554f80768d198ab203e43c5ff6b.tar.gz
sharkey-4afbf3b91e058554f80768d198ab203e43c5ff6b.tar.bz2
sharkey-4afbf3b91e058554f80768d198ab203e43c5ff6b.zip
some fixes for note edits
Diffstat (limited to 'packages/backend/src/core/NoteReadService.ts')
-rw-r--r--packages/backend/src/core/NoteReadService.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/backend/src/core/NoteReadService.ts b/packages/backend/src/core/NoteReadService.ts
index feef024602..45f9c454e9 100644
--- a/packages/backend/src/core/NoteReadService.ts
+++ b/packages/backend/src/core/NoteReadService.ts
@@ -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 () => {