Skip to content

Node.js based forum software built for the modern web

fix(privileges): route ActivityPub URIs to fediverse pseudo-user check

Julian Lam2da82dbb0091
diff --git a/src/privileges/helpers.js b/src/privileges/helpers.js
index 0e50011027..ce61d72c32 100644
--- a/src/privileges/helpers.js
+++ b/src/privileges/helpers.js
@@ -9,6 +9,7 @@ const user = require('../user');
const categories = require('../categories');
const plugins = require('../plugins');
const utils = require('../utils');
+const activitypub = require('../activitypub');
const helpers = module.exports;
@@ -75,6 +76,11 @@ async function isAllowedToCids(privilege, uidOrGroupName, cids) {
const groupKeys = cids.map(cid => `cid:${cid}:privileges:groups:${privilege}`);
+ // Remote ActivityPub actors (URIs) are treated as the fediverse pseudo-user
+ if (activitypub.helpers.isUri(uidOrGroupName)) {
+ return await isSystemGroupAllowedToCids(privilege, -2, cids);
+ }
+
// Group handling
if (!utils.isNumber(uidOrGroupName) && (uidOrGroupName || '').length) {
return await checkIfAllowedGroup(uidOrGroupName, groupKeys);
@@ -91,6 +97,11 @@ async function isAllowedToCids(privilege, uidOrGroupName, cids) {
async function isAllowedToPrivileges(privileges, uidOrGroupName, cid) {
const groupKeys = privileges.map(privilege => `cid:${cid}:privileges:groups:${privilege}`);
+ // Remote ActivityPub actors (URIs) are treated as the fediverse pseudo-user
+ if (activitypub.helpers.isUri(uidOrGroupName)) {
+ return await isSystemGroupAllowedToPrivileges(privileges, -2, cid);
+ }
+
// Group handling
if (isNaN(parseInt(uidOrGroupName, 10)) && (uidOrGroupName || '').length) {
return await checkIfAllowedGroup(uidOrGroupName, groupKeys);