From 2c59007b1005cd5cd14cbb523ca5229db1fd2dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 1 Apr 2025 10:55:03 -0400 Subject: [PATCH] fix: closes #13275, set 'announces' after adding to zset to prevent race condition --- src/activitypub/notes.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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), ]);