openvibers/openvibe.live Commits
AI moment pastes name the streamer: Media's VOD list gives only the owner's id, so the footer read '@null's stream' (478 pastes) (#305)
Changes
@@@ -269,6 +269,10 @@ async function _momentPool(limit) {if (rows.length) {return (await Promise.all(rows.map(async (v) => {const state = (db.getVodAiState && await db.getVodAiState(v.id)) || {};++ // Media's list names the owner by id only: the moment's footer and title name them by username++ // (pastes read "@null's stream" without it).++ let username = v.username || null;++ if (!username && v.user_id) { try { username = (await db.getUserById(v.user_id))?.username || null; } catch { /* */ } }let memory_count = 0, peak_viewers = 0;if (v.stream_id) {try { memory_count = (await db.get('SELECT COUNT(*) AS c FROM stream_memories WHERE stream_id = ?', [v.stream_id]))?.c || 0; } catch { /* */ }@@@ -276,7 +280,7 @@ async function _momentPool(limit) {}return {vod_id: v.id, stream_id: v.stream_id || null, user_id: v.user_id || null,-- username: v.username || null, title: v.title || '',++ username, title: v.title || '',ai_overview: state.ai_overview_short || v.ai_overview_short || '',ai_overview_short: state.ai_overview_short || v.ai_overview_short || '',view_count: Number(v.view_count) || 0,@@@ -422,7 +426,7 @@ async function tick(opts = {}) {continue;}if (finalSig) thisSigs.add(finalSig);-- const content = `${desc}\n\n▶ Watch this moment on @${v.username}'s stream: ${vodLink}`;++ const content = `${desc}\n\n▶ Watch this moment on ${v.username ? `@${v.username}'s stream` : 'the stream'}: ${vodLink}`;const metadata = JSON.stringify({ ai_moment: true, vod_id: v.vod_id, offset, vod_link: vodPath, username: v.username, why: r.why || null });let pasteSlug = slug;try {@@@ -160,6 +160,8 @@ async function check(name, fn) {await check("the AI moments job never picks an opted-out channel's VODs", async () => {const pool = await moments._internals.momentPool(10);assert.deepStrictEqual(pool.map((v) => v.vod_id), [10]);++ // Media's list names the owner by id only: the pool names them by username (pastes read "@null's stream").++ assert.strictEqual(pool[0].username, 'alice');});await check('no "caught live" paste from an opted-out stream', async () => {
@@ -269,6 +269,10 @@ async function _momentPool(limit) {
@@ -269,6 +269,10 @@ async function _momentPool(limit) {
if (rows.length) {
if (rows.length) {
return (await Promise.all(rows.map(async (v) => {
return (await Promise.all(rows.map(async (v) => {
const state = (db.getVodAiState && await db.getVodAiState(v.id)) || {};
const state = (db.getVodAiState && await db.getVodAiState(v.id)) || {};
+ // Media's list names the owner by id only: the moment's footer and title name them by username
+ // (pastes read "@null's stream" without it).
+ let username = v.username || null;
+ if (!username && v.user_id) { try { username = (await db.getUserById(v.user_id))?.username || null; } catch { /* */ } }
let memory_count = 0, peak_viewers = 0;
let memory_count = 0, peak_viewers = 0;
if (v.stream_id) {
if (v.stream_id) {
try { memory_count = (await db.get('SELECT COUNT(*) AS c FROM stream_memories WHERE stream_id = ?', [v.stream_id]))?.c || 0; } catch { /* */ }
try { memory_count = (await db.get('SELECT COUNT(*) AS c FROM stream_memories WHERE stream_id = ?', [v.stream_id]))?.c || 0; } catch { /* */ }
@@ -276,7 +280,7 @@ async function _momentPool(limit) {
@@ -276,7 +280,7 @@ async function _momentPool(limit) {
}
}
return {
return {
vod_id: v.id, stream_id: v.stream_id || null, user_id: v.user_id || null,
vod_id: v.id, stream_id: v.stream_id || null, user_id: v.user_id || null,
- username: v.username || null, title: v.title || '',
+ username, title: v.title || '',
ai_overview: state.ai_overview_short || v.ai_overview_short || '',
ai_overview: state.ai_overview_short || v.ai_overview_short || '',
ai_overview_short: state.ai_overview_short || v.ai_overview_short || '',
ai_overview_short: state.ai_overview_short || v.ai_overview_short || '',
view_count: Number(v.view_count) || 0,
view_count: Number(v.view_count) || 0,
@@ -422,7 +426,7 @@ async function tick(opts = {}) {
@@ -422,7 +426,7 @@ async function tick(opts = {}) {
continue;
continue;
}
}
if (finalSig) thisSigs.add(finalSig);
if (finalSig) thisSigs.add(finalSig);
- const content = `${desc}\n\n▶ Watch this moment on @${v.username}'s stream: ${vodLink}`;
+ const content = `${desc}\n\n▶ Watch this moment on ${v.username ? `@${v.username}'s stream` : 'the stream'}: ${vodLink}`;
const metadata = JSON.stringify({ ai_moment: true, vod_id: v.vod_id, offset, vod_link: vodPath, username: v.username, why: r.why || null });
const metadata = JSON.stringify({ ai_moment: true, vod_id: v.vod_id, offset, vod_link: vodPath, username: v.username, why: r.why || null });
let pasteSlug = slug;
let pasteSlug = slug;
try {
try {
@@ -160,6 +160,8 @@ async function check(name, fn) {
@@ -160,6 +160,8 @@ async function check(name, fn) {
await check("the AI moments job never picks an opted-out channel's VODs", async () => {
await check("the AI moments job never picks an opted-out channel's VODs", async () => {
const pool = await moments._internals.momentPool(10);
const pool = await moments._internals.momentPool(10);
assert.deepStrictEqual(pool.map((v) => v.vod_id), [10]);
assert.deepStrictEqual(pool.map((v) => v.vod_id), [10]);
+ // Media's list names the owner by id only: the pool names them by username (pastes read "@null's stream").
+ assert.strictEqual(pool[0].username, 'alice');
});
});
await check('no "caught live" paste from an opted-out stream', async () => {
await check('no "caught live" paste from an opted-out stream', async () => {