Changeset f1a23b8 in Klonkt for src/routes/posts.js


Ignore:
Timestamp:
07/18/2026 12:53:15 AM (8 weeks ago)
Author:
Robin <roboburr@…>
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)
Message:

Feature: Messages merges Replies + Notifications into one inbox

/messages replaces /fediverse (manage own replies) and /notifications with a
single stream, per the Robin+Bart decision. getMessages() merges notifications
with your outbound replies ('sent' items, edit/delete via their outbox routes)
and collapses consecutive likes/boosts on the same post into one grouped item.
Design refresh: filter chips (All/Conversations/Activity/Sent, client-side),
avatars with a type-dot overlay, sent items with a direction indicator and
accent border, a lock badge on private replies (visibility now flows through
getNotifications along with actor icons), and unread dots via the existing
seen-watermark (read before marking seen). The two tabs collapse into one
Messages tab carrying the badge; the bookmarklet moved to /messages; old routes
redirect. Also fixes a latent NaN-unsafe date sort in getNotifications that
scrambled ordering when a row had a garbled created_at (seen live). i18n
NL/EN/DE. 4 new tests (67 green); verified in a browser incl. grouping, chips,
private badge, edit/delete forms. Beads: klonkt-demo-pkg. Old
fedi-notifications.ejs and the authorize-interaction manage block are now
unreachable; cleanup tracked in klonkt-demo-bk8.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r7d19465 rf1a23b8  
    722722
    723723// Manage / delete your own outbound fediverse replies (site owner only).
    724 router.get('/fediverse', requireSiteManager, (req, res) => {
    725   const site = res.locals.site;
    726   const items = site ? ActivityPubService.listOutbox(site.slug) : [];
    727   renderPage(req, res, 'pages/authorize-interaction', {
    728     pageTitleKey: 'fedi.manage_title', bodyClass: 'on-special', // i18n: was hardcoded Dutch
    729     manage: items, uri: '', target: null, sent: false, siteTitle: site ? site.title : '',
     724// Messages = Reacties + Meldingen in ONE inbox (your sent replies join the stream).
     725// The old /fediverse (manage) and /notifications pages redirect here.
     726router.get('/messages', requireSiteManager, (req, res) => {
     727  const site = res.locals.site;
     728  const items = site ? ActivityPubService.getMessages(site.slug, 80) : [];
     729  // Read the watermark BEFORE marking seen → unread dots on items newer than last visit.
     730  const seenAt = site ? ActivityPubService.notificationsSeenAt(site.slug) : 0;
     731  if (site && !isViewer(req.session.user)) ActivityPubService.markNotificationsSeen(site.slug);
     732  renderPage(req, res, 'pages/messages', {
     733    pageTitleKey: 'msg.title', bodyClass: 'on-special', items, seenAt,
     734    success: req.query.success || null, error: req.query.error || null,
    730735  });
    731736});
     737router.get('/fediverse', requireSiteManager, (req, res) => res.redirect(`${res.locals.siteUrlBase || ''}/messages`));
    732738
    733739router.post('/fediverse/:id/delete', requireSiteManager, async (req, res) => {
     
    963969
    964970// Notifications inbox (new followers + replies/likes/boosts on your posts).
    965 router.get('/notifications', requireSiteManager, (req, res) => {
    966   const site = res.locals.site;
    967   const items = site ? ActivityPubService.getNotifications(site.slug, 80) : [];
    968   // viewing = seen → clears the bell badge. A viewer (kijker) may look but must not
    969   // mutate state (the global write-guard only catches non-GET, not this GET-side effect).
    970   if (site && !isViewer(req.session.user)) ActivityPubService.markNotificationsSeen(site.slug);
    971   renderPage(req, res, 'pages/fedi-notifications', { pageTitle: 'Meldingen', bodyClass: 'on-special', items });
    972 });
     971router.get('/notifications', requireSiteManager, (req, res) => res.redirect(`${res.locals.siteUrlBase || ''}/messages`));
    973972
    974973// Blocking / defederation (owner-only).
Note: See TracChangeset for help on using the changeset viewer.