diff --git a/config/default.yaml b/config/default.yaml index acc17ee84..ada229a21 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -433,6 +433,9 @@ plugins: url: 'https://packages.joinpeertube.org' federation: + # Enable ActivityPub endpoints (inbox/outbox) + enabled: true + # Some federated software such as Mastodon may require an HTTP signature to access content sign_federated_fetches: true diff --git a/config/production.yaml.example b/config/production.yaml.example index 736f26cda..50d0db300 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -431,6 +431,9 @@ plugins: url: 'https://packages.joinpeertube.org' federation: + # Enable ActivityPub endpoints (inbox/outbox) + enabled: true + # Some federated software such as Mastodon may require an HTTP signature to access content sign_federated_fetches: true diff --git a/packages/tests/src/api/server/follow-constraints.ts b/packages/tests/src/api/server/follow-constraints.ts index 8d277c906..8c9703ce5 100644 --- a/packages/tests/src/api/server/follow-constraints.ts +++ b/packages/tests/src/api/server/follow-constraints.ts @@ -6,6 +6,8 @@ import { cleanupTests, createMultipleServers, doubleFollow, + makeActivityPubGetRequest, + makeGetRequest, PeerTubeServer, setAccessTokensToServers, waitJobs @@ -315,6 +317,26 @@ describe('Test follow constraints', function () { }) }) + describe('When disabling federation', function () { + + before(async function () { + this.timeout(60_000) + + await servers[0].kill() + await servers[0].run({ federation: { enabled: false } }) + }) + + it('Should not federate anymore', async function () { + const { uuid } = await servers[0].videos.quickUpload({ name: 'non federated video' }) + await waitJobs(servers) + + await servers[1].videos.get({ id: uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + + await makeActivityPubGetRequest(servers[0].url, '/inbox', HttpStatusCode.NOT_ACCEPTABLE_406) + await makeActivityPubGetRequest(servers[0].url, '/outbox', HttpStatusCode.NOT_ACCEPTABLE_406) + }) + }) + after(async function () { await cleanupTests(servers) }) diff --git a/server/core/controllers/activitypub/index.ts b/server/core/controllers/activitypub/index.ts index 7057457ee..f675de001 100644 --- a/server/core/controllers/activitypub/index.ts +++ b/server/core/controllers/activitypub/index.ts @@ -1,5 +1,4 @@ import express from 'express' - import { activityPubClientRouter } from './client.js' import { inboxRouter } from './inbox.js' import { outboxRouter } from './outbox.js' diff --git a/server/core/initializers/checker-before-init.ts b/server/core/initializers/checker-before-init.ts index 8397b1517..748d74580 100644 --- a/server/core/initializers/checker-before-init.ts +++ b/server/core/initializers/checker-before-init.ts @@ -74,7 +74,7 @@ function checkMissedConfig () { 'feeds.videos.count', 'feeds.comments.count', 'geo_ip.enabled', 'geo_ip.country.database_url', 'geo_ip.city.database_url', 'remote_redundancy.videos.accept_from', - 'federation.videos.federate_unlisted', 'federation.videos.cleanup_remote_interactions', + 'federation.enabled', 'federation.videos.federate_unlisted', 'federation.videos.cleanup_remote_interactions', 'peertube.check_latest_version.enabled', 'peertube.check_latest_version.url', 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url', 'search.search_index.disable_local_search', 'search.search_index.is_default_search', diff --git a/server/core/initializers/config.ts b/server/core/initializers/config.ts index 79367784d..6a6522f5c 100644 --- a/server/core/initializers/config.ts +++ b/server/core/initializers/config.ts @@ -341,6 +341,7 @@ const CONFIG = { } }, FEDERATION: { + ENABLED: config.get('federation.enabled'), VIDEOS: { FEDERATE_UNLISTED: config.get('federation.videos.federate_unlisted'), CLEANUP_REMOTE_INTERACTIONS: config.get('federation.videos.cleanup_remote_interactions') diff --git a/server/server.ts b/server/server.ts index 23e6cb1e6..603e35e80 100644 --- a/server/server.ts +++ b/server/server.ts @@ -232,7 +232,10 @@ app.use('/api/' + API_VERSION, apiRouter) // Services (oembed...) app.use('/services', servicesRouter) -app.use('/', activityPubRouter) +if (CONFIG.FEDERATION.ENABLED) { + app.use('/', activityPubRouter) +} + app.use('/', feedsRouter) app.use('/', trackerRouter) app.use('/', sitemapRouter)