parent
1458e4126b
commit
9a35bd60e1
@ -0,0 +1,29 @@
|
||||
const { Job } = require('flitter-jobs')
|
||||
|
||||
class PopulateAnnouncementJob extends Job {
|
||||
static get services() {
|
||||
return [...super.services, 'models', 'output']
|
||||
}
|
||||
|
||||
async execute(job) {
|
||||
const { data } = job
|
||||
const { announcement_id } = data
|
||||
|
||||
try {
|
||||
const Announcement = this.models.get('system:Announcement')
|
||||
const announcement = await Announcement.findById(announcement_id)
|
||||
|
||||
if ( !announcement ) {
|
||||
this.output.error(`Unable to find announcement with ID: ${announcement_id}`)
|
||||
throw new Error('Unable to find announcement with that ID.')
|
||||
}
|
||||
|
||||
await announcement.populate()
|
||||
this.output.success('Populated announcements.')
|
||||
} catch (e) {
|
||||
this.output.error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = PopulateAnnouncementJob
|
Loading…
Reference in new issue