Changeset 88d7c8f in Klonkt for src/routes/guardian.js
- Timestamp:
- 07/29/2026 07:15:16 AM (6 weeks ago)
- Branches:
- main
- Children:
- e27b8db
- Parents:
- 439f095
- File:
-
- 1 edited
-
src/routes/guardian.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/guardian.js
r439f095 r88d7c8f 52 52 'avail_available', 'avail_away', 'avail_dormant', 'panel_guards', 'panel_guards_remote', 53 53 'lapse_propose', 'lapse_line', 'lapse_tally', 'lapse_note', 'lapse_agree', 'lapse_disagree', 'voted', 54 'away_title', 'away_sub', 'away_week', 'away_month', 'away_done']; 54 'away_title', 'away_sub', 'away_week', 'away_month', 'away_done', 55 // A gated-setting proposal from a fellow guardian (5.6). 56 'gated_title', 'gated_line_on', 'gated_line_off', 'gated_agree', 'gated_disagree']; 55 57 const s = Object.fromEntries(keys.map((k) => [k, i18nT(L, `guardian.${k}`)])); 56 58 s.wave = i18nT(L, 'guardian.wave'); … … 93 95 // Running lapses (3.6.3) this guardian or its local wards are party to. 94 96 lapses: Guardianship.availability.lapseQueueItems(site.slug, me, Date.now()), 97 // Gated-setting proposals another guardian opened on a ward we share 98 // (5.6), forwarded here by the ward's server. Without answering these the 99 // threshold is never met and the proposal simply expires. 100 gatedReviews: Guardianship.gated.listGatedReviews(site.slug).map((r) => ({ 101 id: r.id, ward: r.ward_uri, proposer: r.proposer, feature: r.feature, value: !!r.value, 102 })), 95 103 help, 96 104 strings: uiStrings(L), … … 345 353 if (!r || r.status >= 400) return res.status(r?.status || 500).json({ error: r?.error || 'lapse_failed' }); 346 354 res.json({ ok: true, lapse: r.id }); 355 }); 356 357 // ── Answer a forwarded gated-setting proposal (FEP-633c 5.6) ───────────── 358 // The decision belongs to the ward's server, so the answer travels there as an 359 // Accept/Reject on the offer id, exactly like a gated follow's decision. 360 router.post('/api/gated/:id', requireAuth, express.json({ limit: '2kb' }), async (req, res) => { 361 const site = siteForUser(req); 362 if (!site) return res.status(404).json({ error: 'no_site' }); 363 const review = Guardianship.gated.getGatedReview(site.slug, req.params.id); 364 if (!review) return res.status(404).json({ error: 'gone' }); 365 const agree = req.body?.answer !== 'reject'; 366 const base = (process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, ''); 367 const me = AP.actorId(base, site.slug); 368 const activity = { 369 id: `${me}#gated-${Date.now().toString(36)}`, 370 type: agree ? 'Accept' : 'Reject', actor: me, to: [review.ward_uri], object: review.id, 371 }; 372 try { await AP.deliverToActor(site, review.ward_uri, activity); } 373 catch { return res.status(502).json({ error: 'delivery' }); } 374 Guardianship.gated.removeGatedReview(site.slug, review.id); 375 res.json({ ok: true, answer: agree ? 'accept' : 'reject' }); 347 376 }); 348 377
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)