diff --git a/src/app/commands.ts b/src/app/commands.ts index df37f32..6ffe9b3 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -306,20 +306,26 @@ export const attemptRelayAccess = async (url: string, claim = "") => { // Actions -export const makeDelete = ({event}: {event: TrustedEvent}) => { - const tags = [["k", String(event.kind)], ...tagEvent(event)] +export const makeDelete = ({event, tags = []}: {event: TrustedEvent; tags?: string[][]}) => { + const thisTags = [["k", String(event.kind)], ...tagEvent(event), ...tags] const groupTag = getTag("h", event.tags) if (groupTag) { - tags.push(PROTECTED) - tags.push(groupTag) + thisTags.push(PROTECTED, groupTag) } - return makeEvent(DELETE, {tags}) + return makeEvent(DELETE, {tags: thisTags}) } -export const publishDelete = ({relays, event}: {relays: string[]; event: TrustedEvent}) => - publishThunk({event: makeDelete({event}), relays}) +export const publishDelete = ({ + relays, + event, + tags = [], +}: { + relays: string[] + event: TrustedEvent + tags?: string[][] +}) => publishThunk({event: makeDelete({event, tags}), relays}) export type ReportParams = { event: TrustedEvent diff --git a/src/app/components/AlertAdd.svelte b/src/app/components/AlertAdd.svelte index a9ca263..2c3326c 100644 --- a/src/app/components/AlertAdd.svelte +++ b/src/app/components/AlertAdd.svelte @@ -29,7 +29,7 @@ NOTIFIER_PUBKEY, NOTIFIER_RELAY, } from "@app/state" - import {loadAlertStatuses, requestRelayClaims} from "@app/requests" + import {loadAlertStatuses, requestRelayClaim} from "@app/requests" import {publishAlert, attemptAuth} from "@app/commands" import type {AlertParams} from "@app/commands" import {platform, canSendPushNotifications, getPushInfo} from "@app/push" @@ -59,6 +59,7 @@ let loading = $state(false) let cron = $state(WEEKLY) + let claim = $state("") let email = $state($alerts.map(a => getTagValue("email", a.tags)).filter(identity)[0] || "") const back = () => history.back() @@ -108,7 +109,7 @@ loading = true try { - const claims = await requestRelayClaims([relay]) + const claims = claim ? {[relay]: claim} : {} const feed = makeIntersectionFeed(feedFromFilters(filters), makeRelayFeed(relay)) const description = `for ${displayList(display)} on ${displayRelayUrl(relay)}` const params: AlertParams = {feed, claims, description} @@ -177,6 +178,12 @@ if (!canSendPushNotifications()) { channel = "email" } + + requestRelayClaim(relay).then(code => { + if (code) { + claim = code + } + }) }) @@ -256,6 +263,22 @@ {/snippet} + + {#snippet label()} +

Invite Code

+ {/snippet} + {#snippet input()} + + {/snippet} + {#snippet info()} +

+ To get notifications from private spaces, please provide an invite code which grants access + to the space. +

+ {/snippet} +