Merge branch 'external-uri' into 'main'
Allow setting external URI on statuses See merge request soapbox-pub/ditto!138
This commit is contained in:
commit
d408b2000d
|
@ -48,6 +48,10 @@ class Conf {
|
|||
static get localDomain() {
|
||||
return Deno.env.get('LOCAL_DOMAIN') || 'http://localhost:8000';
|
||||
}
|
||||
/** URL to an external Nostr viewer. */
|
||||
static get externalDomain() {
|
||||
return Deno.env.get('NOSTR_EXTERNAL') || Conf.localDomain;
|
||||
}
|
||||
/** Path to the main SQLite database which stores users, events, and more. */
|
||||
static get dbPath() {
|
||||
return Deno.env.get('DB_PATH') || 'data/db.sqlite3';
|
||||
|
@ -138,6 +142,10 @@ class Conf {
|
|||
static local(path: string): string {
|
||||
return mergePaths(Conf.localDomain, path);
|
||||
}
|
||||
/** Get an external URL for the NIP-19 identifier. */
|
||||
static external(nip19: string): string {
|
||||
return new URL(`/${nip19}`, Conf.externalDomain).toString();
|
||||
}
|
||||
/** URL to send Sentry errors to. */
|
||||
static get sentryDsn() {
|
||||
return Deno.env.get('SENTRY_DSN');
|
||||
|
|
|
@ -15,6 +15,8 @@ import { DittoAttachment, renderAttachment } from '@/views/mastodon/attachments.
|
|||
import { renderEmojis } from '@/views/mastodon/emojis.ts';
|
||||
|
||||
async function renderStatus(event: DittoEvent, viewerPubkey?: string) {
|
||||
const note = nip19.noteEncode(event.id);
|
||||
|
||||
const account = event.author
|
||||
? await renderAccount({ ...event.author, author_stats: event.author_stats })
|
||||
: await accountFromPubkey(event.pubkey);
|
||||
|
@ -92,8 +94,8 @@ async function renderStatus(event: DittoEvent, viewerPubkey?: string) {
|
|||
tags: [],
|
||||
emojis: renderEmojis(event),
|
||||
poll: null,
|
||||
uri: Conf.local(`/posts/${event.id}`),
|
||||
url: Conf.local(`/posts/${event.id}`),
|
||||
uri: Conf.external(note),
|
||||
url: Conf.external(note),
|
||||
zapped: Boolean(zapEvent),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue