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@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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};
Note: See TracChangeset for help on using the changeset viewer.