Browse Source

feat: send contacts events to big relays

imwald
codytseng 10 months ago
parent
commit
19fc4864cb
  1. 32
      src/providers/NostrProvider/index.tsx

32
src/providers/NostrProvider/index.tsx

@ -485,6 +485,21 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { @@ -485,6 +485,21 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
throw new Error('You need to login first')
}
const event = await signEvent(draftEvent)
if (event.pubkey !== account.pubkey) {
const eventAuthor = await client.fetchProfile(event.pubkey)
const result = confirm(
t(
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?',
{ eventAuthorName: eventAuthor?.username, currentUsername: profile?.username }
)
)
if (!result) {
throw new Error(t('Cancelled'))
}
}
const additionalRelayUrls: string[] = []
if (
!specifiedRelayUrls?.length &&
@ -514,25 +529,10 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { @@ -514,25 +529,10 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
})
}
}
if ([kinds.RelayList, ExtendedKind.FAVORITE_RELAYS].includes(draftEvent.kind)) {
if ([kinds.RelayList, kinds.Contacts, ExtendedKind.FAVORITE_RELAYS].includes(draftEvent.kind)) {
additionalRelayUrls.push(...BIG_RELAY_URLS)
}
const event = await signEvent(draftEvent)
if (event.pubkey !== account.pubkey) {
const eventAuthor = await client.fetchProfile(event.pubkey)
const result = confirm(
t(
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?',
{ eventAuthorName: eventAuthor?.username, currentUsername: profile?.username }
)
)
if (!result) {
throw new Error(t('Cancelled'))
}
}
let relays: string[]
if (specifiedRelayUrls?.length) {
relays = specifiedRelayUrls

Loading…
Cancel
Save