Changeset aed0092 in Klonkt for src/services/music
- Timestamp:
- 08/11/2026 06:35:19 PM (4 weeks ago)
- Branches:
- main
- Children:
- 960f015
- Parents:
- cb3001e
- File:
-
- 1 edited
-
src/services/music/index.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/music/index.js
rcb3001e raed0092 14 14 15 15 import db from '../../config/database.js'; 16 import { AP_CONTEXT, PUBLIC, actorId, noteId, safeUrl, guessMediaType, buildHashtagList } from '../ap-core.js';16 import { AP_CONTEXT, PUBLIC, actorId, noteId, safeUrl, guessMediaType, buildHashtagList, pagedCollection } from '../ap-core.js'; 17 17 import { afleidenUitInsluitingen, ingeslotenPlaylists } from '../../assets/js/shared/post-music-type.js'; 18 18 … … 201 201 /** De collectie van alle open tracks van een site (shaer-0nh, stap 3). */ 202 202 export function buildTrackCollection(base, site, rows) { 203 return { 204 '@context': AP_CONTEXT, 205 id: `${actorId(base, site.slug)}/tracks`, 206 type: 'OrderedCollection', 207 attributedTo: actorId(base, site.slug), 208 totalItems: (rows || []).length, 209 // Eén zoekopdracht voor alle rijen samen; zie trackHostPosts. 210 orderedItems: (() => { 211 const posts = site.id ? trackHostPosts(site.id) : null; 212 return (rows || []).map((r) => buildTrackAudio(base, site, r, { hostPosts: posts })); 213 })(), 214 }; 203 // Eén zoekopdracht voor alle rijen samen; zie trackHostPosts. 204 const posts = site.id ? trackHostPosts(site.id) : null; 205 const items = (rows || []).map((r) => buildTrackAudio(base, site, r, { hostPosts: posts })); 206 return pagedCollection(`${actorId(base, site.slug)}/tracks`, items, { extra: { attributedTo: actorId(base, site.slug) } }); 215 207 } 216 208 … … 270 262 return stub; 271 263 }); 272 return { 273 '@context': AP_CONTEXT, 274 id: colId, 275 type: 'OrderedCollection', 276 attributedTo: actorId(base, site.slug), 277 totalItems: items.length, 278 orderedItems: items, 279 }; 264 return pagedCollection(colId, items, { extra: { attributedTo: actorId(base, site.slug) } }); 280 265 } 281 266 … … 289 274 const hostPosts = site.id ? trackHostPosts(site.id) : null; 290 275 const items = (rows || []).map((r) => buildTrackAudio(base, site, r, { coverFallback: playlist.cover_url || null, hostPosts })); 291 const out = { 292 '@context': AP_CONTEXT, 293 id: `${actorId(base, site.slug)}/playlists/${playlist.id}`, 294 type: 'OrderedCollection', 295 name: playlist.title, 296 attributedTo: actorId(base, site.slug), 297 totalItems: items.length, 298 orderedItems: items, 299 }; 276 const out = pagedCollection(`${actorId(base, site.slug)}/playlists/${playlist.id}`, items, { 277 extra: { name: playlist.title, attributedTo: actorId(base, site.slug) }, 278 }); 300 279 // Album of playlist is presentatie; op de draad is het één samenvattingsveld. 301 280 const parts = []; … … 449 428 450 429 const hostPosts = new Map(rows.map((r) => [r.id, { id: post.id, slug: post.slug }])); 451 const out = { 452 '@context': AP_CONTEXT, 453 id: postTracksId(base, site, post.id), 454 type: 'OrderedCollection', 455 attributedTo: actorId(base, site.slug), 456 totalItems: rows.length, 457 orderedItems: rows.map((r) => buildTrackAudio(base, site, r, { hostPosts })), 458 }; 430 const out = pagedCollection(postTracksId(base, site, post.id), 431 rows.map((r) => buildTrackAudio(base, site, r, { hostPosts })), 432 { extra: { attributedTo: actorId(base, site.slug) } }); 459 433 return leenVanPost(base, site, out, post); 460 434 }
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)