From bd27b7ca3aa52c4d578782014c1356969f118ea1 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 13 Dec 2022 16:06:18 -0500 Subject: [PATCH] server: add typing for renderFollowRelay --- .../src/remote/activitypub/renderer/follow-relay.ts | 11 +++++++++-- packages/backend/src/services/relay.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts b/packages/backend/src/remote/activitypub/renderer/follow-relay.ts index 2c9678090..b172f6ba9 100644 --- a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts +++ b/packages/backend/src/remote/activitypub/renderer/follow-relay.ts @@ -2,13 +2,20 @@ import config from '@/config/index.js'; import { Relay } from '@/models/entities/relay.js'; import { ILocalUser } from '@/models/entities/user.js'; -export function renderFollowRelay(relay: Relay, relayActor: ILocalUser) { +export type FollowRelay = { + id: string; + type: 'Follow'; + actor: string; + object: 'https://www.w3.org/ns/activitystreams#Public'; +}; + +export function renderFollowRelay(relay: Relay, relayActor: ILocalUser): FollowRelay { const follow = { id: `${config.url}/activities/follow-relay/${relay.id}`, type: 'Follow', actor: `${config.url}/users/${relayActor.id}`, object: 'https://www.w3.org/ns/activitystreams#Public', - }; + } as const; return follow; } diff --git a/packages/backend/src/services/relay.ts b/packages/backend/src/services/relay.ts index 35779e79a..5e5eb35bc 100644 --- a/packages/backend/src/services/relay.ts +++ b/packages/backend/src/services/relay.ts @@ -44,7 +44,7 @@ export async function addRelay(inbox: string): Promise { }).then(x => Relays.findOneByOrFail(x.identifiers[0])); const relayActor = await getRelayActor(); - const follow = await renderFollowRelay(relay, relayActor); + const follow = renderFollowRelay(relay, relayActor); const activity = renderActivity(follow); deliver(relayActor, activity, relay.inbox);