Changeset 8ad1784 in Klonkt for src/routes


Ignore:
Timestamp:
06/25/2026 09:08:20 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
7c62efb
Parents:
4c12783
Message:

feat(ap): authorize_interaction handles actor URIs as a Follow

The fediverse interaction page only did reply/like — it always tried to
resolve the URI as a post. A profile/actor URL fell through to the reply
composer, so 'following' produced a reply. Now: if the URI isn't a post,
resolve it as an actor and show a Follow action (followActor, which now
accepts a profile URL as well as an @handle). Adds fedi.follow_* i18n (nl/en/de).

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r4c12783 r8ad1784  
    485485  const uri = (req.query.uri || '').toString();
    486486  const sent = !!req.query.sent;
    487   let target = null;
    488   if (!sent) { try { target = await ActivityPubService.resolveRemoteNote(uri); } catch { /* ignore */ } }
     487  const followed = !!req.query.followed;
     488  let target = null, followTarget = null;
     489  if (!sent && !followed && uri) {
     490    try { target = await ActivityPubService.resolveRemoteNote(uri); } catch { /* ignore */ }
     491    // Not a post? Maybe the URI is a profile/actor → offer Follow, not reply.
     492    if (!target) { try { followTarget = await ActivityPubService.resolveRemoteActor(uri); } catch { /* ignore */ } }
     493  }
    489494  renderPage(req, res, 'pages/authorize-interaction', {
    490495    pageTitle: 'Interacteer via de fediverse',
     
    492497    uri,
    493498    target,
     499    followTarget,
    494500    sent,
     501    followed,
    495502    liked: !!req.query.liked,
    496503    siteTitle: site ? site.title : '',
     
    508515  }
    509516  res.redirect('/authorize_interaction?liked=1&uri=' + encodeURIComponent(uri));
     517});
     518
     519// Follow a remote actor from your own site (when the target is a profile, not a post).
     520router.post('/authorize_interaction/follow', requireSiteManager, (req, res) => {
     521  const site = res.locals.site;
     522  const uri = (req.body.uri || '').toString();
     523  if (site && uri) {
     524    ActivityPubService.followActor(site, uri)
     525      .catch((e) => console.warn('[AP] remote follow failed:', e.message));
     526  }
     527  res.redirect('/authorize_interaction?followed=1&uri=' + encodeURIComponent(uri));
    510528});
    511529
Note: See TracChangeset for help on using the changeset viewer.