openvibers/openvibe.live Commits

Channel search documents go out with priority low (the envelope allows critical, important or low; 'normal' made Events refuse them with 422); the test's stub Events now validates envelopes as Events does

OP OpenVibers committed 25 Sept 2026 · 278a498173 · 2 files, +5 −2


Changes

ddiff --git a/server/events/search-documents.js b/server/events/search-documents.js
iindex c9340844..391c18f1 100644
---- a/server/events/search-documents.js
++++ b/server/events/search-documents.js
@@@ -86,8 +86,8 @@ function publish(userId, { now = Date.now() } = {}) {
const id = String(userId);
d.transaction(() => {
streamEvents.enqueue(doc.deleted
-- ? { event_type: 'live.index_document.deleted', actor: { type: 'service', id: 'live' }, subject: { type: 'channel', id, revision }, visibility: 'internal', priority: 'normal', payload: { type: 'channel', id, revision } }
-- : { event_type: 'live.index_document.upserted', actor: { type: 'service', id: 'live' }, subject: { type: 'channel', id, revision }, visibility: 'internal', priority: 'normal',
++ ? { event_type: 'live.index_document.deleted', actor: { type: 'service', id: 'live' }, subject: { type: 'channel', id, revision }, visibility: 'internal', priority: 'low', payload: { type: 'channel', id, revision } }
++ : { event_type: 'live.index_document.upserted', actor: { type: 'service', id: 'live' }, subject: { type: 'channel', id, revision }, visibility: 'internal', priority: 'low',
payload: { ...doc, revision, updated_at: new Date(now).toISOString() } });
d.prepare(`INSERT INTO search_doc_pushes (user_id, hash, revision, deleted, pushed_at) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)
ON CONFLICT(user_id) DO UPDATE SET hash = excluded.hash, revision = excluded.revision, deleted = excluded.deleted, pushed_at = excluded.pushed_at`)
ddiff --git a/test/search-documents.test.js b/test/search-documents.test.js
iindex 70ca7f3a..0ae34b47 100644
---- a/test/search-documents.test.js
++++ b/test/search-documents.test.js
@@@ -25,6 +25,9 @@ const stub = http.createServer((req, res) => {
if (req.url === '/api/v1/events' && req.method === 'POST') {
const parsed = JSON.parse(body);
const list = parsed.events || [parsed];
++ const { validate } = require('openvibe-contracts');
++ const bad = list.find((e) => !validate('events.event-envelope@1', e).valid);
++ if (bad) { res.statusCode = 422; return res.end(JSON.stringify({ code: 'events.invalid_envelope', errors: validate('events.event-envelope@1', bad).errors })); } // as Events does
const results = list.map((e) => { published.push(e); return { event_id: e.event_id, seq: published.length, duplicate: false }; });
return res.end(JSON.stringify(parsed.events ? { results } : results[0]));
}