Load messaging relays before sending wrapped messages
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
getListTags,
|
getListTags,
|
||||||
getRelayTags,
|
getRelayTags,
|
||||||
getRelayTagValues,
|
getRelayTagValues,
|
||||||
|
getRelaysFromList,
|
||||||
makeList,
|
makeList,
|
||||||
makeRoomCreateEvent,
|
makeRoomCreateEvent,
|
||||||
makeRoomDeleteEvent,
|
makeRoomDeleteEvent,
|
||||||
@@ -50,6 +51,7 @@ import {
|
|||||||
} from "./user.js"
|
} from "./user.js"
|
||||||
import {nip44EncryptToSelf, signer} from "./session.js"
|
import {nip44EncryptToSelf, signer} from "./session.js"
|
||||||
import {ThunkOptions, MergedThunk, publishThunk} from "./thunk.js"
|
import {ThunkOptions, MergedThunk, publishThunk} from "./thunk.js"
|
||||||
|
import {loadMessagingRelayList} from "./messagingRelayLists.js"
|
||||||
|
|
||||||
// NIP 65
|
// NIP 65
|
||||||
|
|
||||||
@@ -261,13 +263,15 @@ export type SendWrappedOptions = Omit<ThunkOptions, "event" | "relays"> & {
|
|||||||
recipients: string[]
|
recipients: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendWrapped = ({event, recipients, ...options}: SendWrappedOptions) =>
|
export const sendWrapped = async ({event, recipients, ...options}: SendWrappedOptions) =>
|
||||||
new MergedThunk(
|
new MergedThunk(
|
||||||
uniq(recipients).map(recipient => {
|
await Promise.all(
|
||||||
const relays = Router.get().MessagesForPubkey(recipient).getUrls()
|
uniq(recipients).map(async recipient => {
|
||||||
|
const relays = getRelaysFromList(await loadMessagingRelayList(recipient))
|
||||||
|
|
||||||
return publishThunk({event, relays, recipient, ...options})
|
return publishThunk({event, relays, recipient, ...options})
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
// NIP 86
|
// NIP 86
|
||||||
|
|||||||
Reference in New Issue
Block a user