-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: setup announcement actor, add endpoint for actor
- Loading branch information
1 parent
893a428
commit 24db4e6
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { APActor } from 'activitypub-types' | ||
|
||
import type { APIConfig, FastifyTypebox } from '.' | ||
import Store from '../store' | ||
import type ActivityPubSystem from '../apsystem' | ||
|
||
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: { | ||
params: {}, | ||
// XXX: even with Type.Any(), the endpoint returns `{}` :/ | ||
// response: { | ||
// // TODO: typebox APActor | ||
// 200: Type.Any() | ||
// }, | ||
description: 'Announcements ActivityPub actor', | ||
tags: ['ActivityPub'] | ||
} | ||
}, async (request, reply) => { | ||
// return await reply.send({ prueba: 'asdfasd' }) | ||
const actor = await store.announcements.getInfo() | ||
|
||
return await reply.send({ | ||
'@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', | ||
inbox: `${actor.actorUrl}/inbox`, | ||
outbox: `${actor.actorUrl}/outbox`, | ||
publicKey: { | ||
// TODO: copied from Mastodon | ||
id: `${actor.actorUrl}#main-key`, | ||
|
||
owner: actor.actorUrl, | ||
publicKeyPem: actor.keypair.publicKeyPem | ||
} | ||
}) | ||
}) | ||
} |
This file contains 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
This file contains 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