Changeset d9ad6c5 in Klonkt for src/routes
- Timestamp:
- 07/28/2026 06:17:36 PM (6 weeks ago)
- Branches:
- main
- Children:
- a7bcf66
- Parents:
- 2708282
- Location:
- src/routes
- Files:
-
- 2 edited
-
guardian.js (modified) (2 diffs)
-
posts.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/guardian.js
r2708282 rd9ad6c5 19 19 import * as Guardianship from '../services/guardianship/index.js'; 20 20 import { t as i18nT, resolveLang } from '../services/i18n.js'; 21 import { injectCspNonce } from '../middleware/render.js'; 21 import { injectCspNonce, renderNoteBody } from '../middleware/render.js'; 22 import { emojiName } from '../services/NoteRender.js'; 22 23 23 24 const router = express.Router(); … … 51 52 const me = AP.actorId(base, site.slug); 52 53 const help = db.prepare( 53 `SELECT object_uri, note_url, actor_uri, actor_name, actor_handle, actor_icon, content, published, created_at 54 `SELECT object_uri, note_url, actor_uri, actor_name, actor_handle, actor_icon, content, published, created_at, 55 emoji_json, actor_emoji_json, media_json, quote_json, embed_json 54 56 FROM ap_mentions WHERE slug = ? AND help_request = 1 ORDER BY created_at DESC LIMIT 50` 55 ).all(site.slug); 57 ).all(site.slug).map((h) => ({ 58 ...h, 59 // The dashboard is built in the browser, so it gets the body finished: the 60 // same partial de Krant and Berichten use. A 🛟 often carries a screenshot 61 // and a link to the post it is about; both belong in the card. 62 body_html: renderNoteBody(h, L), 63 name_html: emojiName(h.actor_name || '', h.actor_emoji_json), 64 })); 56 65 return { 57 66 site: site.slug, -
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)