feat: add relay selector for posting
This commit is contained in:
parent
2439150c6e
commit
ec11d53fac
25 changed files with 418 additions and 201 deletions
|
|
@ -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)) ?? []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue