From 8f9dbcd0ea0e733dad69f5e6d8d126e41b642314 Mon Sep 17 00:00:00 2001 From: Fabien 'egg' O'Carroll Date: Thu, 7 Nov 2024 13:55:11 +0000 Subject: [PATCH] Added Ghost ActivityPub internal integration (#21540) refs https://linear.app/ghost/issue/AP-500 Rather than having to manually create an integration for communication with the ActivityPub service, we are going to have an internal integration which will then be used to handle webhooks between Ghost & ActivityPub The 'internal' type has been used to keep it out of the UI/API but available for all Pro customers, which is necessary during the private beta. --------- Co-authored-by: Michael Barrett --- ...06-04-45-15-add-activitypub-integration.js | 40 +++++++++++++++++++ .../server/data/schema/fixtures/fixtures.json | 7 ++++ .../unit/server/data/schema/integrity.test.js | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 ghost/core/core/server/data/migrations/versions/5.100/2024-11-06-04-45-15-add-activitypub-integration.js diff --git a/ghost/core/core/server/data/migrations/versions/5.100/2024-11-06-04-45-15-add-activitypub-integration.js b/ghost/core/core/server/data/migrations/versions/5.100/2024-11-06-04-45-15-add-activitypub-integration.js new file mode 100644 index 0000000000..6ed57c7fce --- /dev/null +++ b/ghost/core/core/server/data/migrations/versions/5.100/2024-11-06-04-45-15-add-activitypub-integration.js @@ -0,0 +1,40 @@ +const logging = require('@tryghost/logging'); +const {createTransactionalMigration, meta} = require('../../utils'); +const ObjectID = require('bson-objectid').default; + +module.exports = createTransactionalMigration( + async function up(knex) { + logging.info('Adding Ghost ActivityPub integration'); + const existing = await knex + .select('id') + .from('integrations') + .where('slug', '=', 'ghost-activitypub') + .andWhere('type', '=', 'internal') + .first(); + + if (existing) { + logging.warn('Found existing Ghost ActivityPub integration'); + return; + } + + await knex + .insert({ + id: (new ObjectID).toHexString(), + type: 'internal', + slug: 'ghost-activitypub', + name: 'Ghost ActivityPub', + description: 'Internal Integration for ActivityPub', + created_at: knex.raw('current_timestamp'), + created_by: meta.MIGRATION_USER + }) + .into('integrations'); + }, + async function down(knex) { + logging.info('Removing Ghost ActivityPub integration'); + await knex + .del() + .from('integrations') + .where('slug', '=', 'ghost-activitypub') + .andWhere('type', '=', 'internal'); + } +); diff --git a/ghost/core/core/server/data/schema/fixtures/fixtures.json b/ghost/core/core/server/data/schema/fixtures/fixtures.json index 1d83925ad0..f69a0c79a7 100644 --- a/ghost/core/core/server/data/schema/fixtures/fixtures.json +++ b/ghost/core/core/server/data/schema/fixtures/fixtures.json @@ -814,6 +814,13 @@ "description": "Internal Content API integration for Admin access", "type": "core", "api_keys": [{"type": "content"}] + }, + { + "slug": "ghost-activitypub", + "name": "Ghost ActivityPub", + "description": "Internal Integration for ActivityPub", + "type": "internal", + "api_keys": [] } ] } diff --git a/ghost/core/test/unit/server/data/schema/integrity.test.js b/ghost/core/test/unit/server/data/schema/integrity.test.js index c066a50308..8b1f114df9 100644 --- a/ghost/core/test/unit/server/data/schema/integrity.test.js +++ b/ghost/core/test/unit/server/data/schema/integrity.test.js @@ -36,7 +36,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route describe('DB version integrity', function () { // Only these variables should need updating const currentSchemaHash = 'f12341a0c74998eeb4628322fd0982fb'; - const currentFixturesHash = '475f488105c390bb0018db90dce845f1'; + const currentFixturesHash = '80e79d1efd5da275e19cb375afb4ad04'; const currentSettingsHash = '47a75e8898fab270174a0c905cb3e914'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';