Skip to content

Node.js based forum software built for the modern web

fix: closes #13275, set 'announces' after adding to zset to prevent race condition

Barış Soner Uşaklı2c59007b1005
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index 74a3db197f..b47730ffc7 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -512,9 +512,11 @@ Notes.announce.list = async ({ pid, tid }) => {
};
Notes.announce.add = async (pid, actor, timestamp = Date.now()) => {
- const tid = await posts.getPostField(pid, 'tid');
- await Promise.all([
+ const [tid] = await Promise.all([
+ posts.getPostField(pid, 'tid'),
db.sortedSetAdd(`pid:${pid}:announces`, timestamp, actor),
+ ]);
+ await Promise.all([
posts.setPostField(pid, 'announces', await db.sortedSetCard(`pid:${pid}:announces`)),
topics.tools.share(tid, actor, timestamp),
]);