diff --git a/src/app/commands.ts b/src/app/commands.ts index 0f388d52..23e59357 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -213,10 +213,15 @@ export const setInboxRelayPolicy = (url: string, enabled: boolean) => { // Relay access +export const attemptAuth = (url: string) => + Pool.get() + .get(url) + .auth.attemptAuth(e => signer.get()?.sign(e)) + export const checkRelayAccess = async (url: string, claim = "") => { const socket = Pool.get().get(url) - await socket.auth.attemptAuth(e => signer.get()?.sign(e)) + await attemptAuth(url) const thunk = publishThunk({ event: makeEvent(AUTH_JOIN, {tags: [["claim", claim]]}), @@ -274,7 +279,7 @@ export const checkRelayAuth = async (url: string, timeout = 3000) => { const socket = Pool.get().get(url) const okStatuses = [AuthStatus.None, AuthStatus.Ok] - await socket.auth.attemptAuth(e => signer.get()?.sign(e)) + await attemptAuth(url) // Only raise an error if it's not a timeout. // If it is, odds are the problem is with our signer, not the relay diff --git a/src/app/components/AlertAdd.svelte b/src/app/components/AlertAdd.svelte index 697d0256..a9ca2630 100644 --- a/src/app/components/AlertAdd.svelte +++ b/src/app/components/AlertAdd.svelte @@ -22,9 +22,15 @@ import Spinner from "@lib/components/Spinner.svelte" import ModalHeader from "@lib/components/ModalHeader.svelte" import ModalFooter from "@lib/components/ModalFooter.svelte" - import {alerts, getMembershipUrls, userMembership, NOTIFIER_PUBKEY} from "@app/state" + import { + alerts, + getMembershipUrls, + userMembership, + NOTIFIER_PUBKEY, + NOTIFIER_RELAY, + } from "@app/state" import {loadAlertStatuses, requestRelayClaims} from "@app/requests" - import {publishAlert} from "@app/commands" + import {publishAlert, attemptAuth} from "@app/commands" import type {AlertParams} from "@app/commands" import {platform, canSendPushNotifications, getPushInfo} from "@app/push" import {pushToast} from "@app/toast" @@ -134,7 +140,7 @@ } // If we don't do this we'll get an event rejection - await Pool.get().get(NOTIFIER_RELAY).auth.attemptAuth() + await attemptAuth(NOTIFIER_RELAY) const thunk = await publishAlert(params) const error = await getThunkError(thunk) diff --git a/src/app/components/ContentMention.svelte b/src/app/components/ContentMention.svelte index 3544e6db..f2209ea5 100644 --- a/src/app/components/ContentMention.svelte +++ b/src/app/components/ContentMention.svelte @@ -1,8 +1,7 @@ diff --git a/src/service-worker.js b/src/service-worker.js index db2de812..3cb5f4fc 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -23,7 +23,7 @@ self.addEventListener("push", e => { if (data?.event) { url += nip19.neventEncode({ id: data.event.id, - relays: data.relays || [] + relays: data.relays || [], }) }