mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 15:30:39 +01:00
feat: Like(Note) and Undo(Like); federating likes
This commit is contained in:
@@ -129,6 +129,7 @@ exports.postCommand = async function (caller, command, eventName, notification,
|
||||
};
|
||||
|
||||
async function executeCommand(caller, command, eventName, notification, data) {
|
||||
const api = require('.');
|
||||
const result = await posts[command](data.pid, caller.uid);
|
||||
if (result && eventName) {
|
||||
websockets.in(`uid_${caller.uid}`).emit(`posts.${command}`, result);
|
||||
@@ -136,10 +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 });
|
||||
} 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 });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user