Changeset 749605a in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 08/16/2026 03:06:18 PM (3 weeks ago)
- Branches:
- main
- Children:
- a5caa73
- Parents:
- a5515b4 (diff), 9026de5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
ra5515b4 r749605a 34 34 // De muziekkant woont in music/ (shaer-drc). Doorgeven wat hier altijd 35 35 // vandaan kwam, zodat elke bestaande aanroep blijft werken. 36 import { luisteraars } from './music/index.js'; 36 37 import { TRACK_KOLOMMEN, 37 38 playlistOpenTracks, siteOpenTracks, openTrack, trackHostPosts, … … 39 40 buildPlaylistCollection, listPlaylistsAP, playlistLinkTags, 40 41 buildPostTrackCollection, uitgavePost, 42 buildLibrary, libraryId, 41 43 licentieUri, channelCategory, 42 44 } from './music/index.js'; … … 46 48 buildPlaylistCollection, listPlaylistsAP, playlistLinkTags, licentieUri, 47 49 buildPostTrackCollection, uitgavePost, 50 buildLibrary, libraryId, 48 51 }; 49 52 … … 354 357 const pagina = pickLink(o.url, () => true); 355 358 return { html: HtmlSanitizerService.sanitize(o.content || ''), atts, url: pagina ? pagina.href : null }; 359 } 360 361 /** 362 * De site achter een library-uri, of null. Zelfde strengheid als localSlugOf: 363 * de uri moet met ONZE basis beginnen en de site moet bestaan -- anders levert 364 * andermans /library met dezelfde padstaart hier een volger op onze naam op. 365 */ 366 function libraryOwnerSlug(uri) { 367 const u = String(uri || ''); 368 if (!u.endsWith('/library')) return null; 369 return localSlugOf(u.slice(0, -'/library'.length)); 356 370 } 357 371 … … 1186 1200 // these as the "Featured" tab (pinned to the profile). Posts come ordered by pin 1187 1201 // rank; embedded as full Notes so a remote server doesn't need extra fetches. 1188 export function buildFeatured(base, site, posts ) {1202 export function buildFeatured(base, site, posts, { page = false } = {}) { 1189 1203 const id = `${actorId(base, site.slug)}/featured`; 1190 1204 const items = (posts || []).map((p) => buildNote(base, site, p)); 1191 return pagedCollection(id, items );1205 return pagedCollection(id, items, { page }); 1192 1206 } 1193 1207 … … 2354 2368 if (type === 'Follow') { 2355 2369 const who = typeof act.actor === 'string' ? act.actor : (act.actor && act.actor.id); 2370 // EERST: volgt iemand onze BIBLIOTHEEK in plaats van onze actor? (shaer-0nh) 2371 // 2372 // Een luisteraar krijgt de muziek en NIET de gewone posts -- wie zich 2373 // abonneert op een platenkast heeft niet om de Krant gevraagd. Vandaar een 2374 // eigen tabel: zolang ze daar staan kan een postbezorging ze niet per 2375 // ongeluk meenemen. 2376 // 2377 // De bibliotheek is openbaar (alles erin is fedi_open), dus dit accepteert 2378 // meteen. Er valt niets goed te keuren, en dan is wachten oneerlijk. 2379 const libSlug = libraryOwnerSlug(typeof act.object === 'string' ? act.object : (act.object && act.object.id)); 2380 if (who && libSlug) { 2381 const remote = await fetchActor(who); 2382 if (!remote || !remote.inbox) return 202; 2383 const fi = actorInfo(remote, who); 2384 luisteraars.voegToe(libSlug, { 2385 actorUri: who, inbox: remote.inbox, 2386 sharedInbox: (remote.endpoints && remote.endpoints.sharedInbox) || null, 2387 name: fi.name, handle: fi.handle, icon: fi.icon, 2388 }); 2389 const keys = getOrCreateKeys(libSlug); 2390 const accept = { 2391 '@context': AP_CONTEXT, 2392 id: `${actorId(base, libSlug)}#accept-library-${Date.now()}-${rid()}`, 2393 type: 'Accept', actor: actorId(base, libSlug), object: act, 2394 }; 2395 deliver(remote.inbox, accept, `${actorId(base, libSlug)}#main-key`, keys.privatePem) 2396 .catch(() => { /* de volger staat er; een mislukte Accept mag dat niet omgooien */ }); 2397 console.log('[AP] library follow from', who, '->', libSlug); 2398 return 202; 2399 } 2356 2400 // slugParam is de eigenaar van een per-actor inbox; op de GEDEELDE inbox is 2357 2401 // die er niet en werd de slug uit act.object geraden. Zonder hostcontrole … … 2437 2481 return 202; 2438 2482 } 2483 // Een luisteraar die weggaat, hoort meteen weg te zijn. 2484 if (type === 'Undo' && act.object && act.object.type === 'Follow') { 2485 const doel = typeof act.object.object === 'string' ? act.object.object : (act.object.object && act.object.object.id); 2486 const libSlug = libraryOwnerSlug(doel); 2487 const wie = typeof act.actor === 'string' ? act.actor : (act.actor && act.actor.id); 2488 if (libSlug && wie && luisteraars.verwijder(libSlug, wie)) { 2489 console.log('[AP] library unfollow from', wie, '->', libSlug); 2490 return 202; 2491 } 2492 } 2493 2439 2494 if (type === 'Undo' && act.object) { 2440 2495 const who = typeof act.actor === 'string' ? act.actor : (act.actor && act.actor.id); … … 6809 6864 buildPlaylistCollection, playlistOpenTracks, listPlaylistsAP, playlistLinkTags, 6810 6865 buildPostTrackCollection, uitgavePost, 6866 buildLibrary, libraryId, 6811 6867 followerCount, deliver, fetchActor, verifyRequest, handleInbox, deliverCreate, deliverDelete, deliverUpdate, deliverActorUpdate, resyncFeaturedPins, 6812 6868 feedCursor, feedChangesSince, waitForFeedChange,
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)