server: add typing for renderFollowRelay

This commit is contained in:
Norm 2022-12-13 16:06:18 -05:00
parent e28a9eb8e8
commit bd27b7ca3a
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE
2 changed files with 10 additions and 3 deletions

View file

@ -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;
}

View file

@ -44,7 +44,7 @@ export async function addRelay(inbox: string): Promise<Relay> {
}).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);