Add support for login intercept messages and announcements

This commit is contained in:
garrettmills
2020-08-12 22:07:53 -05:00
parent 9a35bd60e1
commit f1bd6e1ad4
6 changed files with 99 additions and 1 deletions

View File

@@ -66,6 +66,8 @@ class AnnouncementModel extends Model {
await this.populate_emails()
} else if ( this.type === 'banner' ) {
await this.populate_banners()
} else if ( this.type === 'login' ) {
await this.populate_logins()
}
}
@@ -92,6 +94,14 @@ class AnnouncementModel extends Model {
await Message.create(user, `${this.title} - ${this.message}`)
}
}
async populate_logins() {
const users = await this.all_users()
const LoginMessage = this.models.get('LoginMessage')
for ( const user of users ) {
await LoginMessage.create(user, this.title, this.message)
}
}
}
module.exports = exports = AnnouncementModel