Add support for blocked relays
This commit is contained in:
@@ -52,10 +52,8 @@ import {
|
||||
removeFromListByPredicate,
|
||||
getTag,
|
||||
getListTags,
|
||||
getRelayTags,
|
||||
getRelayTagValues,
|
||||
toNostrURI,
|
||||
getRelaysFromList,
|
||||
RelayMode,
|
||||
getAddress,
|
||||
getTagValue,
|
||||
@@ -80,8 +78,6 @@ import {
|
||||
publishThunk,
|
||||
tagEvent,
|
||||
tagEventForReaction,
|
||||
userRelayList,
|
||||
userMessagingRelayList,
|
||||
nip44EncryptToSelf,
|
||||
dropSession,
|
||||
tagEventForComment,
|
||||
@@ -208,42 +204,6 @@ export const removeRoomMembership = async (url: string, h: string) => {
|
||||
return publishThunk({event, relays})
|
||||
}
|
||||
|
||||
export const setRelayPolicy = (url: string, read: boolean, write: boolean) => {
|
||||
const list = get(userRelayList) || makeList({kind: RELAYS})
|
||||
const tags = getRelayTags(getListTags(list)).filter(t => normalizeRelayUrl(t[1]) !== url)
|
||||
|
||||
if (read && write) {
|
||||
tags.push(["r", url])
|
||||
} else if (read) {
|
||||
tags.push(["r", url, "read"])
|
||||
} else if (write) {
|
||||
tags.push(["r", url, "write"])
|
||||
}
|
||||
|
||||
return publishThunk({
|
||||
event: makeEvent(list.kind, {tags}),
|
||||
relays: [url, ...INDEXER_RELAYS, ...Router.get().FromUser().getUrls(), ...get(userSpaceUrls)],
|
||||
})
|
||||
}
|
||||
|
||||
export const setMessagingRelayPolicy = (url: string, enabled: boolean) => {
|
||||
const list = get(userMessagingRelayList) || makeList({kind: MESSAGING_RELAYS})
|
||||
|
||||
// Only update messaging policies if they already exist or we're adding them
|
||||
if (enabled || getRelaysFromList(list).includes(url)) {
|
||||
const tags = getRelayTags(getListTags(list)).filter(t => normalizeRelayUrl(t[1]) !== url)
|
||||
|
||||
if (enabled) {
|
||||
tags.push(["relay", url])
|
||||
}
|
||||
|
||||
return publishThunk({
|
||||
event: makeEvent(list.kind, {tags}),
|
||||
relays: [...INDEXER_RELAYS, ...Router.get().FromUser().getUrls(), ...get(userSpaceUrls)],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Relay access
|
||||
|
||||
export const canEnforceNip70 = async (url: string) => {
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
loadRelayList,
|
||||
loadMessagingRelayList,
|
||||
loadBlossomServerList,
|
||||
loadBlockedRelayList,
|
||||
loadFollowList,
|
||||
loadMuteList,
|
||||
loadProfile,
|
||||
@@ -215,6 +216,7 @@ const syncUserData = () => {
|
||||
loadAlerts($userRelayList.event.pubkey)
|
||||
loadAlertStatuses($userRelayList.event.pubkey)
|
||||
loadBlossomServerList($userRelayList.event.pubkey)
|
||||
loadBlockedRelayList($userRelayList.event.pubkey)
|
||||
loadFollowList($userRelayList.event.pubkey)
|
||||
loadGroupList($userRelayList.event.pubkey)
|
||||
loadMuteList($userRelayList.event.pubkey)
|
||||
@@ -229,13 +231,13 @@ const syncUserData = () => {
|
||||
await sleep(1000)
|
||||
|
||||
await Promise.all(
|
||||
pubkeys.map(async pk => {
|
||||
await loadRelayList(pk)
|
||||
await loadGroupList(pk)
|
||||
await loadProfile(pk)
|
||||
await loadFollowList(pk)
|
||||
await loadMuteList(pk)
|
||||
}),
|
||||
pubkeys.flatMap(pk => [
|
||||
loadRelayList(pk),
|
||||
loadGroupList(pk),
|
||||
loadProfile(pk),
|
||||
loadFollowList(pk),
|
||||
loadMuteList(pk),
|
||||
]),
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user