Changeset 28267519 in Klonkt for src/routes
- Timestamp:
- 07/25/2026 07:43:37 AM (7 weeks ago)
- Branches:
- main
- Children:
- 5c373b8
- Parents:
- 05665bc
- File:
-
- 1 edited
-
src/routes/guardian2.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/guardian2.js
r05665bc r28267519 86 86 if (!site) return res.status(404).json({ error: 'no_site' }); 87 87 res.json(dashboardState(site, resolveLang(req))); 88 }); 89 90 // ── Meekijken (FEP-633c §5, interop-hoofdroute): a committed guardian FOLLOWS 91 // its wards, so their posts (incl. followers-only) are DELIVERED to the 92 // guardian's inbox → timeline. The follow is the mechanism; no new fetch. 93 // First contact also backfills the ward's recent PUBLIC posts as a cold 94 // start so the corner is not empty before delivery catches up. 95 function ensureWardConnections(site) { 96 let wards; 97 try { wards = Guardianship.listWards(site.slug); } catch { return; } 98 for (const w of wards) { 99 const already = db.prepare('SELECT 1 FROM ap_following WHERE slug = ? AND actor_uri = ?') 100 .get(site.slug, w.other_uri); 101 if (already) continue; 102 // Follow (guardian's server auto-accepts today; §5.3 gating is a later fase). 103 AP.followActor(site, w.other_uri).catch(() => { /* retried by the queue */ }); 104 // Cold start: pull recent public posts now so oma sees something at once. 105 AP.backfillFromOutbox(site.slug, w.other_uri).catch(() => { /* best-effort */ }); 106 } 107 } 108 109 // ── The wards' corner: your wards' posts, read-only. No reply, no share; a 110 // guardian watches, it does not publish (Robins besluit). 111 router.get('/api/feed', requireAuth, (req, res) => { 112 const site = siteForUser(req); 113 if (!site) return res.status(404).json({ error: 'no_site' }); 114 ensureWardConnections(site); 115 const wardUris = new Set(Guardianship.listWards(site.slug).map((w) => w.other_uri)); 116 // Only show the wards you actually guard (the timeline can hold more). 117 const items = AP.getTimeline(site.slug, 60, 0) 118 .filter((p) => wardUris.has(p.author_uri)) 119 .map((p) => ({ 120 id: p.id, 121 author: p.author_handle || p.author_name || p.author_uri, 122 authorName: p.author_name, 123 authorIcon: p.author_icon, 124 content: p.content, 125 url: p.url, 126 published: p.published || p.created_at, 127 cw: p.cw || null, 128 media: p.media_json ? JSON.parse(p.media_json) : [], 129 })); 130 res.json({ items, following: wardUris.size }); 88 131 }); 89 132
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)