forked from FoundKeyGang/FoundKey
server: add typing for renderFollowRelay
This commit is contained in:
parent
e28a9eb8e8
commit
bd27b7ca3a
2 changed files with 10 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue