Skip to content

Node.js based forum software built for the modern web

fix: unintentional origin mismatch error thrown when user deletes their own post and the community announces it

Julian Lamd19d0972022b
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js
index f9a01663d6..f6bef4e957 100644
--- a/src/activitypub/inbox.js
+++ b/src/activitypub/inbox.js
@@ -494,10 +494,17 @@ inbox.announce = async (req) => {
break;
}
- // Deletions must be made by an actor of the same origin
+ /**
+ * Deletions must be made by:
+ * - an actor of the same origin as announcer (mod deletion), OR
+ * - an actor of the same origin as the object id (use case: self-deletion), OR
+ * - (TBD) an actor in the announcer's moderators list
+ */
const announcerHostname = new URL(actor).hostname;
const actorHostname = new URL(object.actor).hostname;
- if (announcerHostname !== actorHostname) {
+ const objectHostname = new URL(id).hostname;
+ const pass = (announcerHostname === actorHostname) || (actorHostname === objectHostname);
+ if (!pass) {
throw new Error('[[error:activitypub.origin-mismatch]]');
}