fix: #13021, save details of follow request before sending the follow, avoid race condition

This commit is contained in:
Julian Lam
2025-01-09 11:46:48 -05:00
parent 3a33cd5b9b
commit 1661681411

View File

@@ -46,13 +46,17 @@ activitypubApi.follow = enabledCheck(async (caller, { type, id, actor } = {}) =>
const handle = await user.getUserField(actor, 'username');
const timestamp = Date.now();
await activitypub.send(type, id, [actor], {
id: `${nconf.get('url')}/${type}/${id}#activity/follow/${handle}/${timestamp}`,
type: 'Follow',
object: actor,
});
await db.sortedSetAdd(`followRequests:${type}.${id}`, timestamp, actor);
try {
await activitypub.send(type, id, [actor], {
id: `${nconf.get('url')}/${type}/${id}#activity/follow/${handle}/${timestamp}`,
type: 'Follow',
object: actor,
});
} catch (e) {
await db.sortedSetRemove(`followRequests:${type}.${id}`, actor);
throw e;
}
});
// should be .undo.follow