Changeset d988fa0 in Klonkt for src/services
- Timestamp:
- 06/24/2026 03:23:01 PM (3 months ago)
- Branches:
- main
- Children:
- 00f669b
- Parents:
- 914eb9f
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r914eb9f rd988fa0 714 714 } 715 715 716 // Send a Like or Announce (boost) on a remote note FROM this site. 717 export async function sendInteraction(site, kind, targetNoteId, authorUri) { 718 const base = (process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, ''); 719 if (!base || !site || !site.slug || !targetNoteId) return { error: 'config' }; 720 const type = kind === 'boost' ? 'Announce' : 'Like'; 721 const me = actorId(base, site.slug); 722 const keys = getOrCreateKeys(site.slug); 723 const act = { 724 '@context': 'https://www.w3.org/ns/activitystreams', 725 id: `${me}#${type.toLowerCase()}-${Date.now()}`, 726 type, actor: me, object: targetNoteId, 727 }; 728 if (type === 'Announce') { act.to = [PUBLIC]; act.cc = [`${me}/followers`]; } 729 const inboxes = new Set(); 730 if (authorUri) { const a = await fetchActor(authorUri).catch(() => null); if (a) inboxes.add((a.endpoints && a.endpoints.sharedInbox) || a.inbox); } 731 // A boost is public → also deliver to our own followers so it shows for them. 732 if (type === 'Announce') { for (const f of fStmts().list.all(site.slug)) inboxes.add(f.shared_inbox || f.inbox); } 733 let delivered = 0; 734 for (const inbox of [...inboxes].filter(Boolean)) { try { const st = await deliver(inbox, act, `${me}#main-key`, keys.private_pem); if (st >= 200 && st < 300) delivered++; } catch { /* best-effort */ } } 735 console.log('[AP]', type, site.slug, '→', targetNoteId, 'delivered', delivered); 736 return { ok: true, delivered }; 737 } 738 716 739 export default { 717 740 getOrCreateKeys, apWants, sendAP, actorId, noteId, … … 720 743 getInteractions, getInteractionById, buildReplyNote, getOutboxNote, deliverReply, resolveRemoteNote, 721 744 listOutbox, deliverOutboxDelete, 722 webfingerResolve, followActor, unfollowActor, listFollowing, getTimeline, 745 webfingerResolve, followActor, unfollowActor, listFollowing, getTimeline, sendInteraction, 723 746 };
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)