Changeset fda08c2 in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 06/26/2026 01:26:39 PM (2 months ago)
- Branches:
- main
- Children:
- 73045f9
- Parents:
- 98ceadd
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r98ceadd rfda08c2 666 666 const media = JSON.stringify(_atts); 667 667 // "Feature" = show in the Cirkel (local only). We do NOT auto-Announce 668 // incoming posts to the fediverse — that flooded followers (esp. onthe669 // initial backfill). Boosting to the fediverse is a deliberate, one-time670 // "boost the latest 5" action at feature time (see boostLatestN).668 // incoming posts to the fediverse — that flooded followers. Boosting to the 669 // fediverse is only ever a deliberate, manual per-post action (the 🔁 on 670 // the timeline). 671 671 for (const s of subs) { 672 672 tlStmts().ins.run(o.id, s.slug, actorUri, ai.name, ai.handle, ai.icon, ai.url, html, o.url || null, o.published || null, media); … … 1244 1244 } 1245 1245 1246 // One-time "boost the latest N posts" of an account to the fediverse — the1247 // deliberate, bounded alternative to auto-boosting every post. Opt-in at feature1248 // time so featuring an artist never floods your followers with their whole backlog.1249 export async function boostLatestN(site, actorUrl, n = 5) {1250 try {1251 const actor = await fetchActor(actorUrl).catch(() => null);1252 if (!actor || !actor.outbox) return { ok: false, boosted: 0 };1253 const getJson = async (u) => { try { const r = await fetch(u, { headers: { Accept: 'application/activity+json' } }); return r.ok ? await r.json() : null; } catch { return null; } };1254 let coll = await getJson(actor.outbox);1255 let items = (coll && coll.orderedItems) || [];1256 if (!items.length && coll && coll.first) {1257 const page = typeof coll.first === 'string' ? await getJson(coll.first) : coll.first;1258 items = (page && page.orderedItems) || [];1259 }1260 const noteIds = items1261 .filter((it) => it && it.type === 'Create' && it.object)1262 .map((it) => (typeof it.object === 'string' ? it.object : it.object.id))1263 .filter(Boolean)1264 .slice(0, n); // outbox is newest-first → the latest N1265 let boosted = 0;1266 for (const id of noteIds) { try { const r = await sendInteraction(site, 'boost', id, actorUrl); if (r && r.ok) boosted++; } catch { /* best-effort */ } }1267 return { ok: true, boosted };1268 } catch { return { ok: false, boosted: 0 }; }1269 }1270 1271 1246 // Notifications inbox: new followers + replies/likes/boosts on this site's posts. 1272 1247 export function getNotifications(slug, limit) { … … 1355 1330 listOutbox, deliverOutboxDelete, 1356 1331 webfingerResolve, followActor, resolveRemoteActor, unfollowActor, listFollowing, setAutoBoost, getTimeline, sendInteraction, 1357 autoBoostCount, boostedCount, markBoosted, unmarkBoosted, getCirkelPosts, getCirkelMembers, selfHealTimeline, boostLatestN,1332 autoBoostCount, boostedCount, markBoosted, unmarkBoosted, getCirkelPosts, getCirkelMembers, selfHealTimeline, 1358 1333 getNotifications, listBlocks, isBlockedAny, blockTarget, unblock, 1359 1334 deliverWithRetry, enqueueDelivery, processDeliveryQueue, startDeliveryWorker,
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)