Changeset 1a2d8ac in Klonkt
- Timestamp:
- 07/24/2026 05:36:42 PM (7 weeks ago)
- Branches:
- main
- Children:
- c26cc18
- Parents:
- e84ce32
- git-author:
- Robin Genis <roboburr@…> (07/24/2026 05:36:30 PM)
- git-committer:
- Robin Genis <roboburr@…> (07/24/2026 05:36:42 PM)
- Files:
-
- 2 edited
-
src/services/guardianship/queues.js (modified) (1 diff)
-
test/guardianship.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/services/guardianship/queues.js
re84ce32 r1a2d8ac 16 16 }); 17 17 18 /** Pending offers, reconstructed as Offer activities (either side). */ 18 /** Pending offers, reconstructed as Offer activities (either side). Each item 19 * also carries the daemon-contract helper fields (shaer:ward, candidate, 20 * needsMyAccept, iAmCandidate, …): the Shaer clients render their accept 21 * button from those, so the shapes must match the test daemon exactly. */ 19 22 export function offersCollection(id, slug, me) { 20 const items = relations.listOffers(slug).map((r) => ({ 21 id: r.offer_id || undefined, 22 type: 'Offer', 23 actor: r.role === 'guardian' ? me : r.other_uri, 24 object: { 25 type: 'Relationship', 26 subject: r.role === 'guardian' ? r.other_uri : me, 27 relationship: GUARDIAN_RELATIONSHIP_COMPACT, 28 object: r.role === 'guardian' ? me : r.other_uri, 29 }, 30 'shaer:handle': r.other_handle || undefined, 31 published: r.created_at, 32 })); 23 const items = relations.listOffers(slug).map((r) => { 24 const ward = r.role === 'guardian' ? r.other_uri : me; 25 const candidate = r.role === 'guardian' ? me : r.other_uri; 26 return { 27 id: r.offer_id || `${me}/offers/pending-${r.id}`, 28 type: 'Offer', 29 actor: candidate, 30 object: { 31 type: 'Relationship', 32 subject: ward, 33 relationship: GUARDIAN_RELATIONSHIP_COMPACT, 34 object: candidate, 35 }, 36 'shaer:ward': ward, 37 'shaer:candidate': candidate, 38 'shaer:existingGuardians': relations.listGuardians(slug).map((g) => g.other_uri), 39 'shaer:acceptedBy': [], 40 // Klonkt's flow is single-phase: the ward's Accept commits at once, so 41 // only the ward-side owner has an action here. 42 'shaer:needsMyAccept': r.role === 'ward', 43 'shaer:readyToCommit': false, 44 'shaer:iAmCandidate': r.role === 'guardian', 45 'shaer:handle': r.other_handle || undefined, 46 published: r.created_at, 47 }; 48 }); 33 49 return collection(id, items); 34 50 } -
test/guardianship.test.js
re84ce32 r1a2d8ac 77 77 assert.equal(G.listOffers('kid').length, 1); 78 78 79 // The kid's offers queue carries the daemon-contract helper fields the 80 // Shaer clients render their accept button from. 81 const kidQ = G.offersCollection(`${KID}/queues/offers`, 'kid', KID); 82 assert.equal(kidQ.totalItems, 1); 83 assert.equal(kidQ.orderedItems[0]['shaer:needsMyAccept'], true); 84 assert.equal(kidQ.orderedItems[0]['shaer:iAmCandidate'], false); 85 assert.equal(kidQ.orderedItems[0]['shaer:ward'], KID); 86 assert.equal(kidQ.orderedItems[0]['shaer:candidate'], ME); 87 79 88 // The kid accepts over C2S; the answer travels to the guardian. 80 89 const r = await G.handleGuardianshipOutbox(kid, { type: 'Accept', object: offerId });
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)