SAML; Dashboard
This commit is contained in:
39
app/models/Message.model.js
Normal file
39
app/models/Message.model.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { Model } = require('flitter-orm')
|
||||
|
||||
class MessageModel extends Model {
|
||||
static get schema() {
|
||||
return {
|
||||
dismissed: {type: Boolean, default: false},
|
||||
expires: {type: Date, default: () => {
|
||||
const date = new Date
|
||||
date.setYear(date.getUTCFullYear() + 1)
|
||||
return date
|
||||
}},
|
||||
display_type: {type: String, default: 'info'},
|
||||
message: String,
|
||||
user_id: String,
|
||||
}
|
||||
}
|
||||
|
||||
static async for_user(user) {
|
||||
return this.find({ user_id: user.id, dismissed: false, expires: { $gt: new Date } })
|
||||
}
|
||||
|
||||
static async create(user, message, display_type = 'info') {
|
||||
const msg = new this({
|
||||
message,
|
||||
display_type,
|
||||
user_id: user.id,
|
||||
})
|
||||
|
||||
await msg.save()
|
||||
return msg
|
||||
}
|
||||
|
||||
async dismiss() {
|
||||
this.dismissed = true
|
||||
return this.save()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = MessageModel
|
||||
Reference in New Issue
Block a user