Ignore:
Timestamp:
06/24/2026 12:44:21 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
594cc50
Parents:
82079ad
Message:

feat(activitypub): remote interaction — reply to any fediverse post from your own server

Standard 'reply from your own server' flow: every post page has a 'Reply via the
fediverse' button that bounces the visitor to their home server's
/authorize_interaction?uri=. Klonkt implements that endpoint: the site owner
composes a reply that's resolved (resolveRemoteNote) + federated back to the
remote post as the site actor. Works Klonkt<->Klonkt and with Mastodon.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    r82079ad r3d7312a  
    477477}
    478478
     479// Resolve a remote post URL (any fediverse/Klonkt post) into a reply target.
     480// Returns a parent-shaped object usable by deliverReply(), or null.
     481export async function resolveRemoteNote(url) {
     482  if (!/^https?:\/\//i.test(String(url || ''))) return null;
     483  const note = await fetchActor(url).catch(() => null); // AP GET (content-negotiates)
     484  if (!note || !note.id) return null;
     485  const att = note.attributedTo;
     486  const actorUri = typeof att === 'string' ? att : (att && att.id);
     487  if (!actorUri) return null;
     488  const actor = await fetchActor(actorUri).catch(() => null);
     489  const ai = actorInfo(actor, actorUri);
     490  return {
     491    object_uri: note.id,
     492    actor_uri: actorUri,
     493    actor_url: ai.url,
     494    actor_handle: ai.handle,
     495    actor_name: ai.name,
     496    actor_icon: ai.icon,
     497    preview: HtmlSanitizerService.toPlainText(note.content || '').slice(0, 240),
     498  };
     499}
     500
    479501export default {
    480502  getOrCreateKeys, apWants, sendAP, actorId, noteId,
    481503  buildActor, buildNote, buildCreate, buildOutbox, buildFollowers,
    482504  followerCount, deliver, fetchActor, verifyRequest, handleInbox, deliverCreate, deliverDelete,
    483   getInteractions, getInteractionById, buildReplyNote, getOutboxNote, deliverReply,
     505  getInteractions, getInteractionById, buildReplyNote, getOutboxNote, deliverReply, resolveRemoteNote,
    484506};
Note: See TracChangeset for help on using the changeset viewer.