feat: add relay selector for posting
This commit is contained in:
@@ -94,41 +94,41 @@ class ClientService extends EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
const _additionalRelayUrls: string[] = additionalRelayUrls ?? []
|
||||
if (!specifiedRelayUrls?.length && ![kinds.Contacts, kinds.Mutelist].includes(event.kind)) {
|
||||
const mentions: string[] = []
|
||||
event.tags.forEach(([tagName, tagValue]) => {
|
||||
if (
|
||||
['p', 'P'].includes(tagName) &&
|
||||
!!tagValue &&
|
||||
isValidPubkey(tagValue) &&
|
||||
!mentions.includes(tagValue)
|
||||
) {
|
||||
mentions.push(tagValue)
|
||||
}
|
||||
})
|
||||
if (mentions.length > 0) {
|
||||
const relayLists = await this.fetchRelayLists(mentions)
|
||||
relayLists.forEach((relayList) => {
|
||||
_additionalRelayUrls.push(...relayList.read.slice(0, 4))
|
||||
})
|
||||
}
|
||||
}
|
||||
if (
|
||||
[
|
||||
kinds.RelayList,
|
||||
kinds.Contacts,
|
||||
ExtendedKind.FAVORITE_RELAYS,
|
||||
ExtendedKind.BLOSSOM_SERVER_LIST
|
||||
].includes(event.kind)
|
||||
) {
|
||||
_additionalRelayUrls.push(...BIG_RELAY_URLS)
|
||||
}
|
||||
|
||||
let relays: string[]
|
||||
if (specifiedRelayUrls?.length) {
|
||||
relays = specifiedRelayUrls
|
||||
} else {
|
||||
const _additionalRelayUrls: string[] = additionalRelayUrls ?? []
|
||||
if (!specifiedRelayUrls?.length && ![kinds.Contacts, kinds.Mutelist].includes(event.kind)) {
|
||||
const mentions: string[] = []
|
||||
event.tags.forEach(([tagName, tagValue]) => {
|
||||
if (
|
||||
['p', 'P'].includes(tagName) &&
|
||||
!!tagValue &&
|
||||
isValidPubkey(tagValue) &&
|
||||
!mentions.includes(tagValue)
|
||||
) {
|
||||
mentions.push(tagValue)
|
||||
}
|
||||
})
|
||||
if (mentions.length > 0) {
|
||||
const relayLists = await this.fetchRelayLists(mentions)
|
||||
relayLists.forEach((relayList) => {
|
||||
_additionalRelayUrls.push(...relayList.read.slice(0, 4))
|
||||
})
|
||||
}
|
||||
}
|
||||
if (
|
||||
[
|
||||
kinds.RelayList,
|
||||
kinds.Contacts,
|
||||
ExtendedKind.FAVORITE_RELAYS,
|
||||
ExtendedKind.BLOSSOM_SERVER_LIST
|
||||
].includes(event.kind)
|
||||
) {
|
||||
_additionalRelayUrls.push(...BIG_RELAY_URLS)
|
||||
}
|
||||
|
||||
const relayList = await this.fetchRelayList(event.pubkey)
|
||||
relays = (relayList?.write.slice(0, 10) ?? []).concat(
|
||||
Array.from(new Set(_additionalRelayUrls)) ?? []
|
||||
|
||||
Reference in New Issue
Block a user