Changeset e27b8db in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 07/29/2026 10:04:36 AM (6 weeks ago)
- Branches:
- main
- Children:
- 329873e
- Parents:
- 88d7c8f
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r88d7c8f re27b8db 3043 3043 3044 3044 /** The stored external-embed card, for the C2S read. */ 3045 export function timelineEmbed(embedJson) { 3046 try { const e = embedJson ? JSON.parse(embedJson) : null; return (e && typeof e === 'object' && e.url) ? e : undefined; } 3047 catch { return undefined; } 3045 export function timelineEmbed(embedJson, { playback = false } = {}) { 3046 try { 3047 const e = embedJson ? JSON.parse(embedJson) : null; 3048 if (!e || typeof e !== 'object' || !e.url) return undefined; 3049 // The player URL is served ONLY when the playback gate is open (FEP-633c 3050 // 5.6). Deciding it here keeps the provider knowledge in one place: the 3051 // client never needs a list of hosts, it just plays what it is handed. 3052 // Privacy-enhanced variants only: nocookie for YouTube, the instance's own 3053 // player for PeerTube. Without one the card stays a thumbnail. 3054 const player = playback ? playerUrlFor(e.url) : null; 3055 return player ? { ...e, 'shaer:playerUrl': player } : e; 3056 } catch { return undefined; } 3057 } 3058 3059 /** The embeddable player for a URL, or null when we will not frame it. */ 3060 export function playerUrlFor(url) { 3061 if (typeof url !== 'string') return null; 3062 let p = null; 3063 try { p = AudioEmbedService.detectProvider(url); } catch { p = null; } 3064 if (p && p.provider === 'youtube' && p.id) return `https://www.youtube-nocookie.com/embed/${p.id}?rel=0&modestbranding=1&playsinline=1`; 3065 if (p && p.provider === 'vimeo' && p.id) return `https://player.vimeo.com/video/${p.id}`; 3066 // PeerTube is decentralised, so it is matched by its watch-URL shape rather 3067 // than a provider list. Host chars are validated before it is inlined. 3068 const pt = url.match(/^https?:\/\/([\w.-]+(?::\d+)?)\/(?:w|videos\/watch)\/([\w-]{6,})/i); 3069 if (pt) return `https://${pt[1]}/videos/embed/${pt[2]}`; 3070 return null; 3048 3071 } 3049 3072 … … 3877 3900 getReplyUris, markNotificationsSeen, countUnseenNotifications, hasPlayableAudio, 3878 3901 linkifyBody, bakePostContent, bakePostContentWithMentions, listFollowers, removeFollower, listConnections, 3879 noteVisibility, belongsInTimeline, isRejectedObject, rejectInteraction, interactionReportTarget,3902 noteVisibility, belongsInTimeline, playerUrlFor, isRejectedObject, rejectInteraction, interactionReportTarget, 3880 3903 getMessages, notificationsSeenAt, ingestOutboxActivity, c2sVisibility, actorDisplay, buildActorRef, prefersEnriched, 3881 3904 };
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)