mirror of
https://github.com/hzrd149/nsite-gateway.git
synced 2025-06-23 12:05:01 +00:00
18 lines
497 B
TypeScript
18 lines
497 B
TypeScript
import NDK from "@nostr-dev-kit/ndk";
|
|
import { LOOKUP_RELAYS, NOSTR_RELAYS } from "./env.js";
|
|
|
|
const ndk = new NDK({
|
|
explicitRelayUrls: [...LOOKUP_RELAYS, ...NOSTR_RELAYS],
|
|
});
|
|
|
|
ndk.connect();
|
|
|
|
export async function getUserOutboxes(pubkey: string) {
|
|
const mailboxes = await ndk.fetchEvent({ kinds: [10002], authors: [pubkey] });
|
|
if (!mailboxes) return;
|
|
|
|
return mailboxes.tags.filter((t) => t[0] === "r" && (t[2] === undefined || t[2] === "write")).map((t) => t[1]);
|
|
}
|
|
|
|
export default ndk;
|