openvibers/openvibe.network Commits

Feed: a live card shows the stream's own picture (#1227)

OP OpenVibers committed 5 h ago · ee2dfccee2 · 2 files, +11 −1

Plan §I.2 ("thumbnails on live cards"). On production 5 of 27 live-stream cards in the last two weeks had a picture:
the go-live event comes before any frame. The card's picture is now Live's stable address for that stream's live frame
(https://openvibe.live/api/thumbnails/stream-<id>-live.jpg, whatever the newest capture is), so it fills in as soon as
Live takes one and follows the stream while it runs. Where it does not answer (no frame yet, or cleared an hour after
the end) Shared's card shows the site's art. No stream id, no picture. Test: feed.

Changes

ddiff --git a/server/feed/events.js b/server/feed/events.js
iindex 6a073705..8f56547d 100644
---- a/server/feed/events.js
++++ b/server/feed/events.js
@@@ -91,9 +91,15 @@ function eventToItems(event) {
if (!url) return { items: [], remove: [] };
const who = userOf(channel.subject) || actor;
const name = clean(channel.display_name || channel.username, 80) || 'A channel';
++ // The stream's own picture (plan §I.2 "thumbnails on live cards"; 12-01: 5 of 27 stream cards had one): Live's
++ // stable address for whatever that stream's live frame is now (media-proxy/thumbnails.js stream-<id>-live.jpg).
++ // A card whose picture does not answer (the frame not taken yet, or cleared an hour after the end) shows the
++ // site's art instead (Shared ov-home.js).
++ const sid = Number(p.stream_id);
++ const thumb = Number.isSafeInteger(sid) && sid > 0 ? `https://openvibe.live/api/thumbnails/stream-${sid}-live.jpg` : null;
return { items: [item({ service: 'live', type: 'stream', id: idOf(event, p, 'stream_id') || String(channel.username || 'live'), kind: 'live',
title: p.title ? `${name} went live: ${clean(p.title, 160)}` : `${name} went live`, url,
-- subject: who, at: p.started_at || at, live_now: true })], remove: [] };
++ subject: who, at: p.started_at || at, live_now: true, ...(thumb ? { media: { thumb } } : {}) })], remove: [] };
}
if (type === 'mediahub.video.published') {
const url = urlOf(p);
ddiff --git a/test/feed.test.js b/test/feed.test.js
iindex 43592855..f2ccc7b6 100644
---- a/test/feed.test.js
++++ b/test/feed.test.js
@@@ -52,6 +52,10 @@ const envelope = (type, payload, over = {}) => ({
assert.deepStrictEqual(eventToItems(envelope('space.deploy.activated', { site_id: 'sit_1', site: 'Bad Name!', deploy_id: 'dpl_3', rollback: false })).items, [], 'no address, no card');
assert.deepStrictEqual(eventToItems(envelope('live.stream.started', { channel: { username: 'alex', url: 'https://openvibe.live/@alex' } }, { visibility: 'internal' })).items, [], 'a non-public event never enters the feed');
assert.deepStrictEqual(eventToItems(envelope('wiki.page.deleted', { page_id: 'w1' })).remove[0], { service: 'wiki', type: 'post', id: 'w1' });
++ // A live card carries the stream's live frame (12-01, plan §I.2: 5 of 27 had a picture); no stream id, no picture.
++ const golive = eventToItems(envelope('live.stream.started', { stream_id: 3149, channel: { username: 'alex', url: 'https://openvibe.live/@alex' } })).items[0];
++ assert.strictEqual(golive.picture_url, 'https://openvibe.live/api/thumbnails/stream-3149-live.jpg');
++ assert.strictEqual(eventToItems(envelope('live.stream.started', { channel: { username: 'alex', url: 'https://openvibe.live/@alex' } })).items[0].picture_url, undefined);
// ── grouping: a run becomes one card, work per hour ──────
const card = (over) => cardOf({ source_service: 'live', source_type: 'recording', source_id: over.id || 'r', kind: 'video', title: over.title || 'Recording', text: '', url: over.url || 'https://openvibe.video/watch?v=1', site: 'live', site_name: 'Live', actor_subject: over.subject || A, counts: {}, occurred_at: over.at || iso(now), media_ratio: null }, { name: 'Alex', avatar: null });