Changeset 1485933 in Klonkt for src/services
- Timestamp:
- 07/20/2026 07:35:55 AM (7 weeks ago)
- Branches:
- main
- Children:
- 520e477
- Parents:
- 7b04d3b
- git-author:
- Robin <roboburr@…> (07/20/2026 07:18:02 AM)
- git-committer:
- Robin <roboburr@…> (07/20/2026 07:35:55 AM)
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r7b04d3b r1485933 507 507 // outboxId), sorted as one stream. Consecutive likes/boosts on the same post collapse into 508 508 // one grouped item (actors list + count) so activity doesn't drown out conversations. 509 export function getMessages(slug, limit) { 510 const items = getNotifications(slug, Math.max(120, (limit || 60))); 509 export function getMessages(slug, limit, offset) { 510 const off = Math.max(0, offset || 0); 511 const lim = limit || 60; 512 // The stream is grouped (consecutive likes/boosts collapse), so paging is done by 513 // recomputing the whole stream top-down and slicing [off, off+lim] — stable across 514 // pages. Fetch a buffer past off+lim so grouping-shrinkage can't hide a full page. 515 const need = off + lim + 100; 516 const items = getNotifications(slug, need); 511 517 try { 512 for (const m of listOutbox(slug).slice(0, 80)) {518 for (const m of listOutbox(slug).slice(0, need)) { 513 519 items.push({ 514 520 type: 'sent', outboxId: m.id, to_handle: m.to_handle, in_reply_to: m.in_reply_to, … … 530 536 out.push(it); 531 537 } 532 return out.slice( 0, limit || 60);538 return out.slice(off, off + lim); 533 539 } 534 540 … … 2660 2666 // Notifications inbox: new followers + replies/likes/boosts on this site's posts. 2661 2667 export function getNotifications(slug, limit) { 2668 // Per-source cap scales with the requested limit so Messages can page deep 2669 // (Load more). Bounded so a huge offset can't ask for unbounded rows. 2670 const L = Math.min(1000, Math.max(80, limit || 60)); 2662 2671 const out = []; 2663 2672 try { 2664 for (const f of db.prepare('SELECT actor_uri, created_at FROM ap_followers WHERE slug = ? ORDER BY created_at DESC LIMIT 50').all(slug)) {2673 for (const f of db.prepare('SELECT actor_uri, created_at FROM ap_followers WHERE slug = ? ORDER BY created_at DESC LIMIT ?').all(slug, L)) { 2665 2674 out.push({ type: 'follow', handle: deriveHandle(f.actor_uri), url: f.actor_uri, created_at: f.created_at }); 2666 2675 } … … 2672 2681 FROM ap_interactions i LEFT JOIN posts p ON p.id = i.post_id 2673 2682 WHERE p.site_id = (SELECT id FROM sites WHERE slug = ?) 2674 ORDER BY i.created_at DESC LIMIT 802675 `).all(slug );2683 ORDER BY i.created_at DESC LIMIT ? 2684 `).all(slug, L); 2676 2685 for (const r of rows) out.push({ 2677 2686 type: r.kind, name: r.actor_name, handle: r.actor_handle, url: r.actor_url, icon: r.actor_icon, … … 2682 2691 } catch { /* ignore */ } 2683 2692 try { 2684 for (const r of db.prepare('SELECT actor_uri, actor_name, actor_handle, actor_icon, content, created_at FROM ap_reports WHERE slug = ? ORDER BY created_at DESC LIMIT 50').all(slug)) {2693 for (const r of db.prepare('SELECT actor_uri, actor_name, actor_handle, actor_icon, content, created_at FROM ap_reports WHERE slug = ? ORDER BY created_at DESC LIMIT ?').all(slug, L)) { 2685 2694 out.push({ type: 'report', name: r.actor_name, handle: r.actor_handle, url: r.actor_uri, icon: r.actor_icon, content: r.content, created_at: r.created_at }); 2686 2695 } 2687 2696 } catch { /* ignore */ } 2688 2697 try { 2689 for (const r of db.prepare('SELECT object_uri, note_url, actor_uri, actor_name, actor_handle, actor_icon, actor_url, content, created_at FROM ap_mentions WHERE slug = ? ORDER BY created_at DESC LIMIT 50').all(slug)) {2698 for (const r of db.prepare('SELECT object_uri, note_url, actor_uri, actor_name, actor_handle, actor_icon, actor_url, content, created_at FROM ap_mentions WHERE slug = ? ORDER BY created_at DESC LIMIT ?').all(slug, L)) { 2690 2699 out.push({ type: 'mention', name: r.actor_name, handle: r.actor_handle, url: r.actor_url || r.actor_uri, icon: r.actor_icon, content: stripLeadingMentions(r.content), note_url: r.note_url || r.object_uri, created_at: r.created_at }); 2691 2700 }
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)