mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
41 lines
No EOL
1.1 KiB
TypeScript
41 lines
No EOL
1.1 KiB
TypeScript
import { Conf } from '@/config.ts';
|
|
import { parseMetaContent } from '@/schema.ts';
|
|
|
|
import type { Event } from '@/event.ts';
|
|
import type { Actor } from '@/schemas/activitypub.ts';
|
|
|
|
/** Nostr metadata event to ActivityPub actor. */
|
|
async function toActor(event: Event<0>, username: string): Promise<Actor> {
|
|
const content = parseMetaContent(event);
|
|
|
|
return {
|
|
type: 'Person',
|
|
id: Conf.local(`/users/${username}`),
|
|
name: content?.name || '',
|
|
preferredUsername: username,
|
|
inbox: Conf.local(`/users/${username}/inbox`),
|
|
followers: Conf.local(`/users/${username}/followers`),
|
|
following: Conf.local(`/users/${username}/following`),
|
|
outbox: Conf.local(`/users/${username}/outbox`),
|
|
icon: content.picture
|
|
? {
|
|
type: 'Image',
|
|
url: content.picture,
|
|
}
|
|
: undefined,
|
|
image: content.banner
|
|
? {
|
|
type: 'Image',
|
|
url: content.banner,
|
|
}
|
|
: undefined,
|
|
summary: content.about ?? '',
|
|
attachment: [],
|
|
tag: [],
|
|
endpoints: {
|
|
sharedInbox: Conf.local('/inbox'),
|
|
},
|
|
};
|
|
}
|
|
|
|
export { toActor }; |