openvibers/openvibe.network Commits
Feed: a live card shows the stream's own picture (#1227)
Changes
@@@ -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);@@@ -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 });
@@ -91,9 +91,15 @@ function eventToItems(event) {
@@ -91,9 +91,15 @@ function eventToItems(event) {
if (!url) return { items: [], remove: [] };
if (!url) return { items: [], remove: [] };
const who = userOf(channel.subject) || actor;
const who = userOf(channel.subject) || actor;
const name = clean(channel.display_name || channel.username, 80) || 'A channel';
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',
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,
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') {
if (type === 'mediahub.video.published') {
const url = urlOf(p);
const url = urlOf(p);
@@ -52,6 +52,10 @@ const envelope = (type, payload, over = {}) => ({
@@ -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('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('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' });
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 ──────
// ── 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 });
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 });