diff --git a/apps/admin-x-activitypub/package.json b/apps/admin-x-activitypub/package.json index 0a82021058..a88ecd5c2e 100644 --- a/apps/admin-x-activitypub/package.json +++ b/apps/admin-x-activitypub/package.json @@ -1,6 +1,6 @@ { "name": "@tryghost/admin-x-activitypub", - "version": "0.3.21", + "version": "0.3.22", "license": "MIT", "repository": { "type": "git", diff --git a/apps/admin-x-activitypub/src/api/activitypub.test.ts b/apps/admin-x-activitypub/src/api/activitypub.test.ts index f16ec28578..5c64da3623 100644 --- a/apps/admin-x-activitypub/src/api/activitypub.test.ts +++ b/apps/admin-x-activitypub/src/api/activitypub.test.ts @@ -1336,4 +1336,33 @@ describe('ActivityPubAPI', function () { expect(actual).toEqual(expected); }); }); + + describe('note', function () { + test('It creates a note and returns it', async function () { + const fakeFetch = Fetch({ + [`https://activitypub.api/.ghost/activitypub/actions/note`]: { + async assert(_resource, init) { + expect(init?.method).toEqual('POST'); + expect(init?.body).toEqual('{"content":"Hello, world!"}'); + }, + response: JSONResponse({ + id: 'https://example.com/note/abc123' + }) + } + }); + + const api = new ActivityPubAPI( + new URL('https://activitypub.api'), + new URL('https://auth.api'), + 'index', + fakeFetch + ); + + const result = await api.note('Hello, world!'); + + expect(result).toEqual({ + id: 'https://example.com/note/abc123' + }); + }); + }); }); diff --git a/apps/admin-x-activitypub/src/api/activitypub.ts b/apps/admin-x-activitypub/src/api/activitypub.ts index ab37d24788..11a31876a1 100644 --- a/apps/admin-x-activitypub/src/api/activitypub.ts +++ b/apps/admin-x-activitypub/src/api/activitypub.ts @@ -325,6 +325,12 @@ export class ActivityPubAPI { return response; } + async note(content: string) { + const url = new URL('.ghost/activitypub/actions/note', this.apiUrl); + const response = await this.fetchJSON(url, 'POST', {content}); + return response; + } + get userApiUrl() { return new URL(`.ghost/activitypub/users/${this.handle}`, this.apiUrl); } diff --git a/apps/admin-x-activitypub/src/components/Inbox.tsx b/apps/admin-x-activitypub/src/components/Inbox.tsx index 4437af8233..629af8ddae 100644 --- a/apps/admin-x-activitypub/src/components/Inbox.tsx +++ b/apps/admin-x-activitypub/src/components/Inbox.tsx @@ -95,7 +95,7 @@ const Inbox: React.FC = ({layout}) => {