Changeset 67fe576 in Klonkt for src/routes


Ignore:
Timestamp:
06/25/2026 10:25:57 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
6cabd18
Parents:
e91849c
Message:

ux(fedi): owner can like/boost a fediverse comment directly too

Extends the owner-direct treatment to likes and boosts: under an inbound
fediverse comment the site owner now gets a star + boost button that go straight
through /posts/:slug/fedi-react (sendInteraction as the site), alongside the
direct reply. No 'your server' detour. Visitors are unchanged.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    re91849c r67fe576  
    899899});
    900900
     901// Owner likes/boosts a fediverse comment on their own post — directly as the
     902// site, no "your server" detour (mirrors /fedi-reply).
     903router.post('/posts/:slug/fedi-react', requireSiteManager, async (req, res) => {
     904  const site = res.locals.site;
     905  if (!site) return res.status(404).send('Site required');
     906  const post = db.prepare('SELECT id, slug FROM posts WHERE site_id = ? AND slug = ?').get(site.id, req.params.slug);
     907  if (!post) return res.status(404).send('Not found');
     908  const parent = ActivityPubService.getInteractionById(req.body.interaction_id);
     909  const kind = req.body.kind === 'boost' ? 'boost' : 'like';
     910  if (parent && parent.post_id === post.id && parent.object_uri) {
     911    ActivityPubService.sendInteraction(site, kind, parent.object_uri, parent.actor_uri)
     912      .catch((e) => console.warn('[AP] reaction failed:', e.message));
     913  }
     914  res.redirect(`${res.locals.siteUrlBase || ''}/${post.slug}#fediverse`);
     915});
     916
    901917export default router;
    902918export { postNeighbors };
Note: See TracChangeset for help on using the changeset viewer.