Changeset 7d932ce in Klonkt for src/routes


Ignore:
Timestamp:
06/24/2026 01:24:23 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
a885afc
Parents:
cc24fa1
Message:

feat(activitypub): nested threading + delete your own replies

Inbox now stores replies-to-comments nested (findThreadTarget resolves the post
via the parent comment); getInteractions builds a thread tree shown on the post
(fedi-node partial). deliverReply also cc's the post author's inbox so their
Klonkt threads it. Owners can delete their outbound replies (Delete+Tombstone)
inline + via /fediverse manage list. Schema: ap_interactions.parent_uri.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    rcc24fa1 r7d932ce  
    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',
     88  'authorize_interaction', 'fediverse',
    8989]);
    9090
     
    542542  }
    543543  res.redirect('/authorize_interaction?sent=1&uri=' + encodeURIComponent(uri));
     544});
     545
     546// Manage / delete your own outbound fediverse replies (site owner only).
     547router.get('/fediverse', requireSiteManager, (req, res) => {
     548  const site = res.locals.site;
     549  const items = site ? ActivityPubService.listOutbox(site.slug) : [];
     550  renderPage(req, res, 'pages/authorize-interaction', {
     551    pageTitle: 'Mijn fediverse-reacties', bodyClass: 'on-special',
     552    manage: items, uri: '', target: null, sent: false, siteTitle: site ? site.title : '',
     553  });
     554});
     555
     556router.post('/fediverse/:id/delete', requireSiteManager, async (req, res) => {
     557  const site = res.locals.site;
     558  if (site) {
     559    try { await ActivityPubService.deliverOutboxDelete(site, req.params.id); }
     560    catch (e) { console.warn('[AP] outbox delete failed:', e.message); }
     561  }
     562  res.redirect(req.get('Referer') || `${res.locals.siteUrlBase || ''}/fediverse`);
    544563});
    545564
     
    783802    db.prepare('SELECT 1 FROM post_likes WHERE post_id = ? AND user_id = ?').get(post.id, req.session.user.id));
    784803
    785   // Inbound fediverse activity (replies/likes/boosts) for this post.
    786   let fediverse = { replies: [], outReplies: [], likeCount: 0, announceCount: 0, total: 0 };
    787   try { fediverse = ActivityPubService.getInteractions(post.id); } catch { /* non-fatal */ }
     804  // Inbound fediverse activity (threaded) for this post.
     805  let fediverse = { thread: [], likeCount: 0, announceCount: 0, total: 0 };
     806  try {
     807    const _apBase = (process.env.PUBLIC_BASE_URL || `${req.protocol}://${req.get('host')}`).replace(/\/+$/, '');
     808    fediverse = ActivityPubService.getInteractions(post.id, _apBase);
     809  } catch { /* non-fatal */ }
    788810  // Owner/admin of this site may reply back to a fediverse interaction.
    789811  const canManageSite = !!(req.session?.user && PermissionsService.canAdminSite(req.session.user, site));
Note: See TracChangeset for help on using the changeset viewer.