Changeset ffa53cc in Klonkt


Ignore:
Timestamp:
06/24/2026 01:56:06 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
c73ac64
Parents:
de3d24b
Message:

fix(activitypub): no self-duplicate when replying on your own post

deliverReply never delivers to our own inbox, and the inbox ignores activities
from our own actors (already stored via ap_outbox). Fixes a reply appearing
twice (once as You, once as the site actor) on the owner's own post.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    rde3d24b rffa53cc  
    386386  const actorUri = typeof act.actor === 'string' ? act.actor : (act.actor && act.actor.id);
    387387  const resolveActor = async (uri) => ((verified && verified.id === uri) ? verified : await fetchActor(uri).catch(() => null));
     388  // Activities from our OWN actors are already stored via ap_outbox — don't re-store.
     389  const isLocalActor = !!(base && actorUri && actorUri.startsWith(`${base}/ap/users/`));
    388390
    389391  // Inbound reply: a Create whose object replies to one of our notes (post OR comment).
     
    391393    const o = act.object;
    392394    const tgt = findThreadTarget(o.inReplyTo, base);
    393     if (tgt && actorUri) {
     395    if (tgt && actorUri && !isLocalActor) {
    394396      const ai = actorInfo(await resolveActor(actorUri), actorUri);
    395397      const html = HtmlSanitizerService.sanitize(o.content || '');
     
    402404    const tgt = act.object;
    403405    const pid = postIdFromNoteUrl(typeof tgt === 'string' ? tgt : (tgt && tgt.id), base);
    404     if (pid && actorUri && localPostExists(pid)) {
     406    if (pid && actorUri && !isLocalActor && localPostExists(pid)) {
    405407      const ai = actorInfo(await resolveActor(actorUri), actorUri);
    406408      iStmts().ins.run(type.toLowerCase(), pid, '', actorUri, ai.name, ai.handle, ai.url, ai.icon, null, null, null);
     
    518520  if (parent.threadInbox) inboxes.add(parent.threadInbox); // post author's server (nesting)
    519521  for (const f of fStmts().list.all(site.slug)) inboxes.add(f.shared_inbox || f.inbox);
     522  inboxes.delete(`${me}/inbox`);       // never deliver to ourselves (already in ap_outbox)
     523  inboxes.delete(`${base}/ap/inbox`);  // (our own shared inbox) → avoids a self-duplicate
    520524  let delivered = 0;
    521525  for (const inbox of [...inboxes].filter(Boolean)) {
Note: See TracChangeset for help on using the changeset viewer.