fix(mesh): resolve ContentRef peer via DID + name-match fallback
Mesh peer pubkeys (LoRa advert ed25519) differ from federation node pubkeys (archipelago identity), so matching on pubkey always missed and attachments >160B had no transport. Match on master DID instead; also accept an explicit peer_onion override from the frontend, which resolves the peer by display name against federation.list-nodes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -382,13 +382,13 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function sendContent(contactId: number, cid: string, caption?: string) {
|
||||
async function sendContent(contactId: number, cid: string, caption?: string, peerOnion?: string) {
|
||||
try {
|
||||
sending.value = true
|
||||
error.value = null
|
||||
const res = await rpcClient.call<{ sent: boolean; message_id: number; cid: string; size: number }>({
|
||||
method: 'mesh.send-content',
|
||||
params: { contact_id: contactId, cid, caption },
|
||||
params: { contact_id: contactId, cid, caption, peer_onion: peerOnion },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
return res
|
||||
|
||||
@@ -639,7 +639,31 @@ async function handleAttachFile(ev: Event) {
|
||||
return
|
||||
}
|
||||
const { cid } = (await up.json()) as { cid: string }
|
||||
await mesh.sendContent(activeChatPeer.value.contact_id, cid, messageText.value.trim() || undefined)
|
||||
// Resolve the federation onion for this mesh peer. Meshcore adverts
|
||||
// don't carry an archipelago DID so the backend can't link them on its
|
||||
// own — we match on name (both sides use the node's display name).
|
||||
// Falls back to undefined; the backend will try its own DID lookup or
|
||||
// error out if no federation path exists.
|
||||
let peerOnion: string | undefined
|
||||
try {
|
||||
const fed = await rpcClient.federationListNodes()
|
||||
const peerName = activeChatPeer.value.advert_name
|
||||
const hit = fed.nodes.find(
|
||||
(n: { name?: string; onion?: string }) =>
|
||||
(n.name ?? '').toLowerCase() === peerName.toLowerCase() ||
|
||||
(n.name ?? '').toLowerCase().includes(peerName.toLowerCase()) ||
|
||||
peerName.toLowerCase().includes((n.name ?? '').toLowerCase()),
|
||||
)
|
||||
peerOnion = hit?.onion ?? undefined
|
||||
} catch {
|
||||
/* non-fatal — backend will try its own lookup */
|
||||
}
|
||||
await mesh.sendContent(
|
||||
activeChatPeer.value.contact_id,
|
||||
cid,
|
||||
messageText.value.trim() || undefined,
|
||||
peerOnion,
|
||||
)
|
||||
messageText.value = ''
|
||||
nextTick(() => scrollChatToBottom())
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user