mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 19:07:08 +02:00
fix: #14182, handle direct likes to remote content
This commit is contained in:
@@ -329,21 +329,20 @@ inbox.delete = async (req) => {
|
||||
|
||||
inbox.like = async (req) => {
|
||||
const { actor, object } = req.body;
|
||||
const { type, id } = await activitypub.helpers.resolveLocalId(object.id);
|
||||
|
||||
if (type !== 'post' || !(await posts.exists(id))) {
|
||||
const exists = await posts.exists(object.id);
|
||||
if (!exists) {
|
||||
throw new Error('[[error:invalid-pid]]');
|
||||
}
|
||||
|
||||
const allowed = await privileges.posts.can('posts:upvote', id, activitypub._constants.uid);
|
||||
const { id: pid } = object;
|
||||
const allowed = await privileges.posts.can('posts:upvote', pid, activitypub._constants.uid);
|
||||
if (!allowed) {
|
||||
activitypub.helpers.log(`[activitypub/inbox.like] ${id} not allowed to be upvoted.`);
|
||||
activitypub.helpers.log(`[activitypub/inbox.like] ${pid} not allowed to be upvoted.`);
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
|
||||
activitypub.helpers.log(`[activitypub/inbox/like] id ${id} via ${actor}`);
|
||||
activitypub.helpers.log(`[activitypub/inbox/like] id ${pid} via ${actor}`);
|
||||
|
||||
const result = await posts.upvote(id, actor);
|
||||
const result = await posts.upvote(pid, actor);
|
||||
await activitypub.feps.announce(object.id, req.body);
|
||||
socketHelpers.upvote(result, 'notifications:upvoted-your-post-in');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user