summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteCreateService.ts
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2024-10-13 10:31:41 -0400
committerHazelnoot <acomputerdog@gmail.com>2024-10-15 14:17:19 -0400
commitc55af9c3b334dd5f81b03805e1e72e0824f8589b (patch)
tree25f67e2151ab97a31dde9db7ef8056e0f1028b6e /packages/backend/src/core/NoteCreateService.ts
parentmove upgrade notes to separate file (diff)
downloadsharkey-c55af9c3b334dd5f81b03805e1e72e0824f8589b.tar.gz
sharkey-c55af9c3b334dd5f81b03805e1e72e0824f8589b.tar.bz2
sharkey-c55af9c3b334dd5f81b03805e1e72e0824f8589b.zip
update latest note in background (don't await the result)
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
-rw-r--r--packages/backend/src/core/NoteCreateService.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index cbc9dcaf8f..55c55589ad 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -531,8 +531,6 @@ export class NoteCreateService implements OnApplicationShutdown {
await this.notesRepository.insert(insert);
}
- await this.updateLatestNote(insert);
-
return insert;
} catch (e) {
// duplicate key error
@@ -815,6 +813,9 @@ export class NoteCreateService implements OnApplicationShutdown {
});
}
+ // Update the Latest Note index / following feed
+ this.updateLatestNoteBG(note);
+
// Register to search database
if (!user.noindex) this.index(note);
}
@@ -1145,7 +1146,13 @@ export class NoteCreateService implements OnApplicationShutdown {
this.dispose();
}
- private async updateLatestNote(note: MiNote) {
+ private updateLatestNoteBG(note: MiNote): void {
+ this
+ .updateLatestNote(note)
+ .catch(err => console.error('Unhandled exception while updating latest_note (after create):', err));
+ }
+
+ private async updateLatestNote(note: MiNote): Promise<void> {
// Ignore DMs.
// Followers-only posts are *included*, as this table is used to back the "following" feed.
if (note.visibility === 'specified') return;