Node.js based forum software built for the modern web
fix(activitypub): return true from assert/assertGroup when all IDs already present
Julian Lam89d3d9643953
diff --git a/src/activitypub/actors.js b/src/activitypub/actors.jsindex 70e9d54e6d..e3c6da54fe 100644--- a/src/activitypub/actors.js+++ b/src/activitypub/actors.js@@ -121,9 +121,12 @@ Actors.assert = async (ids, options = {}) => {*/ids = await Actors.qualify(ids, options);- if (!ids || !ids.length) {+ if (ids === false) {return ids;}+ if (!ids.length) {+ return true;+ }activitypub.helpers.log(`[activitypub/actors] Asserting ${ids.length} actor(s)`);@@ -292,8 +295,11 @@ Actors.assert = async (ids, options = {}) => {} else if (Array.isArray(assertion)) {return [...actors, ...assertion];}-- // otherwise, assertGroup returned true and output can be safely ignored.+ // assertGroup returned true (all groups already present)+ // if there are no regular actors, propagate true; otherwise return actors+ if (!actors.length) {+ return true;+ }}return actors;@@ -314,9 +320,12 @@ Actors.assertGroup = async (ids, options = {}) => {qualifyGroup: true,...options,});- if (!ids) {+ if (ids === false) {return ids;}+ if (!ids.length) {+ return true;+ }activitypub.helpers.log(`[activitypub/actors] Asserting ${ids.length} group(s)`);diff --git a/test/activitypub/actors.js b/test/activitypub/actors.jsindex 6f9912897c..9402aae24c 100644--- a/test/activitypub/actors.js+++ b/test/activitypub/actors.js@@ -20,6 +20,7 @@ const helpers = require('./helpers');describe('as:Person (Actor asserton)', () => {before(async () => {meta.config.activitypubEnabled = 1;+ meta.config.activitypubAllowLoopback = 1;await install.giveWorldPrivileges();});@@ -215,6 +216,10 @@ describe('as:Person (Actor asserton)', () => {});describe('as:Group', () => {+ before(async () => {+ meta.config.activitypubAllowLoopback = 1;+ });+describe('assertion', () => {let actorUri;let actorData;