Changeset 292734a in Klonkt


Ignore:
Timestamp:
06/30/2026 01:58:06 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
28b59e7
Parents:
2306abd
Message:

refactor(federation): specific AS2 media types (Image/Audio) for attachments, not generic Document

AS2 has dedicated Image/Audio/Video subtypes; we emitted generic Document + mediaType for both
image and audio attachments. Now emit the specific type (derived from mediaType), keeping
mediaType as the interop safety net. More spec-canonical (matches PeerTube/Funkwhale's Video/
Audio); Image/Audio/Video are AS2-core so the shared @context + the AS2 validity test still pass.

  • src/services/ActivityPubService.js — attachment type from mediaType (fedi_open audio → Audio, images → Image)

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    r2306abd r292734a  
    255255      const fn = r.filename || (r.storage_path || '').split('/').pop();
    256256      if (!fn || seenA.has(fn)) return; seenA.add(fn);
    257       openAudio.push({ type: 'Document', mediaType: r.mime_type || 'audio/mpeg', url: `${base}/audio/stream/${encodeURIComponent(fn)}`, name: r.title || 'Audio' });
     257      openAudio.push({ type: 'Audio', mediaType: r.mime_type || 'audio/mpeg', url: `${base}/audio/stream/${encodeURIComponent(fn)}`, name: r.title || 'Audio' });
    258258    };
    259259    const SEL = 'SELECT t.title, m.filename, m.storage_path, m.mime_type FROM audio_tracks t JOIN media m ON m.id = t.media_id WHERE t.fedi_open = 1 AND ';
     
    301301  const attachment = urls.filter(Boolean)
    302302    .filter((u) => { if (seen.has(u)) return false; seen.add(u); return true; })
    303     .map((u) => ({ type: 'Document', mediaType: mediaType(u), url: u }));
     303    .map((u) => { const mt = mediaType(u); // specific AS2 subtype (Image/Audio/Video) over generic Document
     304      const ty = /^image\//i.test(mt) ? 'Image' : /^video\//i.test(mt) ? 'Video' : /^audio\//i.test(mt) ? 'Audio' : 'Document';
     305      return { type: ty, mediaType: mt, url: u }; });
    304306  for (const a of openAudio) attachment.push(a); // fedi_open tracks → native Audio players
    305307
Note: See TracChangeset for help on using the changeset viewer.