Changeset 6d5ce0c in Klonkt for src/services/guardianship/delivery.js
- Timestamp:
- 07/29/2026 10:50:32 AM (6 weeks ago)
- Branches:
- main
- Children:
- 08ab8ad
- Parents:
- c8e03c6
- File:
-
- 1 edited
-
src/services/guardianship/delivery.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/guardianship/delivery.js
rc8e03c6 r6d5ce0c 41 41 // call-for-help path). 42 42 export async function deliverDirectNote(site, { recipients, text, language, inReplyTo, attachments, helpRequest, wave, awayUntil }) { 43 const { actorId, fetchActor, deriveHandle, escHtml, linkUrls, linkHashtags,43 const { actorId, fetchActor, localActor, deliverTo, deriveHandle, escHtml, linkUrls, linkHashtags, 44 44 getOutboxRow, buildReplyNote, AP_CONTEXT, getOrCreateKeys, deliver, enqueueDelivery } = deps; 45 45 const base = (process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, ''); … … 50 50 const resolved = []; 51 51 for (const uri of list) { 52 const a = await fetchActor(uri).catch(() => null); 52 // An actor we host is read from our own database, not fetched from our own 53 // hostname: that request has to leave the machine and come back, and when 54 // it does not, the recipient is silently dropped from the note. Everything 55 // that decides anything still runs below, for local and remote alike. 56 const a = (localActor && localActor(uri)) || await fetchActor(uri).catch(() => null); 53 57 if (!a || !(a.inbox || (a.endpoints && a.endpoints.sharedInbox))) continue; 54 resolved.push({ uri, inbox: (a.endpoints && a.endpoints.sharedInbox) || a.inbox, handle: deriveHandle(uri), url: a.url || uri });58 resolved.push({ uri, inbox: (a.endpoints && a.endpoints.sharedInbox) || a.inbox, local: !!a.local, handle: deriveHandle(uri), url: a.url || uri }); 55 59 } 56 60 if (!resolved.length) return null; … … 83 87 const keyId = `${me}#main-key`; 84 88 let delivered = 0; 85 for (const inbox of [...new Set(resolved.map((r) => r.inbox))]) { 89 // A recipient on this machine takes the loopback (deliverToActor), which 90 // hands the Create to the same inbox handler an HTTP POST would reach: the 91 // note is stored, the mention is stored, and a shaer:away on it is applied, 92 // all by the code that does it for everyone else. A hairpin POST to our own 93 // hostname is not that code path, it is a second one that only appears to be. 94 for (const r of resolved.filter((x) => x.local)) { 95 const res = await deliverTo(site, r.uri, create).catch(() => null); 96 if (res && res.delivered) delivered++; 97 } 98 // Remote: one POST per inbox, so two guardians on the same server share it. 99 for (const inbox of [...new Set(resolved.filter((x) => !x.local).map((r) => r.inbox))]) { 86 100 let ok = false; 87 101 try { const st = await deliver(inbox, create, keyId, keys.private_pem); ok = st >= 200 && st < 300; } catch { ok = false; }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)