mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: allow activities to be addressed to as:Public or Public to be treated as public content
This commit is contained in:
@@ -32,11 +32,15 @@ function reject(type, object, target, senderType = 'uid', id = 0) {
|
||||
}).catch(err => winston.error(err.stack));
|
||||
}
|
||||
|
||||
function publiclyAddressed(recipients) {
|
||||
return activitypub._constants.acceptablePublicAddresses.some(address => recipients.includes(address));
|
||||
}
|
||||
|
||||
inbox.create = async (req) => {
|
||||
const { object, actor } = req.body;
|
||||
|
||||
// Alternative logic for non-public objects
|
||||
const isPublic = [...(object.to || []), ...(object.cc || [])].includes(activitypub._constants.publicAddress);
|
||||
const isPublic = publiclyAddressed([...(object.to || []), ...(object.cc || [])]);
|
||||
if (!isPublic) {
|
||||
return await activitypub.notes.assertPrivate(object);
|
||||
}
|
||||
@@ -76,7 +80,7 @@ inbox.add = async (req) => {
|
||||
|
||||
inbox.update = async (req) => {
|
||||
const { actor, object } = req.body;
|
||||
const isPublic = [...(object.to || []), ...(object.cc || [])].includes(activitypub._constants.publicAddress);
|
||||
const isPublic = publiclyAddressed([...(object.to || []), ...(object.cc || [])]);
|
||||
|
||||
// Origin checking
|
||||
const actorHostname = new URL(actor).hostname;
|
||||
|
||||
@@ -38,6 +38,7 @@ const ActivityPub = module.exports;
|
||||
ActivityPub._constants = Object.freeze({
|
||||
uid: -2,
|
||||
publicAddress: 'https://www.w3.org/ns/activitystreams#Public',
|
||||
acceptablePublicAddresses: ['https://www.w3.org/ns/activitystreams#Public', 'as:Public', 'Public'],
|
||||
acceptableTypes: [
|
||||
'application/activity+json',
|
||||
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
||||
|
||||
Reference in New Issue
Block a user