mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 02:47:06 +00:00
Add claim to alert add
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -256,6 +263,22 @@
|
||||
</div>
|
||||
{/snippet}
|
||||
</FieldInline>
|
||||
<FieldInline>
|
||||
{#snippet label()}
|
||||
<p>Invite Code</p>
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<label class="input input-bordered flex w-full items-center gap-2">
|
||||
<input bind:value={claim} />
|
||||
</label>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
<p>
|
||||
To get notifications from private spaces, please provide an invite code which grants access
|
||||
to the space.
|
||||
</p>
|
||||
{/snippet}
|
||||
</FieldInline>
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon="alt-arrow-left" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import type {Alert} from "@app/state"
|
||||
import {NOTIFIER_RELAY} from "@app/state"
|
||||
import {NOTIFIER_RELAY, NOTIFIER_PUBKEY} from "@app/state"
|
||||
import {publishDelete} from "@app/commands"
|
||||
import {pushToast} from "@app/toast"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
const {alert}: Props = $props()
|
||||
|
||||
const confirm = () => {
|
||||
publishDelete({event: alert.event, relays: [NOTIFIER_RELAY]})
|
||||
publishDelete({event: alert.event, relays: [NOTIFIER_RELAY], tags: [["p", NOTIFIER_PUBKEY]]})
|
||||
pushToast({message: "Your alert has been deleted!"})
|
||||
history.back()
|
||||
}
|
||||
|
||||
@@ -62,8 +62,6 @@
|
||||
}
|
||||
|
||||
let limit = $state(3)
|
||||
|
||||
$inspect($messages)
|
||||
</script>
|
||||
|
||||
<div class="card2 bg-alt">
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
sortBy,
|
||||
assoc,
|
||||
now,
|
||||
removeNil,
|
||||
isNotNil,
|
||||
filterVals,
|
||||
fromPairs,
|
||||
@@ -442,9 +441,7 @@ export const discoverRelays = (lists: List[]) =>
|
||||
)
|
||||
|
||||
export const requestRelayClaim = async (url: string) => {
|
||||
const relay = await loadRelay(url)
|
||||
const authors = removeNil([relay?.profile?.self, relay?.profile?.pubkey])
|
||||
const filters = [{kinds: [AUTH_INVITE], authors, limit: 1}]
|
||||
const filters = [{kinds: [AUTH_INVITE], limit: 1}]
|
||||
const events = await load({filters, relays: [url]})
|
||||
|
||||
if (events.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user