Changeset 1a2d8ac in Klonkt


Ignore:
Timestamp:
07/24/2026 05:36:42 PM (7 weeks ago)
Author:
Robin Genis <roboburr@…>
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)
Message:

Offers-queue draagt de daemon-hulpvelden (accept-knop in de apps)

De Shaer-clients renderen hun accepteer-knop uit de shaer:-hulpvelden die
de test-daemon op elk offer-item zet (shaer:ward, candidate, needsMyAccept,
iAmCandidate, ...). Klonkt's offers-queue gaf een kale AS2-Offer, waardoor
de parser lege velden zag en de knop nooit verscheen. Nu draagt elk item
beide vormen: de AS2 Relationship én de hulpvelden. Klonkts flow is
één-fase (de Accept van de ward maakt het meteen echt), dus needsMyAccept
geldt de ward-kant en readyToCommit blijft false.

Changed files:
src/services/guardianship/queues.js

  • offersCollection: shaer:ward/candidate/existingGuardians/acceptedBy/ needsMyAccept/readyToCommit/iAmCandidate per item

test/guardianship.test.js

  • pint de hulpvelden op de kid-queue

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/services/guardianship/queues.js

    re84ce32 r1a2d8ac  
    1616});
    1717
    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. */
    1922export 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  });
    3349  return collection(id, items);
    3450}
  • test/guardianship.test.js

    re84ce32 r1a2d8ac  
    7777  assert.equal(G.listOffers('kid').length, 1);
    7878
     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
    7988  // The kid accepts over C2S; the answer travels to the guardian.
    8089  const r = await G.handleGuardianshipOutbox(kid, { type: 'Accept', object: offerId });
Note: See TracChangeset for help on using the changeset viewer.