Changeset c73ac64 in Klonkt for src


Ignore:
Timestamp:
06/24/2026 01:58:33 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
5b47619
Parents:
ffa53cc
Message:

fix(activitypub): own replies show the site identity to everyone (not 'You')

Outbound reply nodes carry the site name/handle/avatar so visitors see e.g.
'Joost Groot @demo@...' instead of 'You'; the owner still gets the delete action.

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

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    rffa53cc rc73ac64  
    806806  try {
    807807    const _apBase = (process.env.PUBLIC_BASE_URL || `${req.protocol}://${req.get('host')}`).replace(/\/+$/, '');
    808     fediverse = ActivityPubService.getInteractions(post.id, _apBase);
     808    fediverse = ActivityPubService.getInteractions(post.id, _apBase, site);
    809809  } catch { /* non-fatal */ }
    810810  // Owner/admin of this site may reply back to a fediverse interaction.
  • src/services/ActivityPubService.js

    rffa53cc rc73ac64  
    250250// View-ready threaded view of a post's fediverse activity (inbound replies +
    251251// our outbound replies, nested), plus like/boost counts.
    252 export function getInteractions(postId, base) {
     252export function getInteractions(postId, base, site) {
    253253  const s = iStmts();
    254254  const rows = s.list.all(postId);
    255255  const baseClean = (base || process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, '');
    256256  const postNoteId = baseClean ? `${baseClean}/ap/notes/${postId}` : null;
     257  // Our own (outbound) replies show the SITE identity for everyone (not "You").
     258  let host = ''; try { host = new URL(baseClean).host; } catch { /* ignore */ }
     259  const siteName = (site && (site.title || site.slug)) || '';
     260  const siteHandle = (site && site.slug && host) ? `@${site.slug}@${host}` : '';
     261  const siteUrl = baseClean ? `${baseClean}/` : '';
     262  const siteIcon = (site && site.profile_photo) || null;
    257263
    258264  const nodes = [];
     
    269275    nodes.push({
    270276      noteId: baseClean ? `${baseClean}/ap/notes/${o.id}` : o.id, parent: o.in_reply_to || null,
    271       mine: true, outboxId: o.id, content: o.content, created_at: o.created_at, children: [],
     277      mine: true, outboxId: o.id, content: o.content, created_at: o.created_at,
     278      actor_name: siteName, actor_handle: siteHandle, actor_url: siteUrl, actor_icon: siteIcon,
     279      children: [],
    272280    });
    273281  }
  • src/views/partials/fedi-node.ejs

    rffa53cc rc73ac64  
    11<%# Renders one fediverse thread node (n). Expects: n, t, canManageSite, _base, siteAvatar, formatDateTime %>
    22<div class="comment-avatar">
    3   <% if (n.mine) { %>
    4     <% if (typeof siteAvatar !== 'undefined' && siteAvatar) { %><img src="<%= siteAvatar %>" alt="">
    5     <% } else { %><span><%= t('fedi.you').charAt(0).toUpperCase() %></span><% } %>
    6   <% } else if (n.actor_icon) { %><img src="<%= n.actor_icon %>" alt="" loading="lazy">
     3  <% if (n.actor_icon) { %><img src="<%= n.actor_icon %>" alt="" loading="lazy">
    74  <% } else { %><span><%= (n.actor_name || '?').charAt(0).toUpperCase() %></span><% } %>
    85</div>
    96<div class="comment-body">
    107  <div class="comment-meta">
    11     <% if (n.mine) { %>
    12       <span class="comment-author"><%= t('fedi.you') %></span>
    13     <% } else { %>
    14       <a class="comment-author" href="<%= n.actor_url %>" rel="nofollow noopener" target="_blank"><%= n.actor_name %></a>
    15       <span class="fedi-handle"><%= n.actor_handle %></span>
    16     <% } %>
     8    <% if (n.actor_url) { %><a class="comment-author" href="<%= n.actor_url %>" rel="nofollow noopener" target="_blank"><%= n.actor_name %></a>
     9    <% } else { %><span class="comment-author"><%= n.actor_name %></span><% } %>
     10    <% if (n.actor_handle) { %><span class="fedi-handle"><%= n.actor_handle %></span><% } %>
    1711    <% if (n.created_at) { %><span class="comment-time"><%= formatDateTime(n.created_at) %></span><% } %>
    1812  </div>
Note: See TracChangeset for help on using the changeset viewer.