+
Skip to content

Use pubkey relay if naddr does not provide relay hints #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/app/views/Bech32Entity.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import {Address} from "@welshman/util"
import {loadHandle} from "@welshman/app"
import {ctx} from "@welshman/lib"
import Content from "src/partials/Content.svelte"
import Spinner from "src/partials/Spinner.svelte"
import NoteDetail from "src/app/views/NoteDetail.svelte"
Expand All @@ -16,10 +17,14 @@
<NoteDetail id={data} {relays} />
{:else if type === "naddr"}
{@const address = new Address(data.kind, data.pubkey, data.identifier).toString()}
{@const relays = [
...(data.relays || []),
...Array.from(ctx.app.router.FromPubkey(data.pubkey).getUrls()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array.from shouldn't be necessary any more

]}
{#if data.kind === 31923}
<EventDetail {address} relays={data.relays} />
<EventDetail {address} {relays} />
{:else}
<NoteDetail {address} relays={data.relays} />
<NoteDetail {address} {relays} />
{/if}
{:else if type === "nprofile"}
<PersonDetail pubkey={data.pubkey} {relays} />
Expand Down
5 changes: 5 additions & 0 deletions src/engine/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
HANDLER_RECOMMENDATION,
DEPRECATED_DIRECT_MESSAGE,
FEEDS,
Address,
} from "@welshman/util"
import {Tracker} from "@welshman/net"
import {deriveEvents} from "@welshman/store"
Expand Down Expand Up @@ -114,6 +115,10 @@ export const deriveEvent = (idOrAddress: string, request: Partial<MySubscribeReq
deriveEvents(repository, {filters, includeDeleted: true}),
(events: TrustedEvent[]) => {
if (!attempted && events.length === 0) {
if (Address.isAddress(idOrAddress) && !request.relays) {
const {pubkey, relays} = Address.from(idOrAddress)
request.relays = uniq([...relays, ...ctx.app.router.ForPubkey(pubkey).getUrls()])
}
loadEvent(idOrAddress, request)
attempted = true
}
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载