openvibers/openvibe.community Commits

Feed: a go-live that is over is a stream card (#312)

OP OpenVibers committed 4 days ago · 06ecb2e6e2 · 2 files, +6 −5

Clients on openvibe-shared 4.163 draw LIVE on every kind "live" card; a go-live whose channel is not on Live's live list
now comes as kind "stream" (live_now false), so nothing says LIVE three days later. The Live filter still finds both.

Changes

ddiff --git a/server/pulse/feed.js b/server/pulse/feed.js
iindex b6f6b9b..252eab1 100644
---- a/server/pulse/feed.js
++++ b/server/pulse/feed.js
@@@ -7,7 +7,7 @@
* a meme, an update…) with the network's trending pictures and videos (Network's Frame cards) woven into the first page.
*
* GET /?kind=live|clip|video|pic|post|meme|game|update&cursor=<opaque>&limit= anyone (the signed-in person too)
-- * → { items: [{ id, kind, url, title, text, at, site, site_name, actor: { name, avatar } | null,
++ * → { items: [{ id, kind (live while on air; a go-live that is over is "stream"), url, title, text, at, site, site_name, actor: { name, avatar } | null,
* media: { thumb, ratio, length } | null, counts: {}, live_now? }], next_cursor } live_now: on Live's live list now
*
* Text only (the client draws every field as text); https links only; nothing from Frame without a picture and a title.
@@@ -104,7 +104,8 @@ function createFeedApi({ pulse, viewers, limits, networkUrl = 'https://openvibe.
const trending = createTrending({ networkUrl, fetchImpl });
const liveNow = createLiveNow({ liveUrl, fetchImpl });
// A "went live" item is live now only while that channel is on Live's live list.
-- const mark = (cards, live) => cards.forEach((c) => { if (c.kind === 'live') c.live_now = live.has(channelOf(c.url).toLowerCase()); });
++ // A go-live that is over is a stream that happened (kind "stream"): clients draw LIVE only on kind "live".
++ const mark = (cards, live) => cards.forEach((c) => { if (c.kind === 'live') { c.live_now = live.has(channelOf(c.url).toLowerCase()); if (!c.live_now) c.kind = 'stream'; } });
router.get('/', run(async (req) => {
const kind = KINDS.includes(String(req.query.kind || '')) ? String(req.query.kind) : '';
ddiff --git a/test/feed-api.test.js b/test/feed-api.test.js
iindex 277ece3..866d1e3 100644
---- a/test/feed-api.test.js
++++ b/test/feed-api.test.js
@@@ -60,9 +60,9 @@ const feedFetch = async (url) => ({ ok: /\/api\/(frame|streams)/.test(String(url
assert.strictEqual((await mk('s1', 'ada')).status, 201);
assert.strictEqual((await mk('s2', 'bo')).status, 201);
const j = (await t.get('/api/v1/feed?kind=live')).json();
-- const by = Object.fromEntries(j.items.map((x) => [x.url, x.live_now]));
-- assert.strictEqual(by['https://openvibe.live/@ada'], true, 'ada is on the live list');
-- assert.strictEqual(by['https://openvibe.live/@bo'], false, 'bo went live earlier and is not live now');
++ const by = Object.fromEntries(j.items.map((x) => [x.url, [x.kind, x.live_now]]));
++ assert.deepStrictEqual(by['https://openvibe.live/@ada'], ['live', true], 'ada is on the live list');
++ assert.deepStrictEqual(by['https://openvibe.live/@bo'], ['stream', false], 'bo went live earlier: a stream that happened, never LIVE');
});
await check('a kind filters the stream', async () => {