UNPKG

nostr-hooks

Version:
25 lines 783 B
import { NDKEvent, NDKRelaySet } from '@nostr-dev-kit/ndk'; import { useStore } from '../../../../store'; export const sendGroupJoinRequest = ({ relay, groupId, joinRequest, onSuccess, onError, }) => { const ndk = useStore.getState().ndk; if (!ndk) return; if (!groupId) return; const event = new NDKEvent(ndk); event.kind = 9021; event.content = joinRequest.reason || ''; event.tags = [['h', groupId]]; joinRequest.code && event.tags.push(['code', joinRequest.code]); event.publish(NDKRelaySet.fromRelayUrls([relay], ndk)).then((r) => { if (r.size > 0) { onSuccess?.(); } else { onError?.(); } }, () => { onError?.(); }); }; //# sourceMappingURL=index.js.map