Fix log-viewer ignoring screenshotless events
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
2022-02-17 10:25:36 +02:00
parent 066474190d
commit 6370a37e5a
2 changed files with 9 additions and 8 deletions

View File

@@ -46,15 +46,18 @@ async function run() {
});
async function wrapEvent(doc) {
let newDoc;
let screenShotArray = [];
let blob;
if (doc && doc.screenshot_count) {
newDoc = {...doc, screenshots: []}
for (let i = 1; i <= doc.screenshot_count ; i++) {
let presignedUrl = await minioClient.presignedUrl('GET', minioBucket, `${doc.camera}/${doc._id}/${i}.jpg`, 60 * 60);
newDoc.screenshots.push({ url: presignedUrl });
screenShotArray.push({ url: presignedUrl });
}
blob = JSON.stringify({...doc, ...screenShotArray});
} else {
blob = JSON.stringify({...doc})
};
let blob = JSON.stringify(newDoc);
return `event: log-entry\ndata: ${blob}\n\n`
}