mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 07:10:30 +01:00
fix: #13021, save details of follow request before sending the follow, avoid race condition
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user