|
|
@ -54,9 +54,13 @@ class WebpageScreenshotJob extends SiteWorkerProcess { |
|
|
|
await super.stop(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Expected job data parameters: modelName, documentId, documentPath, pageUrl. |
|
|
|
* @param {Job} job the Bull Queue job to be processed |
|
|
|
*/ |
|
|
|
async processWebpageScreenshot (job) { |
|
|
|
const { image: imageService } = this.dtp.services; |
|
|
|
const { modelName, documentId, pageUrl } = job.data; |
|
|
|
const { modelName, documentId, documentPath, pageUrl } = job.data; |
|
|
|
|
|
|
|
const model = mongoose.model(modelName); |
|
|
|
if (!model) { |
|
|
@ -105,14 +109,9 @@ class WebpageScreenshotJob extends SiteWorkerProcess { |
|
|
|
job.data.screenshotImage = await imageService.create(job.data.semitism.author, imageDefinition, imageFile); |
|
|
|
|
|
|
|
this.jobLog(job, 'updating document with screenshot image'); |
|
|
|
await model.updateOne( |
|
|
|
{ _id: documentId }, |
|
|
|
{ |
|
|
|
$set: { |
|
|
|
'attachments.screenshot': job.data.screenshotImage._id, |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
const updateOp = { $set: { } }; |
|
|
|
updateOp.$set[documentPath] = job.data.screenshotImage._id; |
|
|
|
await model.updateOne({ _id: documentId }, updateOp); |
|
|
|
|
|
|
|
this.jobLog(job, 'screenshot captured and processed successfully'); |
|
|
|
|
|
|
|