mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: skip notes.assert checks for Announce(Note) if it's a remote object, do our own checks; #12442
This commit is contained in:
@@ -107,6 +107,7 @@ inbox.announce = async (req) => {
|
|||||||
let pid;
|
let pid;
|
||||||
|
|
||||||
if (String(object).startsWith(nconf.get('url'))) {
|
if (String(object).startsWith(nconf.get('url'))) {
|
||||||
|
// Local object
|
||||||
const { type, id } = await activitypub.helpers.resolveLocalId(object);
|
const { type, id } = await activitypub.helpers.resolveLocalId(object);
|
||||||
if (type !== 'post' || !(await posts.exists(id))) {
|
if (type !== 'post' || !(await posts.exists(id))) {
|
||||||
throw new Error('[[error:activitypub.invalid-id]]');
|
throw new Error('[[error:activitypub.invalid-id]]');
|
||||||
@@ -117,13 +118,21 @@ inbox.announce = async (req) => {
|
|||||||
|
|
||||||
socketHelpers.sendNotificationToPostOwner(pid, actor, 'announce', 'notifications:activitypub.announce');
|
socketHelpers.sendNotificationToPostOwner(pid, actor, 'announce', 'notifications:activitypub.announce');
|
||||||
} else {
|
} else {
|
||||||
|
// Remote object
|
||||||
|
const isFollowed = await db.sortedSetCard(`followersRemote:${actor}`);
|
||||||
|
if (!isFollowed) {
|
||||||
|
winston.info(`[activitypub/inbox.announce] Rejecting ${object} via ${actor} due to no followers`);
|
||||||
|
reject('Announce', object, actor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pid = object;
|
pid = object;
|
||||||
pid = await activitypub.resolveId(0, pid); // in case wrong id is passed-in; unlikely, but still.
|
pid = await activitypub.resolveId(0, pid); // in case wrong id is passed-in; unlikely, but still.
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
({ tid } = await activitypub.notes.assert(0, pid));
|
({ tid } = await activitypub.notes.assert(0, pid, { skipChecks: true })); // checks skipped; done above.
|
||||||
if (!tid) {
|
if (!tid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user