Only protect events if the relay will authenticate with the user
This commit is contained in:
@@ -12,7 +12,10 @@
|
||||
const {alert}: Props = $props()
|
||||
|
||||
const confirm = () => {
|
||||
publishDelete({event: alert.event, relays: [NOTIFIER_RELAY], tags: [["p", NOTIFIER_PUBKEY]]})
|
||||
const relays = [NOTIFIER_RELAY]
|
||||
const tags = [["p", NOTIFIER_PUBKEY]]
|
||||
|
||||
publishDelete({event: alert.event, relays, tags, protect: false})
|
||||
pushToast({message: "Your alert has been deleted!"})
|
||||
history.back()
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import EventActivity from "@app/components/EventActivity.svelte"
|
||||
import EventActions from "@app/components/EventActions.svelte"
|
||||
import CalendarEventEdit from "@app/components/CalendarEventEdit.svelte"
|
||||
import {publishDelete, publishReaction} from "@app/commands"
|
||||
import {publishDelete, publishReaction, canEnforceNip70} from "@app/commands"
|
||||
import {makeCalendarPath} from "@app/routes"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
|
||||
const editEvent = () => pushModal(CalendarEventEdit, {url, event})
|
||||
|
||||
const deleteReaction = (event: TrustedEvent) => publishDelete({relays: [url], event})
|
||||
const deleteReaction = async (event: TrustedEvent) =>
|
||||
publishDelete({relays: [url], event, protect: await canEnforceNip70(url)})
|
||||
|
||||
const createReaction = (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url]})
|
||||
const createReaction = async (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url], protect: await canEnforceNip70(url)})
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import {PROTECTED} from "@app/state"
|
||||
import {makeEditor} from "@app/editor"
|
||||
import {pushToast} from "@app/toast"
|
||||
import {canEnforceNip70} from "@app/commands"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
@@ -63,19 +64,22 @@
|
||||
}
|
||||
|
||||
const ed = await editor
|
||||
const event = makeEvent(EVENT_TIME, {
|
||||
content: ed.getText({blockSeparator: "\n"}).trim(),
|
||||
tags: [
|
||||
["d", initialValues?.d || randomId()],
|
||||
["title", title],
|
||||
["location", location || ""],
|
||||
["start", start.toString()],
|
||||
["end", end.toString()],
|
||||
...daysBetween(start, end).map(D => ["D", D.toString()]),
|
||||
...ed.storage.nostr.getEditorTags(),
|
||||
PROTECTED,
|
||||
],
|
||||
})
|
||||
const content = ed.getText({blockSeparator: "\n"}).trim()
|
||||
const tags = [
|
||||
["d", initialValues?.d || randomId()],
|
||||
["title", title],
|
||||
["location", location || ""],
|
||||
["start", start.toString()],
|
||||
["end", end.toString()],
|
||||
...daysBetween(start, end).map(D => ["D", D.toString()]),
|
||||
...ed.storage.nostr.getEditorTags(),
|
||||
]
|
||||
|
||||
if (await canEnforceNip70(url)) {
|
||||
tags.push(PROTECTED)
|
||||
}
|
||||
|
||||
const event = makeEvent(EVENT_TIME, {content, tags})
|
||||
|
||||
pushToast({message: "Your event has been saved!"})
|
||||
publishThunk({event, relays: [url]})
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import ChannelMessageMenuButton from "@app/components/ChannelMessageMenuButton.svelte"
|
||||
import ChannelMessageMenuMobile from "@app/components/ChannelMessageMenuMobile.svelte"
|
||||
import {colors, ENABLE_ZAPS} from "@app/state"
|
||||
import {publishDelete, publishReaction} from "@app/commands"
|
||||
import {publishDelete, publishReaction, canEnforceNip70} from "@app/commands"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
interface Props {
|
||||
@@ -41,10 +41,11 @@
|
||||
|
||||
const openProfile = () => pushModal(ProfileDetail, {pubkey: event.pubkey, url})
|
||||
|
||||
const deleteReaction = (event: TrustedEvent) => publishDelete({relays: [url], event})
|
||||
const deleteReaction = async (event: TrustedEvent) =>
|
||||
publishDelete({relays: [url], event, protect: await canEnforceNip70(url)})
|
||||
|
||||
const createReaction = (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url]})
|
||||
const createReaction = async (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url], protect: await canEnforceNip70(url)})
|
||||
</script>
|
||||
|
||||
<TapTarget
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
import type {NativeEmoji} from "emoji-picker-element/shared"
|
||||
import EmojiButton from "@lib/components/EmojiButton.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import {publishReaction} from "@app/commands"
|
||||
import {publishReaction, canEnforceNip70} from "@app/commands"
|
||||
|
||||
const {url, event} = $props()
|
||||
|
||||
const onEmoji = (emoji: NativeEmoji) =>
|
||||
publishReaction({event, relays: [url], content: emoji.unicode})
|
||||
const onEmoji = async (emoji: NativeEmoji) =>
|
||||
publishReaction({
|
||||
event,
|
||||
relays: [url],
|
||||
content: emoji.unicode,
|
||||
protect: await canEnforceNip70(url),
|
||||
})
|
||||
</script>
|
||||
|
||||
<EmojiButton {onEmoji} class="btn join-item btn-xs">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import EventInfo from "@app/components/EventInfo.svelte"
|
||||
import EventDeleteConfirm from "@app/components/EventDeleteConfirm.svelte"
|
||||
import {ENABLE_ZAPS} from "@app/state"
|
||||
import {publishReaction} from "@app/commands"
|
||||
import {publishReaction, canEnforceNip70} from "@app/commands"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
type Props = {
|
||||
@@ -20,9 +20,14 @@
|
||||
|
||||
const {url, event, reply}: Props = $props()
|
||||
|
||||
const onEmoji = ((event: TrustedEvent, url: string, emoji: NativeEmoji) => {
|
||||
const onEmoji = (async (event: TrustedEvent, url: string, emoji: NativeEmoji) => {
|
||||
history.back()
|
||||
publishReaction({event, relays: [url], content: emoji.unicode})
|
||||
publishReaction({
|
||||
event,
|
||||
relays: [url],
|
||||
content: emoji.unicode,
|
||||
protect: await canEnforceNip70(url),
|
||||
})
|
||||
}).bind(undefined, event, url)
|
||||
|
||||
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
const reply = () => replyTo(event)
|
||||
|
||||
const deleteReaction = (event: TrustedEvent) =>
|
||||
sendWrapped({template: makeDelete({event}), pubkeys})
|
||||
sendWrapped({template: makeDelete({event, protect: false}), pubkeys})
|
||||
|
||||
const createReaction = (template: EventContent) =>
|
||||
sendWrapped({template: makeReaction({event, ...template}), pubkeys})
|
||||
sendWrapped({template: makeReaction({event, protect: false, ...template}), pubkeys})
|
||||
|
||||
const openProfile = () => pushModal(ProfileDetail, {pubkey: event.pubkey})
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
const {event, pubkeys}: Props = $props()
|
||||
|
||||
const onEmoji = (emoji: NativeEmoji) =>
|
||||
sendWrapped({template: makeReaction({event, content: emoji.unicode}), pubkeys})
|
||||
sendWrapped({template: makeReaction({event, content: emoji.unicode, protect: false}), pubkeys})
|
||||
</script>
|
||||
|
||||
<EmojiButton {onEmoji} class="btn join-item btn-xs">
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
const onEmoji = ((event: TrustedEvent, pubkeys: string[], emoji: NativeEmoji) => {
|
||||
history.back()
|
||||
sendWrapped({template: makeReaction({event, content: emoji.unicode}), pubkeys})
|
||||
sendWrapped({template: makeReaction({event, content: emoji.unicode, protect: false}), pubkeys})
|
||||
}).bind(undefined, event, pubkeys)
|
||||
|
||||
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte"
|
||||
import EventActivity from "@app/components/EventActivity.svelte"
|
||||
import EventActions from "@app/components/EventActions.svelte"
|
||||
import {publishDelete, publishReaction} from "@app/commands"
|
||||
import {publishDelete, publishReaction, canEnforceNip70} from "@app/commands"
|
||||
import {makeThreadPath} from "@app/routes"
|
||||
|
||||
interface Props {
|
||||
@@ -17,10 +17,11 @@
|
||||
|
||||
const path = makeThreadPath(url, event.id)
|
||||
|
||||
const deleteReaction = (event: TrustedEvent) => publishDelete({relays: [url], event})
|
||||
const deleteReaction = async (event: TrustedEvent) =>
|
||||
publishDelete({relays: [url], event, protect: await canEnforceNip70(url)})
|
||||
|
||||
const createReaction = (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url]})
|
||||
const createReaction = async (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url], protect: await canEnforceNip70(url)})
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import EmojiButton from "@lib/components/EmojiButton.svelte"
|
||||
import EventMenu from "@app/components/EventMenu.svelte"
|
||||
import {ENABLE_ZAPS} from "@app/state"
|
||||
import {publishReaction} from "@app/commands"
|
||||
import {publishReaction, canEnforceNip70} from "@app/commands"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
@@ -26,8 +26,13 @@
|
||||
|
||||
const hidePopover = () => popover?.hide()
|
||||
|
||||
const onEmoji = (emoji: NativeEmoji) =>
|
||||
publishReaction({event, content: emoji.unicode, relays: [url]})
|
||||
const onEmoji = async (emoji: NativeEmoji) =>
|
||||
publishReaction({
|
||||
event,
|
||||
content: emoji.unicode,
|
||||
relays: [url],
|
||||
protect: await canEnforceNip70(url),
|
||||
})
|
||||
|
||||
let popover: Instance | undefined = $state()
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import {publishDelete} from "@app/commands"
|
||||
import {publishDelete, canEnforceNip70} from "@app/commands"
|
||||
import {clearModals} from "@app/modal"
|
||||
|
||||
type Props = {
|
||||
@@ -12,7 +12,7 @@
|
||||
const {url, event}: Props = $props()
|
||||
|
||||
const confirm = async () => {
|
||||
await publishDelete({event, relays: [url]})
|
||||
await publishDelete({event, relays: [url], protect: await canEnforceNip70(url)})
|
||||
|
||||
clearModals()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import EditorContent from "@app/editor/EditorContent.svelte"
|
||||
import {publishComment} from "@app/commands"
|
||||
import {publishComment, canEnforceNip70} from "@app/commands"
|
||||
import {PROTECTED} from "@app/state"
|
||||
import {makeEditor} from "@app/editor"
|
||||
import {pushToast} from "@app/toast"
|
||||
@@ -23,7 +23,11 @@
|
||||
|
||||
const ed = await editor
|
||||
const content = ed.getText({blockSeparator: "\n"}).trim()
|
||||
const tags = [...ed.storage.nostr.getEditorTags(), PROTECTED]
|
||||
const tags = ed.storage.nostr.getEditorTags()
|
||||
|
||||
if (await canEnforceNip70(url)) {
|
||||
tags.push(PROTECTED)
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
return pushToast({
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import {publishDelete} from "@app/commands"
|
||||
import {publishDelete, canEnforceNip70} from "@app/commands"
|
||||
|
||||
const {url, event} = $props()
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const deleteReport = (report: TrustedEvent) => {
|
||||
publishDelete({event: report, relays: [url]})
|
||||
const deleteReport = async (report: TrustedEvent) => {
|
||||
publishDelete({event: report, relays: [url], protect: await canEnforceNip70(url)})
|
||||
|
||||
if ($reports.length === 0) {
|
||||
history.back()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte"
|
||||
import EventActivity from "@app/components/EventActivity.svelte"
|
||||
import EventActions from "@app/components/EventActions.svelte"
|
||||
import {publishDelete, publishReaction} from "@app/commands"
|
||||
import {publishDelete, publishReaction, canEnforceNip70} from "@app/commands"
|
||||
import {makeGoalPath} from "@app/routes"
|
||||
|
||||
interface Props {
|
||||
@@ -17,10 +17,11 @@
|
||||
|
||||
const path = makeGoalPath(url, event.id)
|
||||
|
||||
const deleteReaction = (event: TrustedEvent) => publishDelete({relays: [url], event})
|
||||
const deleteReaction = async (event: TrustedEvent) =>
|
||||
publishDelete({relays: [url], event, protect: await canEnforceNip70(url)})
|
||||
|
||||
const createReaction = (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url]})
|
||||
const createReaction = async (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url], protect: await canEnforceNip70(url)})
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import {pushToast} from "@app/toast"
|
||||
import {PROTECTED} from "@app/state"
|
||||
import {makeEditor} from "@app/editor"
|
||||
import {canEnforceNip70} from "@app/commands"
|
||||
|
||||
const {url} = $props()
|
||||
|
||||
@@ -47,9 +48,12 @@
|
||||
["summary", summary],
|
||||
["amount", String(amount)],
|
||||
["relays", url],
|
||||
PROTECTED,
|
||||
]
|
||||
|
||||
if (await canEnforceNip70(url)) {
|
||||
tags.push(PROTECTED)
|
||||
}
|
||||
|
||||
publishThunk({
|
||||
relays: [url],
|
||||
event: makeEvent(ZAP_GOAL, {content, tags}),
|
||||
|
||||
@@ -6,17 +6,23 @@
|
||||
import NoteContent from "@app/components/NoteContent.svelte"
|
||||
import NoteCard from "@app/components/NoteCard.svelte"
|
||||
import ReactionSummary from "@app/components/ReactionSummary.svelte"
|
||||
import {publishDelete, publishReaction} from "@app/commands"
|
||||
import {publishDelete, publishReaction, canEnforceNip70} from "@app/commands"
|
||||
|
||||
const {url, event} = $props()
|
||||
|
||||
const deleteReaction = (event: TrustedEvent) => publishDelete({relays: [url], event})
|
||||
const deleteReaction = async (event: TrustedEvent) =>
|
||||
publishDelete({relays: [url], event, protect: await canEnforceNip70(url)})
|
||||
|
||||
const createReaction = (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url]})
|
||||
const createReaction = async (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url], protect: await canEnforceNip70(url)})
|
||||
|
||||
const onEmoji = (emoji: NativeEmoji) =>
|
||||
publishReaction({event, content: emoji.unicode, relays: [url]})
|
||||
const onEmoji = async (emoji: NativeEmoji) =>
|
||||
publishReaction({
|
||||
event,
|
||||
content: emoji.unicode,
|
||||
relays: [url],
|
||||
protect: await canEnforceNip70(url),
|
||||
})
|
||||
</script>
|
||||
|
||||
<NoteCard {event} {url} class="card2 bg-alt">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte"
|
||||
import EventActivity from "@app/components/EventActivity.svelte"
|
||||
import EventActions from "@app/components/EventActions.svelte"
|
||||
import {publishDelete, publishReaction} from "@app/commands"
|
||||
import {publishDelete, publishReaction, canEnforceNip70} from "@app/commands"
|
||||
import {makeThreadPath} from "@app/routes"
|
||||
|
||||
interface Props {
|
||||
@@ -17,10 +17,11 @@
|
||||
|
||||
const path = makeThreadPath(url, event.id)
|
||||
|
||||
const deleteReaction = (event: TrustedEvent) => publishDelete({relays: [url], event})
|
||||
const deleteReaction = async (event: TrustedEvent) =>
|
||||
publishDelete({relays: [url], event, protect: await canEnforceNip70(url)})
|
||||
|
||||
const createReaction = (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url]})
|
||||
const createReaction = async (template: EventContent) =>
|
||||
publishReaction({...template, event, relays: [url], protect: await canEnforceNip70(url)})
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import {pushToast} from "@app/toast"
|
||||
import {PROTECTED} from "@app/state"
|
||||
import {makeEditor} from "@app/editor"
|
||||
import {canEnforceNip70} from "@app/commands"
|
||||
|
||||
const {url} = $props()
|
||||
|
||||
@@ -41,7 +42,11 @@
|
||||
})
|
||||
}
|
||||
|
||||
const tags = [...ed.storage.nostr.getEditorTags(), ["title", title], PROTECTED]
|
||||
const tags = [...ed.storage.nostr.getEditorTags(), ["title", title]]
|
||||
|
||||
if (await canEnforceNip70(url)) {
|
||||
tags.push(PROTECTED)
|
||||
}
|
||||
|
||||
publishThunk({
|
||||
relays: [url],
|
||||
|
||||
Reference in New Issue
Block a user