Changeset 41a7637 in Klonkt


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@…>

Location:
src
Files:
3 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
  • src/services/i18n.js

    r7f46112b r41a7637  
    109109    'fedi.heading': 'Vanuit de fediverse', 'fedi.likes': 'sterren', 'fedi.boosts': 'boosts', 'fedi.replies': 'Reacties uit de fediverse',
    110110    'fedi.reply': 'Reageer', 'fedi.reply_ph': 'Je antwoord aan de fediverse…', 'fedi.send': 'Versturen', 'fedi.you': 'Jij',
    111     'fedi.remote_title': 'Reageer via de fediverse', 'fedi.remote_reply': 'Reageer via de fediverse', 'fedi.remote_prompt': 'Je fediverse-adres (bv. @jij@mastodon.social):', 'fedi.remote_notfound': 'Kon die post niet ophalen. Plak de volledige post-URL:', 'fedi.remote_load': 'Ophalen', 'fedi.remote_replying_to': 'Je reageert op', 'fedi.remote_as': 'Wordt verzonden als {site}.', 'fedi.remote_view_original': 'Bekijk de hele post + reacties op de bron →', 'fedi.remote_reply_short': 'via de fediverse',
     111    'fedi.remote_title': 'Reageer via de fediverse', 'fedi.remote_reply': 'Reageer via de fediverse', 'fedi.remote_prompt': 'Je fediverse-adres (bv. @jij@mastodon.social):', 'fedi.remote_notfound': 'Kon die post niet ophalen. Plak de volledige post-URL:', 'fedi.remote_load': 'Ophalen', 'fedi.remote_replying_to': 'Je reageert op', 'fedi.remote_as': 'Wordt verzonden als {site}.', 'fedi.remote_view_original': 'Bekijk de hele post + reacties op de bron →', 'fedi.remote_reply_short': 'via de fediverse', 'fedi.remote_sent_title': 'Verzonden ✅', 'fedi.remote_sent': 'Je reactie is onderweg naar de fediverse en verschijnt zo bij de ontvanger.', 'fedi.remote_back': '← Terug naar je site',
    112112    'comments.to_start': 'om de conversatie te starten.',
    113113    'comments.reply': 'Reageer', 'comments.delete': 'Verwijder', 'comments.cancel': 'Annuleren',
     
    11041104    'fedi.heading': 'From the fediverse', 'fedi.likes': 'favourites', 'fedi.boosts': 'boosts', 'fedi.replies': 'Replies from the fediverse',
    11051105    'fedi.reply': 'Reply', 'fedi.reply_ph': 'Your reply to the fediverse…', 'fedi.send': 'Send', 'fedi.you': 'You',
    1106     'fedi.remote_title': 'Reply via the fediverse', 'fedi.remote_reply': 'Reply via the fediverse', 'fedi.remote_prompt': 'Your fediverse address (e.g. @you@mastodon.social):', 'fedi.remote_notfound': 'Could not fetch that post. Paste the full post URL:', 'fedi.remote_load': 'Fetch', 'fedi.remote_replying_to': 'Replying to', 'fedi.remote_as': 'Sent as {site}.', 'fedi.remote_view_original': 'View the full post + comments on the source →', 'fedi.remote_reply_short': 'via the fediverse',
     1106    'fedi.remote_title': 'Reply via the fediverse', 'fedi.remote_reply': 'Reply via the fediverse', 'fedi.remote_prompt': 'Your fediverse address (e.g. @you@mastodon.social):', 'fedi.remote_notfound': 'Could not fetch that post. Paste the full post URL:', 'fedi.remote_load': 'Fetch', 'fedi.remote_replying_to': 'Replying to', 'fedi.remote_as': 'Sent as {site}.', 'fedi.remote_view_original': 'View the full post + comments on the source →', 'fedi.remote_reply_short': 'via the fediverse', 'fedi.remote_sent_title': 'Sent ✅', 'fedi.remote_sent': 'Your reply is on its way to the fediverse and will appear for the recipient shortly.', 'fedi.remote_back': '← Back to your site',
    11071107    'comments.to_start': 'to start the conversation.',
    11081108    'comments.reply': 'Reply', 'comments.delete': 'Delete', 'comments.cancel': 'Cancel',
     
    20972097    'fedi.heading': 'Aus dem Fediverse', 'fedi.likes': 'Favoriten', 'fedi.boosts': 'Boosts', 'fedi.replies': 'Antworten aus dem Fediverse',
    20982098    'fedi.reply': 'Antworten', 'fedi.reply_ph': 'Deine Antwort an das Fediverse…', 'fedi.send': 'Senden', 'fedi.you': 'Du',
    2099     'fedi.remote_title': 'Über das Fediverse antworten', 'fedi.remote_reply': 'Über das Fediverse antworten', 'fedi.remote_prompt': 'Deine Fediverse-Adresse (z.B. @du@mastodon.social):', 'fedi.remote_notfound': 'Beitrag konnte nicht geladen werden. Füge die vollständige Beitrags-URL ein:', 'fedi.remote_load': 'Laden', 'fedi.remote_replying_to': 'Antwort an', 'fedi.remote_as': 'Wird als {site} gesendet.', 'fedi.remote_view_original': 'Ganzen Beitrag + Kommentare an der Quelle ansehen →', 'fedi.remote_reply_short': 'übers Fediverse',
     2099    'fedi.remote_title': 'Über das Fediverse antworten', 'fedi.remote_reply': 'Über das Fediverse antworten', 'fedi.remote_prompt': 'Deine Fediverse-Adresse (z.B. @du@mastodon.social):', 'fedi.remote_notfound': 'Beitrag konnte nicht geladen werden. Füge die vollständige Beitrags-URL ein:', 'fedi.remote_load': 'Laden', 'fedi.remote_replying_to': 'Antwort an', 'fedi.remote_as': 'Wird als {site} gesendet.', 'fedi.remote_view_original': 'Ganzen Beitrag + Kommentare an der Quelle ansehen →', 'fedi.remote_reply_short': 'übers Fediverse', 'fedi.remote_sent_title': 'Gesendet ✅', 'fedi.remote_sent': 'Deine Antwort ist auf dem Weg ins Fediverse und erscheint gleich beim Empfänger.', 'fedi.remote_back': '← Zurück zu deiner Seite',
    21002100    'comments.to_start': 'um das Gespräch zu starten.',
    21012101    'comments.reply': 'Antworten', 'comments.delete': 'Löschen', 'comments.cancel': 'Abbrechen',
  • src/views/pages/authorize-interaction.ejs

    r7f46112b r41a7637  
    11<div class="auth-interact">
     2  <% if (typeof sent !== 'undefined' && sent) { %>
     3    <h1 class="auth-interact-title"><%= t('fedi.remote_sent_title') %></h1>
     4    <p class="auth-interact-note"><%= t('fedi.remote_sent') %></p>
     5    <p class="auth-interact-actions">
     6      <% if (uri) { %><a class="btn" href="<%= uri %>" target="_blank" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
     7      <a class="btn btn-primary" href="/"><%= t('fedi.remote_back') %></a>
     8    </p>
     9  <% } else { %>
    210  <h1 class="auth-interact-title"><%= t('fedi.remote_title') %></h1>
    311
     
    3442    <p class="auth-interact-note"><%= t('fedi.remote_as', { site: siteTitle }) %></p>
    3543  <% } %>
     44  <% } %>
    3645</div>
    3746
Note: See TracChangeset for help on using the changeset viewer.