Changeset 00f669b in Klonkt


Ignore:
Timestamp:
06/24/2026 03:27:49 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
d0cab9d
Parents:
d988fa0
Message:

feat(fediverse-client): notifications inbox (/meldingen)

Aggregates new followers + replies/likes/boosts on your posts into one feed
(getNotifications). New pages/fedi-notifications view + Beheer link. The old
native notifications.ejs (dead since comments removed) is left untouched.

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

Location:
src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    rd988fa0 r00f669b  
    8686  'tag', 'type', 'user', 'users', 'artiesten', 'leden', 'favorieten', 'feed.xml', 'atom.xml', 'sitemap.xml',
    8787  'manifest.webmanifest', 'sw.js', 'favicon.ico', 'favicon.svg', 'assets',
    88   'authorize_interaction', 'fediverse', 'tijdlijn',
     88  'authorize_interaction', 'fediverse', 'tijdlijn', 'meldingen',
    8989]);
    9090
     
    606606  if (site) { try { await ActivityPubService.sendInteraction(site, 'boost', (req.body.note || '').toString(), (req.body.author || '').toString()); } catch (e) { /* ignore */ } }
    607607  res.redirect('/tijdlijn?success=' + encodeURIComponent('Geboost 🔁'));
     608});
     609
     610// Notifications inbox (new followers + replies/likes/boosts on your posts).
     611router.get('/meldingen', requireSiteManager, (req, res) => {
     612  const site = res.locals.site;
     613  const items = site ? ActivityPubService.getNotifications(site.slug, 80) : [];
     614  renderPage(req, res, 'pages/fedi-notifications', { pageTitle: 'Meldingen', bodyClass: 'on-special', items });
    608615});
    609616
  • src/services/ActivityPubService.js

    rd988fa0 r00f669b  
    737737}
    738738
     739// Notifications inbox: new followers + replies/likes/boosts on this site's posts.
     740export function getNotifications(slug, limit) {
     741  const out = [];
     742  try {
     743    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)) {
     744      out.push({ type: 'follow', handle: deriveHandle(f.actor_uri), url: f.actor_uri, created_at: f.created_at });
     745    }
     746  } catch { /* ignore */ }
     747  try {
     748    const rows = db.prepare(`
     749      SELECT i.kind, i.actor_name, i.actor_handle, i.actor_url, i.content, i.created_at,
     750             p.slug AS post_slug, p.title AS post_title
     751      FROM ap_interactions i LEFT JOIN posts p ON p.id = i.post_id
     752      WHERE p.site_id = (SELECT id FROM sites WHERE slug = ?)
     753      ORDER BY i.created_at DESC LIMIT 80
     754    `).all(slug);
     755    for (const r of rows) out.push({
     756      type: r.kind, name: r.actor_name, handle: r.actor_handle, url: r.actor_url,
     757      content: r.content, post_slug: r.post_slug, post_title: r.post_title, created_at: r.created_at,
     758    });
     759  } catch { /* ignore */ }
     760  out.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
     761  return out.slice(0, limit || 60);
     762}
     763
    739764export default {
    740765  getOrCreateKeys, apWants, sendAP, actorId, noteId,
     
    744769  listOutbox, deliverOutboxDelete,
    745770  webfingerResolve, followActor, unfollowActor, listFollowing, getTimeline, sendInteraction,
     771  getNotifications,
    746772};
  • src/services/i18n.js

    rd988fa0 r00f669b  
    2626    'nav.language': 'Taal',
    2727    'nav.notifications': 'Meldingen',
    28     'notif.title': 'Meldingen', 'notif.empty': 'Nog geen meldingen.', 'notif.someone': 'Iemand',
     28    'notif.title': 'Meldingen', 'notif.empty': 'Nog geen meldingen.', 'notif.someone': 'Iemand', 'notif.followed': 'volgt je nu', 'notif.liked': 'likete je post', 'notif.boosted': 'boostte je post', 'notif.replied': 'reageerde op',
    2929    'notif.reply': '{actor} reageerde op je reactie', 'notif.comment': '{actor} reageerde op je post', 'notif.like': '{actor} vindt je post leuk',
    3030    'switch.agenda': 'Agenda',
     
    10291029    'nav.language': 'Language',
    10301030    'nav.notifications': 'Notifications',
    1031     'notif.title': 'Notifications', 'notif.empty': 'No notifications yet.', 'notif.someone': 'Someone',
     1031    'notif.title': 'Notifications', 'notif.empty': 'No notifications yet.', 'notif.someone': 'Someone', 'notif.followed': 'followed you', 'notif.liked': 'liked your post', 'notif.boosted': 'boosted your post', 'notif.replied': 'replied to',
    10321032    'notif.reply': '{actor} replied to your comment', 'notif.comment': '{actor} commented on your post', 'notif.like': '{actor} liked your post',
    10331033    'switch.agenda': 'Agenda',
     
    20232023    'nav.language': 'Sprache',
    20242024    'nav.notifications': 'Benachrichtigungen',
    2025     'notif.title': 'Benachrichtigungen', 'notif.empty': 'Noch keine Benachrichtigungen.', 'notif.someone': 'Jemand',
     2025    'notif.title': 'Benachrichtigungen', 'notif.empty': 'Noch keine Benachrichtigungen.', 'notif.someone': 'Jemand', 'notif.followed': 'folgt dir jetzt', 'notif.liked': 'gefällt dein Beitrag', 'notif.boosted': 'teilte deinen Beitrag', 'notif.replied': 'antwortete auf',
    20262026    'notif.reply': '{actor} hat auf deinen Kommentar geantwortet', 'notif.comment': '{actor} hat deinen Beitrag kommentiert', 'notif.like': '{actor} gefällt dein Beitrag',
    20272027    'switch.agenda': 'Termine',
  • src/views/pages/admin.ejs

    rd988fa0 r00f669b  
    5858    <% } %>
    5959    <a href="/tijdlijn" class="btn">🌐 <%= t('tl.title') %></a>
     60    <a href="/meldingen" class="btn">🔔 <%= t('notif.title') %></a>
    6061    <a href="/admin/updates" class="btn"><%= t('admin.b_updates') %></a>
    6162    <a href="/admin/handleiding" class="btn"><%= t('admin.b_help') %></a>
Note: See TracChangeset for help on using the changeset viewer.