Changeset c26cc18 in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 07/24/2026 06:04:03 PM (7 weeks ago)
- Branches:
- main
- Children:
- 780a7c6
- Parents:
- 1a2d8ac
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r1a2d8ac rc26cc18 3129 3129 return actorId(base, slug); 3130 3130 } 3131 // Deliver one activity to one actor's inbox, signed; queued on failure. 3131 // Deliver one activity to one actor's inbox, signed; queued + retried on any 3132 // hiccup so a slow or briefly-down ward server never loses the offer. Returns 3133 // { delivered, inbox }: delivered=false means the account could not be 3134 // resolved at all (a bad handle) — the offer stays recorded regardless. 3132 3135 async function deliverToActor(site, actorUri, activity) { 3133 const a = await fetchActor(actorUri).catch(() => null);3134 const inbox = a && (a.inbox || (a.endpoints && a.endpoints.sharedInbox));3135 if (!inbox) return false;3136 3136 const me = selfActorId(site.slug); 3137 3137 const keys = getOrCreateKeys(site.slug); 3138 3138 const payload = { '@context': AP_CONTEXT, ...activity }; 3139 const a = await fetchActor(actorUri).catch(() => null); 3140 const inbox = a && (a.inbox || (a.endpoints && a.endpoints.sharedInbox)); 3141 if (!inbox) { 3142 console.warn('[AP] guardianship: could not resolve an inbox for', actorUri, '(offer recorded, not sent)'); 3143 return { delivered: false, inbox: null }; 3144 } 3139 3145 try { 3140 3146 const st = await deliver(inbox, payload, `${me}#main-key`, keys.private_pem); 3141 if (st >= 200 && st < 300) return true; 3142 } catch { /* fall through to the queue */ } 3147 if (st >= 200 && st < 300) { console.log('[AP] guardianship', activity.type, 'delivered →', inbox, st); return { delivered: true, inbox }; } 3148 console.warn('[AP] guardianship', activity.type, 'got', st, 'from', inbox, '→ queued for retry'); 3149 } catch (e) { console.warn('[AP] guardianship', activity.type, 'to', inbox, 'failed:', e.message, '→ queued for retry'); } 3143 3150 enqueueDelivery(site.slug, inbox, payload); 3144 return true; // queued: it will arrive3151 return { delivered: true, inbox }; // queued: the retry worker gets it there 3145 3152 } 3146 3153 Guardianship.wireDelivery({
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)