Changeset 1c2dcba in Klonkt for src/routes


Ignore:
Timestamp:
07/01/2026 07:14:12 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
737ea05
Parents:
0688b5f
Message:

feat(fediverse): report a post/account to its home server (AS2 Flag)

From the interact page you can now report a fediverse post to its home server's
moderators. Sends the Mastodon-standard AS2 Flag (object = [reported account,
reported status], content = the reason) to the reported account's inbox.

  • src/services/ActivityPubService.js — sendReport(site, {objectUri, actorUri, reason}) resolves the reported account, builds the Flag and delivers it to their inbox.
  • src/routes/posts.js — POST /authorize_interaction/report (owner-only); GET passes reported and skips re-resolving on the confirmation view.
  • src/views/pages/authorize-interaction.ejs — a "Report this post" disclosure with a reason field, a "reported" confirmation, and scoped styles.
  • src/services/i18n.js — fedi.report_* + fedi.reported_* (nl/en/de).
  • test/activitypub-as2.test.js — allow the AS2 Flag activity type.
  • CHANGELOG(.nl/.de).md — "Report a post to the fediverse" under Unreleased.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r0688b5f r1c2dcba  
    585585  const followed = !!req.query.followed;
    586586  const voted = !!req.query.voted;
     587  const reported = !!req.query.reported;
    587588  let target = null, followTarget = null;
    588   if (!sent && !followed && !voted && uri) {
     589  if (!sent && !followed && !voted && !reported && uri) {
    589590    try { target = await ActivityPubService.resolveRemoteNote(uri); } catch { /* ignore */ }
    590591    // Not a post? Maybe the URI is a profile/actor → offer Follow, not reply.
     
    600601    followed,
    601602    voted: !!req.query.voted,
     603    reported: !!req.query.reported,
    602604    liked: !!req.query.liked,
    603605    boosted: !!req.query.boosted,
     
    617619  if (site && uri && choice.length) { try { await ActivityPubService.voteOnRemotePoll(site, uri, choice.map(String)); } catch { /* ignore */ } }
    618620  res.redirect('/authorize_interaction?voted=1&uri=' + encodeURIComponent(uri));
     621});
     622
     623// 🚩 Report a remote post/account to its home instance (sends an AS2 Flag).
     624router.post('/authorize_interaction/report', requireSiteManager, async (req, res) => {
     625  const site = res.locals.site;
     626  const uri = (req.body.uri || '').toString();
     627  const actorUri = (req.body.actor_uri || '').toString();
     628  const reason = (req.body.reason || '').toString();
     629  if (site && (uri || actorUri)) { try { await ActivityPubService.sendReport(site, { objectUri: uri, actorUri, reason }); } catch { /* ignore */ } }
     630  res.redirect('/authorize_interaction?reported=1&uri=' + encodeURIComponent(uri || actorUri));
    619631});
    620632
Note: See TracChangeset for help on using the changeset viewer.