Changeset 065452a in Klonkt


Ignore:
Timestamp:
06/24/2026 11:11:29 AM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
5a93ac0
Parents:
dd1028a
Message:

fix(activitypub): include post title in the Note content

Mastodon ignores a Note's name field, so prepend the title as a bold first line
in content (the standard blog->fediverse convention). Title is HTML-escaped.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    rdd1028a r065452a  
    101101  const aId = actorId(base, site.slug);
    102102  const human = `${base}/${encodeURIComponent(post.slug)}`;
    103   const html = post.content || ''; // posts store sanitized HTML
     103  // Mastodon ignores a Note's `name`, so put the title INTO the content (bold
     104  // first line) — the standard blog→fediverse convention. post.content is
     105  // already sanitized HTML; the title is plain text, so escape it.
     106  const escTitle = String(post.title || '').replace(/[<>&]/g, (c) => ({ '<': '&lt;', '>': '&gt;', '&': '&amp;' }[c]));
     107  const titleHtml = post.title ? `<p><strong>${escTitle}</strong></p>` : '';
     108  const html = titleHtml + (post.content || '');
    104109  return {
    105110    id,
     
    107112    attributedTo: aId,
    108113    content: html,
    109     name: post.title || undefined,
    110114    url: human,
    111115    published: new Date(post.published_at || post.created_at || Date.now()).toISOString(),
Note: See TracChangeset for help on using the changeset viewer.