Changeset 1cc8c85 in Klonkt


Ignore:
Timestamp:
07/16/2026 12:20:51 PM (8 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
87d2787
Parents:
476d6e7
git-author:
Robin <roboburr@…> (07/13/2026 05:48:50 AM)
git-committer:
Robin <roboburr@…> (07/16/2026 12:20:51 PM)
Message:

Spoor A step 3b: buildNote is the single Note entry point (buildReplyNote delegates)

Fold buildReplyNote into buildNote via an isReply option, so ALL ActivityPub
Notes are built by one function. For now a reply stays the simple flavor
(pre-baked content, no title/cover/image/audio/embed machinery) behind an early
branch, so output is byte-identical (verified: reply Note deep-equals the old
buildReplyNote for both a mention+hashtag reply and a plain reply; 46 tests
green). buildReplyNote is now a thin delegate, so no caller changes. This is the
foundation for rich replies: when replies gain images/audio/embeds, the branch
collapses and they flow through the full post pipeline instead of duplicating it.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    r476d6e7 r1cc8c85  
    210210
    211211// A single post as an AS2 Note (the object), and as a Create activity (for outbox/delivery).
    212 export function buildNote(base, site, post) {
     212export function buildNote(base, site, post, opts = {}) {
     213  // Replies are Notes too. buildNote is the single entry point for ALL Notes; a reply is
     214  // (for now) the simple flavor: pre-baked content, no title/cover/image/audio/embed
     215  // machinery, addressed to the parent actor + thread. This early branch keeps that output
     216  // byte-identical to the old buildReplyNote. When rich replies land (images/audio/embeds),
     217  // this branch collapses and replies flow through the full post pipeline below. `post` here
     218  // is the ap_outbox reply row (id, in_reply_to, content, post_slug, created_at, to_actor).
     219  if (opts.isReply) {
     220    const meR = actorId(base, site.slug);
     221    return {
     222      id: noteId(base, post.id),
     223      type: 'Note',
     224      attributedTo: meR,
     225      inReplyTo: post.in_reply_to || undefined,
     226      content: post.content,
     227      url: post.post_slug ? `${base}/${encodeURIComponent(post.post_slug)}` : undefined,
     228      published: toISO(post.created_at),
     229      to: post.to_actor ? [post.to_actor] : [PUBLIC],
     230      cc: [PUBLIC, `${meR}/followers`],
     231      tag: [
     232        ...mentionTags(post.content),
     233        ...hashtagTags(base, post.content),
     234      ],
     235    };
     236  }
    213237  const id = noteId(base, post.id);
    214238  const aId = actorId(base, site.slug);
     
    15721596
    15731597export function buildReplyNote(base, site, row) {
    1574   const me = actorId(base, site.slug);
    1575   return {
    1576     id: noteId(base, row.id),
    1577     type: 'Note',
    1578     attributedTo: me,
    1579     inReplyTo: row.in_reply_to || undefined,
    1580     content: row.content,
    1581     url: row.post_slug ? `${base}/${encodeURIComponent(row.post_slug)}` : undefined,
    1582     published: toISO(row.created_at),
    1583     to: row.to_actor ? [row.to_actor] : [PUBLIC],
    1584     cc: [PUBLIC, `${me}/followers`],
    1585     tag: [
    1586       ...mentionTags(row.content),
    1587       ...hashtagTags(base, row.content),
    1588     ],
    1589   };
     1598  // Thin delegate: replies are built by buildNote (the single Note entry point) in reply mode.
     1599  return buildNote(base, site, row, { isReply: true });
    15901600}
    15911601
Note: See TracChangeset for help on using the changeset viewer.