Changeset 41a7637 in Klonkt for src/routes/posts.js


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

fix(activitypub): instant Send + confirmation on remote reply

Send now resolves+delivers in the background and immediately shows a 'Sent ✅'
confirmation, instead of awaiting delivery and redirecting to a raw AP-JSON URL
(which felt like nothing happened).

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r7f46112b r41a7637  
    518518  const site = res.locals.site;
    519519  const uri = (req.query.uri || '').toString();
     520  const sent = !!req.query.sent;
    520521  let target = null;
    521   try { target = await ActivityPubService.resolveRemoteNote(uri); } catch { /* ignore */ }
     522  if (!sent) { try { target = await ActivityPubService.resolveRemoteNote(uri); } catch { /* ignore */ } }
    522523  renderPage(req, res, 'pages/authorize-interaction', {
    523524    pageTitle: 'Reageer via de fediverse',
     
    525526    uri,
    526527    target,
     528    sent,
    527529    siteTitle: site ? site.title : '',
    528530  });
    529531});
    530532
    531 router.post('/authorize_interaction', requireSiteManager, async (req, res) => {
     533router.post('/authorize_interaction', requireSiteManager, (req, res) => {
    532534  const site = res.locals.site;
    533535  const uri = (req.body.uri || '').toString();
    534536  const text = (req.body.text || '').toString();
    535537  if (site && uri && text.trim()) {
    536     try {
    537       const parent = await ActivityPubService.resolveRemoteNote(uri);
    538       if (parent) await ActivityPubService.deliverReply(site, { postId: '', postSlug: null, parent, text });
    539     } catch (e) { console.warn('[AP] remote reply failed:', e.message); }
    540   }
    541   // Send them to the post they replied to so they can see the thread.
    542   res.redirect(uri && /^https?:\/\//i.test(uri) ? uri : (res.locals.siteUrlBase || '/'));
     538    // Resolve + deliver in the background so Send responds instantly.
     539    ActivityPubService.resolveRemoteNote(uri)
     540      .then((parent) => parent && ActivityPubService.deliverReply(site, { postId: '', postSlug: null, parent, text }))
     541      .catch((e) => console.warn('[AP] remote reply failed:', e.message));
     542  }
     543  res.redirect('/authorize_interaction?sent=1&uri=' + encodeURIComponent(uri));
    543544});
    544545
Note: See TracChangeset for help on using the changeset viewer.