mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-27 00:51:16 +01:00
fix: missing awaits, more comprehensive 1b12 tests
This commit is contained in:
@@ -310,7 +310,15 @@ activitypubApi.delete.note = enabledCheck(async (caller, { pid }) => {
|
||||
activitypubApi.like = {};
|
||||
|
||||
activitypubApi.like.note = enabledCheck(async (caller, { pid }) => {
|
||||
if (!activitypub.helpers.isUri(pid)) { // remote only
|
||||
const payload = {
|
||||
id: `${nconf.get('url')}/uid/${caller.uid}#activity/like/${encodeURIComponent(pid)}`,
|
||||
type: 'Like',
|
||||
actor: `${nconf.get('url')}/uid/${caller.uid}`,
|
||||
object: utils.isNumber(pid) ? `${nconf.get('url')}/post/${pid}` : pid,
|
||||
};
|
||||
|
||||
if (!activitypub.helpers.isUri(pid)) { // only 1b12 announce for local likes
|
||||
await activitypub.feps.announce(pid, payload);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -319,13 +327,6 @@ activitypubApi.like.note = enabledCheck(async (caller, { pid }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
id: `${nconf.get('url')}/uid/${caller.uid}#activity/like/${encodeURIComponent(pid)}`,
|
||||
type: 'Like',
|
||||
actor: `${nconf.get('url')}/uid/${caller.uid}`,
|
||||
object: pid,
|
||||
};
|
||||
|
||||
await Promise.all([
|
||||
activitypub.send('uid', caller.uid, [uid], payload),
|
||||
activitypub.feps.announce(pid, payload),
|
||||
|
||||
@@ -137,12 +137,12 @@ async function executeCommand(caller, command, eventName, notification, data) {
|
||||
}
|
||||
if (result && command === 'upvote') {
|
||||
socketHelpers.upvote(result, notification);
|
||||
api.activitypub.like.note(caller, { pid: data.pid });
|
||||
await api.activitypub.like.note(caller, { pid: data.pid });
|
||||
} else if (result && notification) {
|
||||
socketHelpers.sendNotificationToPostOwner(data.pid, caller.uid, command, notification);
|
||||
} else if (result && command === 'unvote') {
|
||||
socketHelpers.rescindUpvoteNotification(data.pid, caller.uid);
|
||||
api.activitypub.undo.like(caller, { pid: data.pid });
|
||||
await api.activitypub.undo.like(caller, { pid: data.pid });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user