fix: skip follower count check if cid follower is found

This commit is contained in:
Julian Lam
2024-06-12 14:15:39 -04:00
parent cdc6f9f6a3
commit f29214e007

View File

@@ -198,8 +198,7 @@ inbox.announce = async (req) => {
cid = Array.from(cids)[0]; cid = Array.from(cids)[0];
} }
if (String(object.id).startsWith(nconf.get('url'))) { if (String(object.id).startsWith(nconf.get('url'))) { // Local object
// Local object
const { type, id } = await activitypub.helpers.resolveLocalId(object.id); const { type, id } = await activitypub.helpers.resolveLocalId(object.id);
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]]');
@@ -209,14 +208,16 @@ inbox.announce = async (req) => {
tid = await posts.getPostField(id, 'tid'); tid = await posts.getPostField(id, 'tid');
socketHelpers.sendNotificationToPostOwner(pid, actor, 'announce', 'notifications:activitypub.announce'); socketHelpers.sendNotificationToPostOwner(pid, actor, 'announce', 'notifications:activitypub.announce');
} else { } else { // Remote object
// Remote object // Follower check
if (!cid) {
const numFollowers = await activitypub.actors.getLocalFollowersCount(actor); const numFollowers = await activitypub.actors.getLocalFollowersCount(actor);
if (!numFollowers) { if (!numFollowers) {
winston.info(`[activitypub/inbox.announce] Rejecting ${object.id} via ${actor} due to no followers`); winston.info(`[activitypub/inbox.announce] Rejecting ${object.id} via ${actor} due to no followers`);
reject('Announce', object, actor); reject('Announce', object, actor);
return; return;
} }
}
// Handle case where Announce(Create(Note)) is received // Handle case where Announce(Create(Note)) is received
if (object.type === 'Create' && object.object.type === 'Note') { if (object.type === 'Create' && object.object.type === 'Note') {