mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-23 16:24:24 +01:00
Include source property on own account
This commit is contained in:
@@ -11,7 +11,7 @@ const credentialsController: AppController = async (c) => {
|
|||||||
|
|
||||||
const event = await getAuthor(pubkey);
|
const event = await getAuthor(pubkey);
|
||||||
if (event) {
|
if (event) {
|
||||||
return c.json(toAccount(event));
|
return c.json(toAccount(event, { withSource: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.json({ error: 'Could not find user.' }, 404);
|
return c.json({ error: 'Could not find user.' }, 404);
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ import { type Nip05, parseNip05 } from './utils.ts';
|
|||||||
const DEFAULT_AVATAR = 'https://gleasonator.com/images/avi.png';
|
const DEFAULT_AVATAR = 'https://gleasonator.com/images/avi.png';
|
||||||
const DEFAULT_BANNER = 'https://gleasonator.com/images/banner.png';
|
const DEFAULT_BANNER = 'https://gleasonator.com/images/banner.png';
|
||||||
|
|
||||||
function toAccount(event: Event<0>) {
|
interface ToAccountOpts {
|
||||||
|
withSource?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toAccount(event: Event<0>, opts: ToAccountOpts = {}) {
|
||||||
|
const { withSource = false } = opts;
|
||||||
|
|
||||||
const { pubkey } = event;
|
const { pubkey } = event;
|
||||||
const { name, nip05, picture, banner, about }: MetaContent = parseContent(event);
|
const { name, nip05, picture, banner, about }: MetaContent = parseContent(event);
|
||||||
const { origin } = new URL(LOCAL_DOMAIN);
|
const { origin } = new URL(LOCAL_DOMAIN);
|
||||||
@@ -35,6 +41,16 @@ function toAccount(event: Event<0>) {
|
|||||||
follow_requests_count: 0,
|
follow_requests_count: 0,
|
||||||
followers_count: 0,
|
followers_count: 0,
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
|
source: withSource
|
||||||
|
? {
|
||||||
|
fields: [],
|
||||||
|
language: '',
|
||||||
|
note: about || '',
|
||||||
|
privacy: 'public',
|
||||||
|
sensitive: false,
|
||||||
|
follow_requests_count: 0,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
statuses_count: 0,
|
statuses_count: 0,
|
||||||
header: banner || DEFAULT_BANNER,
|
header: banner || DEFAULT_BANNER,
|
||||||
header_static: banner || DEFAULT_BANNER,
|
header_static: banner || DEFAULT_BANNER,
|
||||||
|
|||||||
Reference in New Issue
Block a user