Created
February 12, 2024 19:54
-
-
Save catdevnull/6563955f57186e4afcecfbf270f0d809 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { APActor } from 'activitypub-types' | |
| import { APIConfig, FastifyTypebox } from '.' | |
| import ActivityPubSystem from '../apsystem' | |
| import Store from '../store' | |
| import { Type } from '@sinclair/typebox' | |
| type APActorNonStandard = APActor & { | |
| publicKey: { | |
| id: string | |
| owner: string | |
| publicKeyPem: string | |
| } | |
| } | |
| export const announcementsRoutes = (cfg: APIConfig, store: Store, apsystem: ActivityPubSystem) => async (server: FastifyTypebox): Promise<void> => { | |
| server.get<{ | |
| Reply: APActorNonStandard | |
| }>('/announcements', { | |
| schema: { | |
| response: { | |
| 200: Type.Any() | |
| }, | |
| description: 'Announcements ActivityPub actor', | |
| tags: ['ActivityPub'] | |
| } | |
| }, async (request, reply) => { | |
| const actor = await store.announcements.getInfo() | |
| return await reply.send({ | |
| inbox: `${actor.actorUrl}/inbox`, | |
| outbox: `${actor.actorUrl}/outbox`, | |
| '@context': [ | |
| // TODO: I copied this from Mastodon, is this correct? | |
| 'https://www.w3.org/ns/activitystreams', | |
| 'https://w3id.org/security/v1' | |
| ], | |
| // https://www.w3.org/TR/activitystreams-vocabulary/#actor-types | |
| type: 'Service', | |
| name: 'Announcements', | |
| publicKey: { | |
| // TODO: copied from Mastodon | |
| id: `${actor.actorUrl}#main-key`, | |
| owner: actor.actorUrl, | |
| publicKeyPem: actor.keypair.publicKeyPem | |
| } | |
| }) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment