openvibers/openvibe.chat Commits
Chat: a room with nobody consenting reads quiet, not an old overview (#482)
Changes
@@@ -42,7 +42,9 @@ function _timeline(events) {}function _shape(row, events) {-- const fresh = !!(row && row.overview && row.window_end && Date.now() - _time(row.window_end) < QUIET_AFTER_MS);++ // A summary written from nobody's messages is not a read of the room: zero consenting people means++ // quiet, however recent the row is (rows written before the consent filter carry no people count).++ const fresh = !!(row && row.overview && Number(row.people) > 0 && row.window_end && Date.now() - _time(row.window_end) < QUIET_AFTER_MS);const state = fresh ? 'ready' : 'quiet';return {overview: {@@@ -27,6 +27,17 @@ t('a fresh summary is ready and keeps its topics, people and timeline', async ()assert.strictEqual(shaped.overview.from, from);});++t('a fresh summary with nobody consenting is quiet, never served as a read of the room', async () => {++ const now = sqliteNow();++ const shaped = roomInsight._shape({++ overview: 'written before the consent filter', window_start: now, window_end: now, updated_at: now,++ people: 0, window_message_count: 300, topics_json: '[]',++ }, []);++ assert.strictEqual(shaped.state, 'quiet');++ assert.strictEqual(shaped.overview.text, '');++ assert.strictEqual(shaped.overview.messages, 0);++});++t('an old summary is quiet: no text, no topics, the timeline stays', async () => {const old = sqliteNow(-48 * 3600e3);const shaped = roomInsight._shape({
@@ -42,7 +42,9 @@ function _timeline(events) {
@@ -42,7 +42,9 @@ function _timeline(events) {
}
}
function _shape(row, events) {
function _shape(row, events) {
- const fresh = !!(row && row.overview && row.window_end && Date.now() - _time(row.window_end) < QUIET_AFTER_MS);
+ // A summary written from nobody's messages is not a read of the room: zero consenting people means
+ // quiet, however recent the row is (rows written before the consent filter carry no people count).
+ const fresh = !!(row && row.overview && Number(row.people) > 0 && row.window_end && Date.now() - _time(row.window_end) < QUIET_AFTER_MS);
const state = fresh ? 'ready' : 'quiet';
const state = fresh ? 'ready' : 'quiet';
return {
return {
overview: {
overview: {
@@ -27,6 +27,17 @@ t('a fresh summary is ready and keeps its topics, people and timeline', async ()
@@ -27,6 +27,17 @@ t('a fresh summary is ready and keeps its topics, people and timeline', async ()
assert.strictEqual(shaped.overview.from, from);
assert.strictEqual(shaped.overview.from, from);
});
});
+t('a fresh summary with nobody consenting is quiet, never served as a read of the room', async () => {
+ const now = sqliteNow();
+ const shaped = roomInsight._shape({
+ overview: 'written before the consent filter', window_start: now, window_end: now, updated_at: now,
+ people: 0, window_message_count: 300, topics_json: '[]',
+ }, []);
+ assert.strictEqual(shaped.state, 'quiet');
+ assert.strictEqual(shaped.overview.text, '');
+ assert.strictEqual(shaped.overview.messages, 0);
+});
+
t('an old summary is quiet: no text, no topics, the timeline stays', async () => {
t('an old summary is quiet: no text, no topics, the timeline stays', async () => {
const old = sqliteNow(-48 * 3600e3);
const old = sqliteNow(-48 * 3600e3);
const shaped = roomInsight._shape({
const shaped = roomInsight._shape({