Changeset 6d5ce0c in Klonkt for src/services/guardianship
- Timestamp:
- 07/29/2026 10:50:32 AM (6 weeks ago)
- Branches:
- main
- Children:
- 08ab8ad
- Parents:
- c8e03c6
- Location:
- src/services/guardianship
- Files:
-
- 2 edited
-
delivery.js (modified) (3 diffs)
-
handshake.js (modified) (1 diff)
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; } -
src/services/guardianship/handshake.js
rc8e03c6 r6d5ce0c 219 219 const lp = availability.parseLapse(activity.object); 220 220 if (lp) { 221 // ONE path (Robins regel, 29-7): the ward's server opens, tallies and 222 // enforces, wherever it lives. A local ward is reached by the same 223 // deliverTo, which loops back into the inbox handler; co-location is a 224 // transport detail and never a shortcut past the decision. 221 225 const id = `${me}/lapses/${Date.now().toString(36)}${Math.floor(Math.random() * 1e4).toString(36)}`; 222 const wardSlug = deps.localSlug(lp.ward);223 if (wardSlug) {224 const r = availability.openLapse({ id, wardSlug, wardUri: lp.ward, target: lp.target, openedBy: me, now: Date.now() });225 if (r.error) return { status: r.error === 'not_in_available_set' ? 403 : 409, error: r.error };226 deps.deliverTo(site, lp.target, { id, type: 'Offer', actor: me, to: [lp.target], object: { type: 'shaer:Lapse', 'shaer:ward': lp.ward, object: lp.target } }).catch(() => { /* best-effort */ });227 notify(wardSlug, { kind: 'lapse_opened', lapse: id, target: lp.target, set: r.set });228 return { status: 202, id, url: id, 'shaer:set': r.set, 'shaer:threshold': r.threshold };229 }230 226 const offer = { id, type: 'Offer', actor: me, to: [lp.ward], object: { type: 'shaer:Lapse', 'shaer:ward': lp.ward, object: lp.target } }; 231 227 const delivered = await fanout(site, [lp.ward], offer);
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)