Changeset 7e66e7e in Klonkt
- Timestamp:
- 06/27/2026 12:04:44 AM (2 months ago)
- Branches:
- main
- Children:
- ace5a9b
- Parents:
- 0a75356
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r0a75356 r7e66e7e 414 414 } 415 415 416 // Drop the leading @mention(s) a federated reply carries (the person being replied to), 417 // so a comment reads "dope tekening ouwe" instead of "@jason@jasonhacky.nl dope …". 418 // Keeps a leading <p> wrapper; handles mention <a> links and plain-text @user@domain. 419 export function stripLeadingMentions(html) { 420 if (!html) return html; 421 let s = String(html); 422 s = s.replace(/^(\s*<p[^>]*>)?\s*(?:<a\b[^>]*>\s*@[^<]+<\/a>[ ]*)+/i, (m, p) => p || ''); 423 s = s.replace(/^(\s*<p[^>]*>)?\s*(?:@[\w.-]+(?:@[\w.-]+)?[ ]+)+/i, (m, p) => p || ''); 424 return s; 425 } 426 416 427 // View-ready threaded view of a post's fediverse activity (inbound replies + 417 428 // our outbound replies, nested), plus like/boost counts. … … 434 445 noteId: r.object_uri, parent: r.parent_uri || null, mine: false, id: r.id, 435 446 actor_name: r.actor_name, actor_handle: r.actor_handle, actor_url: r.actor_url, 436 actor_icon: r.actor_icon, content: r.content, created_at: r.published || r.created_at,447 actor_icon: r.actor_icon, content: stripLeadingMentions(r.content), created_at: r.published || r.created_at, 437 448 acted_boost: !!r.acted_boost, acted_like: !!r.acted_like, 438 449 children: [], … … 442 453 nodes.push({ 443 454 noteId: baseClean ? `${baseClean}/ap/notes/${o.id}` : o.id, parent: o.in_reply_to || null, 444 mine: true, outboxId: o.id, content: o.content, created_at: o.created_at,455 mine: true, outboxId: o.id, content: stripLeadingMentions(o.content), created_at: o.created_at, 445 456 actor_name: siteName, actor_handle: siteHandle, actor_url: siteUrl, actor_icon: siteIcon, 446 457 children: [], … … 998 1009 // List a site's own outbound fediverse replies (for the manage/delete view). 999 1010 export function listOutbox(siteSlug) { 1000 return db.prepare('SELECT id, content, to_handle, in_reply_to, created_at FROM ap_outbox WHERE site_slug = ? ORDER BY created_at DESC').all(siteSlug); 1011 return db.prepare('SELECT id, content, to_handle, in_reply_to, created_at FROM ap_outbox WHERE site_slug = ? ORDER BY created_at DESC') 1012 .all(siteSlug).map((r) => ({ ...r, content: stripLeadingMentions(r.content) })); 1001 1013 } 1002 1014 … … 1291 1303 for (const r of rows) out.push({ 1292 1304 type: r.kind, name: r.actor_name, handle: r.actor_handle, url: r.actor_url, 1293 content: r.content, post_slug: r.post_slug, post_title: r.post_title, created_at: r.created_at,1305 content: stripLeadingMentions(r.content), post_slug: r.post_slug, post_title: r.post_title, created_at: r.created_at, 1294 1306 }); 1295 1307 } catch { /* ignore */ }
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)