Remove app date functions

This commit is contained in:
Jon Staab
2025-04-30 14:14:03 -07:00
parent a42ee30066
commit f20eab929e
6 changed files with 34 additions and 63 deletions
+26 -3
View File
@@ -1,9 +1,11 @@
import {get} from "svelte/store"
import {addToListPublicly, removeFromList, makeList, FOLLOWS, MUTES, PINS} from "@welshman/util"
import {uniq} from "@welshman/lib"
import {addToListPublicly, EventTemplate, removeFromList, makeList, FOLLOWS, MUTES, PINS} from "@welshman/util"
import {Nip59, stamp} from "@welshman/signer"
import {Router, addMaximalFallbacks} from "@welshman/router"
import {userFollows, userMutes, userPins} from "./user.js"
import {nip44EncryptToSelf} from "./session.js"
import {publishThunk} from "./thunk.js"
import {nip44EncryptToSelf, signer} from "./session.js"
import {ThunkOptions, MergedThunk, publishThunk} from "./thunk.js"
export const unfollow = async (value: string) => {
const list = get(userFollows) || makeList({kind: FOLLOWS})
@@ -52,3 +54,24 @@ export const pin = async (tag: string[]) => {
return publishThunk({event, relays})
}
export type SendWrappedOptions = Omit<ThunkOptions, "event" | "relays"> & {
template: EventTemplate
pubkeys: string[]
}
export const sendWrapped = async ({template, pubkeys, ...options}: SendWrappedOptions) => {
const nip59 = Nip59.fromSigner(signer.get()!)
return new MergedThunk(
await Promise.all(
uniq(pubkeys).map(async recipient =>
publishThunk({
event: await nip59.wrap(recipient, stamp(template)),
relays: Router.get().PubkeyInbox(recipient).getUrls(),
...options,
}),
),
),
)
}