Changeset f3a2556 in Klonkt for src/routes/guardian.js
- Timestamp:
- 08/08/2026 06:35:21 AM (5 weeks ago)
- Branches:
- main
- Children:
- 2bfe26c
- Parents:
- cf5073b
- git-author:
- Robin <roboburr@…> (08/08/2026 06:35:19 AM)
- git-committer:
- roboburr <roboburr@…> (08/08/2026 06:35:21 AM)
- File:
-
- 1 edited
-
src/routes/guardian.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/guardian.js
rcf5073b rf3a2556 123 123 embeds: wardEmbedSetting(w.other_uri), 124 124 playback: wardPlaybackSetting(w.other_uri), 125 guardians: wardGuardianStatuses(w.other_uri),125 guardians: Guardianship.queues.wardGuardianStatuses(w.other_uri), 126 126 // What THIS guardian proposed for this ward and how it stands (5.6): 127 127 // open, accepted, rejected, or expired when the window ran out and the … … 135 135 // de drempel (shaer-ahy.1). Losse knoppen lieten een guardian zelf 136 136 // uitzoeken wat er allemaal geldt; wat niet verstelbaar is stond nergens. 137 gates: wardGates(site.slug, w.other_uri),137 gates: Guardianship.queues.wardGates(site.slug, w.other_uri), 138 138 })), 139 139 offers: Guardianship.offersCollection(`${me}/queues/offers`, site.slug, me).orderedItems, … … 155 155 } 156 156 157 /** The guardians of a ward WE host, with availability (3.6.1: owner-only in158 * spirit; the co-guardians are among the owners of the relationship). Null159 * for a remote ward: its server tracks availability, not us. */160 function wardGuardianStatuses(wardUri) {161 const base = (process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, '');162 if (!base || !String(wardUri || '').startsWith(`${base}/`)) return null;163 const slug = String(wardUri).trim().replace(/\/+$/, '').split('/').pop();164 try {165 const uris = Guardianship.listGuardians(slug).map((g) => ({ uri: g.other_uri, handle: g.other_handle }));166 const st = Object.fromEntries(167 Guardianship.availability.statusesFor(slug, uris.map((u) => u.uri), Date.now()).map((s) => [s.id, s]),168 );169 return uris.map((u) => ({170 uri: u.uri,171 handle: u.handle,172 availability: (st[u.uri] || {})['shaer:availability'] || 'active',173 awayUntil: (st[u.uri] || {})['shaer:awayUntil'] || null,174 lapse: (st[u.uri] || {})['shaer:lapse'] || null,175 }));176 } catch { return null; }177 }178 157 179 158 // ── The PWA page ───────────────────────────────────────────────────────── … … 578 557 return res.status(403).json({ error: 'not_my_ward' }); 579 558 } 580 const local = wardGuardianStatuses(uri);559 const local = Guardianship.queues.wardGuardianStatuses(uri); 581 560 if (local) return res.json({ local: true, guardians: local }); 582 561 const doc = await AP.fetchActor(uri).catch(() => null); … … 613 592 /** The playback gate of a ward we host (5.6): the heavier sibling. */ 614 593 function wardPlaybackSetting(uri) { return wardGateSetting(uri, 'external_playback'); } 615 /**616 * De gate-rijen van een ward voor het paneel.617 *618 * De standen komen uit onze eigen kolommen als we het kind hosten; bij een ward619 * elders weten we ze niet en blijft het NULL -- onbekend, niet uit. Het aantal620 * guardians idem: dat wordt op de server van die ward bijgehouden, en zonder dat621 * getal wordt er geen drempel verzonnen.622 */623 function wardGates(mySlug, wardUri) {624 const statuses = wardGuardianStatuses(wardUri);625 const wachtend = Guardianship.follows.listReviewsByDirection(mySlug, 'incoming')626 .filter((r) => r.ward_uri === wardUri).length;627 return Guardianship.gated.gateRows({628 // Uit de BESLUITEN, niet uit onze eigen kolom. Er zijn geen lokale accounts:629 // elke ward woont elders, dus wardEmbedSetting() gaf voor iedere ward null en630 // stond er in het paneel overal "onbekend". Wat een guardian wel heeft is de631 // uitslag van wat hij voorstelde.632 settings: Object.fromEntries(Guardianship.gated.GATE_CATALOGUE633 .filter((g) => g.available !== false && Guardianship.gated.featureColumn(g.feature))634 .map((g) => [g.feature, Guardianship.gated.knownSetting(mySlug, wardUri, g.feature)])),635 guardianCount: statuses ? statuses.length : null,636 proposals: Guardianship.gated.listSent(mySlug, wardUri).map((p) => ({637 feature: p.feature, value: !!p.value, status: Guardianship.gated.sentStatus(p, Date.now()),638 })),639 waiting: { 'shaer:follows': wachtend || undefined },640 });641 }642 594 643 595 function wardGateSetting(uri, column) {
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)