From 48d2cac1abf64d549cf10c18c90b875a086c575f Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Sat, 27 Sep 2025 21:06:48 -0500 Subject: Upload DMs to specified relays Currently, this is a comma-separated list specified in the env var PUBLIC_DM_RELAYS. Later, it will use users' preferences. --- src/routes/(app)/dm/[recipient]/+page.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/routes/(app)/dm/[recipient]/+page.svelte b/src/routes/(app)/dm/[recipient]/+page.svelte index 8e01b7a8..4f02829d 100644 --- a/src/routes/(app)/dm/[recipient]/+page.svelte +++ b/src/routes/(app)/dm/[recipient]/+page.svelte @@ -2,12 +2,17 @@ import Icon from "$comp/Icon.svelte"; import { hexToBytes, bytesToHex } from '@noble/hashes/utils'; import * as toolsnip17 from 'nostr-tools/nip17'; + import { SimplePool } from 'nostr-tools/pool'; import * as libnip17 from '$lib/nip17'; import { sign, getPrivateKey } from '$lib/nostr'; let { data } = $props(); const { user, recipient } = data; + const pool = new SimplePool(); + import { PUBLIC_DM_RELAYS } from '$env/static/public'; + const DM_RELAYS_LIST = PUBLIC_DM_RELAYS.split(','); + let text = $state(""); const btnCreateMessage = async () => { @@ -20,8 +25,7 @@ event = libnip17.createNIP17MessageSK(text, sk, recipient.pubkey); } - // TODO send event to relays instead of displaying it - text = JSON.stringify(event); + await Promise.any(pool.publish(DM_RELAYS_LIST, event)); } const btnDecryptMessage = async () => { -- cgit v1.2.3