diff --git a/install/data/defaults.json b/install/data/defaults.json index 45ba72014a..75e99f4a9b 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -189,5 +189,7 @@ "composer:allowPluginHelp": 1, "maxReconnectionAttempts": 5, "reconnectionDelay": 1500, - "disableCustomUserSkins": 0 + "disableCustomUserSkins": 0, + "activitypubEnabled": 1, + "activitypubAllowLoopback": 0 } diff --git a/public/language/en-GB/admin/settings/activitypub.json b/public/language/en-GB/admin/settings/activitypub.json index d4cc62360d..95dc35f16d 100644 --- a/public/language/en-GB/admin/settings/activitypub.json +++ b/public/language/en-GB/admin/settings/activitypub.json @@ -1,6 +1,14 @@ { - "acp.intro-lead": "What is Federation?", - "acp.intro-body": "NodeBB is able to communicate with other NodeBB instances that support it. This is achieved through a protocol called ActivityPub. If enabled, NodeBB will also be able to communicate with other apps and websites that use ActivityPub (e.g. Mastodon, Peertube, etc.)", - "acp.general": "General", - "acp.enabled": "Enable Federation" + "intro-lead": "What is Federation?", + "intro-body": "NodeBB is able to communicate with other NodeBB instances that support it. This is achieved through a protocol called ActivityPub. If enabled, NodeBB will also be able to communicate with other apps and websites that use ActivityPub (e.g. Mastodon, Peertube, etc.)", + "general": "General", + "enabled": "Enable Federation", + "enabled-help": "If enabled, will allow this NodeBB will be able to communicate with all Activitypub-enabled clients on the wider fediverse.", + "allowLoopback": "Allow loopback processing", + "allowLoopback-help": "Useful for debugging purposes only. You should probably leave this disabled.", + + "servers": "Servers", + "count": "This NodeBB is currently aware of %1 server(s)", + "server.filter-help": "Specify servers you would like to bar from federating with your NodeBB. Alternatively, you may opt to selectively allow federation with specific servers, instead. Both options are supported, although they are mutually exclusive.", + "server.filter-allow-list": "Use this as an Allow List instead" } \ No newline at end of file diff --git a/src/activitypub/index.js b/src/activitypub/index.js index 5d4922d7f8..b2d7f52d64 100644 --- a/src/activitypub/index.js +++ b/src/activitypub/index.js @@ -6,6 +6,7 @@ const { createHash, createSign, createVerify } = require('crypto'); const request = require('../request'); const db = require('../database'); +const meta = require('../meta'); const user = require('../user'); const utils = require('../utils'); const ttl = require('../cache/ttl'); @@ -45,6 +46,13 @@ ActivityPub.resolveId = async (uid, id) => { ActivityPub.resolveInboxes = async (ids) => { const inboxes = new Set(); + if (!meta.config.activitypubAllowLoopback) { + ids = ids.filter((id) => { + const { hostname } = new URL(id); + return hostname !== nconf.get('url_parsed').hostname; + }); + } + await ActivityPub.actors.assert(ids); await Promise.all(ids.map(async (id) => { const { inbox, sharedInbox } = await user.getUserFields(id, ['inbox', 'sharedInbox']); diff --git a/src/views/admin/settings/activitypub.tpl b/src/views/admin/settings/activitypub.tpl index ce339d0572..6396725009 100644 --- a/src/views/admin/settings/activitypub.tpl +++ b/src/views/admin/settings/activitypub.tpl @@ -1,18 +1,42 @@
[[admin/settings/activitypub:acp.intro-lead]]
-[[admin/settings/activitypub:acp.intro-body]]
+[[admin/settings/activitypub:intro-lead]]
+[[admin/settings/activitypub:intro-body]]