Changeset 2b4252c in Klonkt for src/routes/guardian2.js
- Timestamp:
- 07/25/2026 09:15:34 AM (7 weeks ago)
- Branches:
- main
- Children:
- 4f15f67
- Parents:
- af5b79b
- File:
-
- 1 edited
-
src/routes/guardian2.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/guardian2.js
raf5b79b r2b4252c 148 148 if (!site) return res.status(404).json({ error: 'no_site' }); 149 149 const items = []; 150 // Local wards (guardian co-located): read the pending follows directly. 150 151 for (const wardSlug of wardSlugsOf(site)) { 151 152 for (const f of Guardianship.follows.listForWard(wardSlug)) { 152 items.push({ id: f.id, ward: wardSlug, follower: f.follower_handle || f.follower_name || f.follower_uri, followerIcon: f.follower_icon, created: f.created_at });153 items.push({ id: f.id, ward: wardSlug, follower: f.follower_handle || f.follower_name || f.follower_uri, followerIcon: f.follower_icon, remote: false, created: f.created_at }); 153 154 } 155 } 156 // Remote wards: the copies forwarded here as Offer(Follow) (cross-instance). 157 for (const rev of Guardianship.follows.listReviews(site.slug)) { 158 const wardName = (() => { try { const u = new URL(rev.ward_uri); return `@${u.pathname.split('/').pop()}@${u.host}`; } catch { return rev.ward_uri; } })(); 159 items.push({ id: rev.id, ward: wardName, follower: rev.follower_handle || rev.follower_uri, followerIcon: rev.follower_icon, remote: true, created: rev.created_at }); 154 160 } 155 161 res.json({ items }); … … 162 168 const me = AP.actorId(base, site.slug); 163 169 const decision = req.body?.decision === 'reject' ? 'reject' : 'approve'; 170 171 // Remote ward: a forwarded copy. Send my Accept/Reject back to the ward, 172 // which tallies quorum and returns the Accept(Follow) to the follower. 173 const review = Guardianship.follows.getReview(site.slug, req.params.id); 174 if (review) { 175 try { await AP.sendFollowDecision(site, review, decision); } 176 catch { return res.status(502).json({ error: 'delivery' }); } 177 Guardianship.follows.removeReview(site.slug, req.params.id); 178 return res.json({ ok: true, outcome: decision === 'reject' ? 'rejected' : 'sent' }); 179 } 180 181 // Local ward: decide directly (quorum on this instance). 164 182 const pending = Guardianship.follows.getPending(req.params.id); 165 183 if (!pending) return res.status(404).json({ error: 'gone' }); 166 // I must actually be a guardian of this ward.167 184 const guardians = Guardianship.listGuardians(pending.ward_slug).map((g) => g.other_uri); 168 185 if (!guardians.includes(me)) return res.status(403).json({ error: 'not_a_guardian' });
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)