Changeset d9ad6c5 in Klonkt for src/routes/posts.js
- Timestamp:
- 07/28/2026 06:17:36 PM (6 weeks ago)
- Branches:
- main
- Children:
- a7bcf66
- Parents:
- 2708282
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r2708282 rd9ad6c5 920 920 const append = req.query.append === '1'; 921 921 const offset = Math.max(0, parseInt(req.query.offset, 10) || 0); 922 const page = site ? ActivityPubService.getMessages(site.slug, FEED_PAGE + 1, offset) : [];922 const page = gateEmbeds(site, site ? ActivityPubService.getMessages(site.slug, FEED_PAGE + 1, offset) : []); 923 923 const hasMore = page.length > FEED_PAGE; 924 924 const items = page.slice(0, FEED_PAGE); … … 1084 1084 } 1085 1085 1086 /** 1087 * FEP-633c §5.3-style gated feature: may this account see previews of links 1088 * that point OUTSIDE the fediverse? For a ward that is the guardians' call. 1089 * 1090 * Applied at SERVE time on every surface, the way the app's inbox read already 1091 * does it (routes/activitypub.js): a card the client merely hides has still 1092 * been delivered. 1093 */ 1094 function gateEmbeds(site, rows) { 1095 if (!site || !rows.length) return rows; 1096 let isWard = false; 1097 try { isWard = Guardianship.listGuardians(site.slug).length > 0; } catch { /* no relations yet */ } 1098 if (Guardianship.externalEmbedsAllowed(site.external_embeds, isWard)) return rows; 1099 return rows.map((r) => (r && r.embed_json ? { ...r, embed_json: null } : r)); 1100 } 1101 1086 1102 router.get('/news', requireSiteManager, (req, res) => { 1087 1103 const site = res.locals.site; … … 1090 1106 const cspOrigins = new Set(); 1091 1107 // Fetch one extra to know whether a "Load more" button belongs on this page. 1092 const rows = site ? ActivityPubService.getTimeline(site.slug, FEED_PAGE + 1, offset) : [];1108 const rows = gateEmbeds(site, site ? ActivityPubService.getTimeline(site.slug, FEED_PAGE + 1, offset) : []); 1093 1109 const hasMore = rows.length > FEED_PAGE; 1094 1110 const timeline = rows.slice(0, FEED_PAGE).map((p) => {
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)