Merge branch 'nostr-external-viewers' into 'main'

Add ditto.external property to accounts and statuses

Closes soapbox#1673

See merge request soapbox-pub/ditto!396
This commit is contained in:
Alex Gleason 2024-06-23 21:11:54 +00:00
commit 961cb070f0
5 changed files with 16 additions and 0 deletions

View file

@ -63,6 +63,14 @@ class Conf {
static get localDomain(): string {
return Deno.env.get('LOCAL_DOMAIN') || `http://localhost:${Conf.port}`;
}
/** Link to an external nostr viewer. */
static get externalDomain(): string {
return Deno.env.get('NOSTR_EXTERNAL') || 'https://njump.me';
}
/** Get a link to a nip19-encoded entity in the configured external viewer. */
static external(path: string) {
return new URL(path, Conf.externalDomain).toString();
}
/**
* Heroku-style database URL. This is used in production to connect to the
* database.

View file

@ -40,6 +40,7 @@ export interface MastodonAccount {
username: string;
ditto: {
accepts_zaps: boolean;
external_url: string;
};
pleroma: {
deactivated: boolean;

View file

@ -39,4 +39,7 @@ export interface MastodonStatus {
expires_at?: string;
quotes_count: number;
};
ditto: {
external_url: string;
};
}

View file

@ -82,6 +82,7 @@ async function renderAccount(
username: parsed05?.nickname || npub.substring(0, 8),
ditto: {
accepts_zaps: Boolean(getLnurl({ lud06, lud16 })),
external_url: Conf.external(npub),
},
pleroma: {
deactivated: names.has('disabled'),

View file

@ -124,6 +124,9 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise<
uri: Conf.local(`/${note}`),
url: Conf.local(`/${note}`),
zapped: Boolean(zapEvent),
ditto: {
external_url: Conf.external(note),
},
pleroma: {
emoji_reactions: reactions,
expires_at: !isNaN(expiresAt.getTime()) ? expiresAt.toISOString() : undefined,