Changeset f1a23b8 in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 07/18/2026 12:53:15 AM (8 weeks ago)
- Branches:
- main
- Children:
- 05cd954
- Parents:
- 7d19465
- git-author:
- Robin <roboburr@…> (07/18/2026 12:52:51 AM)
- git-committer:
- Robin <roboburr@…> (07/18/2026 12:53:15 AM)
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r7d19465 rf1a23b8 469 469 } catch { return 0; } 470 470 } 471 // The seen-watermark itself (ms epoch, 0 = never marked) — the Messages page reads it 472 // BEFORE marking seen, so it can render unread dots on the items newer than last visit. 473 export function notificationsSeenAt(slug) { 474 try { 475 const row = db.prepare('SELECT value FROM app_settings WHERE key = ?').get(`fedi_notif_seen:${slug}`); 476 return row ? (Date.parse(row.value) || 0) : 0; 477 } catch { return 0; } 478 } 479 480 // Messages = the unified inbox (Reacties + Meldingen merged, decision Robin+Bart 2026-07-16): 481 // every notification PLUS your own outbound replies ('sent', with edit/delete via their 482 // outboxId), sorted as one stream. Consecutive likes/boosts on the same post collapse into 483 // one grouped item (actors list + count) so activity doesn't drown out conversations. 484 export function getMessages(slug, limit) { 485 const items = getNotifications(slug, Math.max(120, (limit || 60))); 486 try { 487 for (const m of listOutbox(slug).slice(0, 80)) { 488 items.push({ 489 type: 'sent', outboxId: m.id, to_handle: m.to_handle, in_reply_to: m.in_reply_to, 490 content: m.content, editable: m.editable, created_at: m.created_at, 491 }); 492 } 493 } catch { /* ignore */ } 494 items.sort((a, b) => _msgTs(b) - _msgTs(a)); // NaN-safe (zie getNotifications) 495 const out = []; 496 for (const it of items) { 497 const prev = out[out.length - 1]; 498 if ((it.type === 'like' || it.type === 'announce') && prev && prev.type === it.type 499 && prev.post_slug === it.post_slug) { 500 prev.actors = prev.actors || [prev.name || prev.handle || '?']; 501 prev.actors.push(it.name || it.handle || '?'); 502 prev.count = (prev.count || 1) + 1; 503 continue; 504 } 505 out.push(it); 506 } 507 return out.slice(0, limit || 60); 508 } 471 509 472 510 export function buildCreate(base, site, post) { … … 2405 2443 try { 2406 2444 const rows = db.prepare(` 2407 SELECT i.kind, i.actor_name, i.actor_handle, i.actor_url, i. content, i.created_at,2445 SELECT i.kind, i.actor_name, i.actor_handle, i.actor_url, i.actor_icon, i.content, i.created_at, i.visibility, 2408 2446 p.slug AS post_slug, p.title AS post_title 2409 2447 FROM ap_interactions i LEFT JOIN posts p ON p.id = i.post_id … … 2412 2450 `).all(slug); 2413 2451 for (const r of rows) out.push({ 2414 type: r.kind, name: r.actor_name, handle: r.actor_handle, url: r.actor_url, 2452 type: r.kind, name: r.actor_name, handle: r.actor_handle, url: r.actor_url, icon: r.actor_icon, 2415 2453 content: stripLeadingMentions(r.content), post_slug: r.post_slug, post_title: r.post_title, created_at: r.created_at, 2454 // followers/direct = a private message to the owner (not on the public thread) → 🔒 in Messages 2455 visibility: r.visibility || 'public', 2416 2456 }); 2417 2457 } catch { /* ignore */ } … … 2426 2466 } 2427 2467 } catch { /* ignore */ } 2428 out.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); 2468 // NaN-safe sort: one row with a missing/garbled created_at would otherwise make the 2469 // comparator return NaN and scramble the WHOLE ordering (seen live: follow rows landing 2470 // between likes, which also broke Messages' like-grouping). 2471 out.sort((a, b) => _msgTs(b) - _msgTs(a)); 2429 2472 return out.slice(0, limit || 60); 2430 2473 } 2474 function _msgTs(x) { const t = Date.parse((x && x.created_at) || ''); return Number.isFinite(t) ? t : 0; } 2431 2475 2432 2476 // ── Blocking / defederation ─────────────────────────────────────── … … 2607 2651 linkifyBody, bakePostContent, bakePostContentWithMentions, listFollowers, removeFollower, listConnections, 2608 2652 noteVisibility, isRejectedObject, rejectInteraction, interactionReportTarget, 2653 getMessages, notificationsSeenAt, 2609 2654 };
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)