Add fcm push notifications

This commit is contained in:
Jon Staab
2025-06-24 14:15:36 -07:00
parent 6cca823ed4
commit 3655790e5f
19 changed files with 236 additions and 608 deletions
+11 -6
View File
@@ -1,6 +1,5 @@
import * as nip19 from "nostr-tools/nip19"
import {get} from "svelte/store"
import {Capacitor} from "@capacitor/core"
import {randomId, flatten, poll, uniq, equals, TIMEZONE, LOCALE} from "@welshman/lib"
import type {Feed} from "@welshman/feeds"
import type {TrustedEvent, EventContent} from "@welshman/util"
@@ -21,6 +20,7 @@ import {
ALERT_ANDROID,
isSignedEvent,
makeEvent,
getAddress,
displayProfile,
normalizeRelayUrl,
makeList,
@@ -62,8 +62,8 @@ import {
NOTIFIER_PUBKEY,
NOTIFIER_RELAY,
userRoomsByUrl,
deviceAlertAddresses,
} from "@app/state"
import {getPushInfo} from "@app/push"
// Utils
@@ -388,10 +388,10 @@ export type AlertParams = {
auth: string
}
ios?: {
nothing: string
device_token: string
}
android?: {
nothing: string
device_token: string
}
}
@@ -433,5 +433,10 @@ export const makeAlert = async (params: AlertParams) => {
})
}
export const publishAlert = async (params: AlertParams) =>
publishThunk({event: await makeAlert(params), relays: [NOTIFIER_RELAY]})
export const publishAlert = async (params: AlertParams) => {
const event = await signer.get().sign(await makeAlert(params))
deviceAlertAddresses.update($addresses => [...$addresses, getAddress(event)])
return publishThunk({event, relays: [NOTIFIER_RELAY]})
}