37 lines
982 B
JavaScript
37 lines
982 B
JavaScript
const { BeanModel } = require("redbean-node/dist/bean-model");
|
|
const { R } = require("redbean-node");
|
|
const dayjs = require("dayjs");
|
|
|
|
class Incident extends BeanModel {
|
|
/**
|
|
* Resolve the incident and mark it as inactive
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async resolve() {
|
|
this.active = false;
|
|
this.pin = false;
|
|
this.lastUpdatedDate = R.isoDateTime(dayjs.utc());
|
|
await R.store(this);
|
|
}
|
|
|
|
/**
|
|
* Return an object that ready to parse to JSON for public
|
|
* @returns {object} Object ready to parse
|
|
*/
|
|
toPublicJSON() {
|
|
return {
|
|
id: this.id,
|
|
style: this.style,
|
|
title: this.title,
|
|
content: this.content,
|
|
pin: !!this.pin,
|
|
active: !!this.active,
|
|
createdDate: this.createdDate,
|
|
lastUpdatedDate: this.lastUpdatedDate,
|
|
status_page_id: this.status_page_id,
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = Incident;
|