Changeset 780a7c6 in Klonkt for src/routes/guardian.js
- Timestamp:
- 07/24/2026 07:44:15 PM (7 weeks ago)
- Branches:
- main
- Children:
- b5924eb
- Parents:
- c26cc18
- File:
-
- 1 edited
-
src/routes/guardian.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/guardian.js
rc26cc18 r780a7c6 32 32 function uiStrings(L) { 33 33 const keys = ['sent', 'sent_retry', 'sending', 'not_found', 'failed', 'network', 34 'pending', 'active', 'retract', 'release', 'open', 'push_unavailable']; 34 'pending', 'active', 'retract', 'release', 'open', 'push_unavailable', 35 'accept', 'reject', 'complete', 'awaiting_others', 'coguard']; 35 36 return Object.fromEntries(keys.map((k) => [k, i18nT(L, `guardian.${k}`)])); 36 37 } 37 38 38 39 function dashboardState(site, L) { 39 const wards = Guardianship.listWards(site.slug); 40 const base = (process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, ''); 41 const me = AP.actorId(base, site.slug); 40 42 const help = db.prepare( 41 43 `SELECT object_uri, note_url, actor_uri, actor_name, actor_handle, actor_icon, content, published, created_at … … 44 46 return { 45 47 site: site.slug, 46 wards: wards.filter((w) => w.status === 'accepted'), 47 pendingOffers: wards.filter((w) => w.status === 'offered'), 48 me, 49 wards: Guardianship.listWards(site.slug), // committed wards 50 offers: Guardianship.offersCollection(`${me}/queues/offers`, site.slug, me).orderedItems, 48 51 help, 49 52 strings: uiStrings(L), … … 94 97 }); 95 98 96 // ── Manage: retract a pending offer / release a ward ───────────────────── 99 // ── Answer an offer (co-guardian accept/reject, or the candidate's final 100 // "complete"). All three are a C2S Accept/Reject on the offer id; the 101 // handshake module decides when it commits (§3.1). 102 router.post('/offer', requireAuth, express.json({ limit: '4kb' }), async (req, res) => { 103 const site = siteForUser(req); 104 if (!site) return res.status(404).json({ error: 'no_site' }); 105 const offerId = String(req.body?.offer || '').trim(); 106 const answer = req.body?.answer === 'reject' ? 'Reject' : 'Accept'; 107 if (!offerId) return res.status(400).json({ error: 'empty_offer' }); 108 const r = await AP.ingestOutboxActivity(site, req.session.user, { type: answer, object: offerId }); 109 if (!r || r.status >= 400) return res.status(r?.status || 500).json({ error: r?.error || 'answer_failed' }); 110 res.json({ ok: true, committed: !!r.committed, readyToCommit: !!r.readyToCommit }); 111 }); 112 113 // ── Manage: release a committed ward (local Undo; federation is Fase 4). ── 97 114 router.post('/wards/remove', requireAuth, express.json({ limit: '4kb' }), (req, res) => { 98 115 const site = siteForUser(req);
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)