Changeset 30271e6 in Klonkt for src/routes


Ignore:
Timestamp:
06/25/2026 06:13:00 AM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
6c3d805
Parents:
2923a95
Message:

fix(fediverse): player card only for playable (hosted) audio; scope embed strictly

A link-only track (external, media_id NULL) has no hosted audio, so it must not get
a Klonkt player card — and /embed?post= must not fall back to ALL site tracks (that
showed unrelated songs). New hasPlayableAudio() gates the player card + cover-
suppression on a real file-backed track; link-only audio keeps its cover. /embed?post
now scopes strictly to the post's tracks (no all-site fallback).

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

Location:
src/routes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/routes/embed.js

    r2923a95 r30271e6  
    4545        for (const m of post.content.matchAll(/\[\[album:([^\]]+)\]\]/g)) for (const r of db.prepare('SELECT id FROM audio_tracks WHERE site_id = ? AND album = ? ORDER BY position').all(site.id, m[1].trim())) add(r.id);
    4646        for (const m of post.content.matchAll(/\[\[playlist:([A-Za-z0-9_-]+)\]\]/g)) for (const r of db.prepare('SELECT track_id FROM playlist_tracks WHERE playlist_id = ? ORDER BY position').all(m[1])) add(r.track_id);
    47         if (ids.length) {
    48           const byId = new Map(tracks.map((t) => [t.id, t]));
    49           const scoped = ids.map((id) => byId.get(id)).filter(Boolean);
    50           if (scoped.length) tracks = scoped;
    51         }
     47        // Strictly scope to this post's tracks — do NOT fall back to all-site
     48        // tracks (that showed unrelated songs for a link-only-track post).
     49        const byId = new Map(tracks.map((t) => [t.id, t]));
     50        tracks = ids.map((id) => byId.get(id)).filter(Boolean);
    5251      }
    5352    } catch { /* fall back to the full site player */ }
  • src/routes/posts.js

    r2923a95 r30271e6  
    848848    canManageSite,
    849849    siteAvatar,
     850    postHasPlayableAudio: ActivityPubService.hasPlayableAudio(post.content || '', site.id),
    850851    pageTitle: post.title + ' - ' + site.title,
    851852    socialDescr: post.excerpt || '',
Note: See TracChangeset for help on using the changeset viewer.