mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 00:56:13 +01:00
fix: update AP api (un)follow ids to be url encoded id instead of handle
This commit is contained in:
@@ -44,11 +44,8 @@ activitypubApi.follow = enabledCheck(async (caller, { type, id, actor } = {}) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
|
actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
|
||||||
const [handle, isFollowing] = await Promise.all([
|
|
||||||
user.getUserField(actor, 'username'),
|
|
||||||
db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor),
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
const isFollowing = await db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor);
|
||||||
if (isFollowing) { // already following
|
if (isFollowing) { // already following
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,7 +55,7 @@ activitypubApi.follow = enabledCheck(async (caller, { type, id, actor } = {}) =>
|
|||||||
await db.sortedSetAdd(`followRequests:${type}.${id}`, timestamp, actor);
|
await db.sortedSetAdd(`followRequests:${type}.${id}`, timestamp, actor);
|
||||||
try {
|
try {
|
||||||
await activitypub.send(type, id, [actor], {
|
await activitypub.send(type, id, [actor], {
|
||||||
id: `${nconf.get('url')}/${type}/${id}#activity/follow/${handle}/${timestamp}`,
|
id: `${nconf.get('url')}/${type}/${id}#activity/follow/${encodeURIComponent(actor)}/${timestamp}`,
|
||||||
type: 'Follow',
|
type: 'Follow',
|
||||||
object: actor,
|
object: actor,
|
||||||
});
|
});
|
||||||
@@ -77,11 +74,8 @@ activitypubApi.unfollow = enabledCheck(async (caller, { type, id, actor }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
|
actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
|
||||||
const [handle, isFollowing] = await Promise.all([
|
|
||||||
user.getUserField(actor, 'username'),
|
|
||||||
db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor),
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
const isFollowing = await db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor);
|
||||||
if (!isFollowing) { // already not following
|
if (!isFollowing) { // already not following
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -93,7 +87,7 @@ activitypubApi.unfollow = enabledCheck(async (caller, { type, id, actor }) => {
|
|||||||
const timestamp = timestamps[0] || timestamps[1];
|
const timestamp = timestamps[0] || timestamps[1];
|
||||||
|
|
||||||
const object = {
|
const object = {
|
||||||
id: `${nconf.get('url')}/${type}/${id}#activity/follow/${handle}/${timestamp}`,
|
id: `${nconf.get('url')}/${type}/${id}#activity/follow/${encodeURIComponent(actor)}/${timestamp}`,
|
||||||
type: 'Follow',
|
type: 'Follow',
|
||||||
object: actor,
|
object: actor,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user