| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- module.exports = function(crowi) {
- const debug = require('debug')('growi:models:global-notification-setting');
- const mongoose = require('mongoose');
- const Notification = this;
- let notificationSchema;
- notificationSchema = new mongoose.Schema({
- isEnabled: { type: Boolean, required: true, default: false },
- triggerPath: { type: String, required: true },
- triggerEvents: { type: [String] },
- toEmail: { type: String, required: true },
- });
- /**
- * create new notification setting
- * @param {string} triggerPath
- * @param {[string]} triggerEvents
- * @param {string} toEmail
- */
- notificationSchema.statics.create = (triggerPath, triggerEvents, toEmail) => {
- // return new Promise((resolve, reject) => {
- // save
- // return resolve(Notification)
- //}
- };
- /**
- * enable notification setting
- * @param {string} id
- */
- notificationSchema.statics.enable = id => {
- // return new Promise((resolve, reject) => {
- // save
- // return resolve(Notification)
- //}
- };
- /**
- * disable notification setting
- * @param {string} id
- */
- notificationSchema.statics.disable = id => {
- // return new Promise((resolve, reject) => {
- // save
- // return resolve(Notification)
- //}
- };
- /**
- * delete notification setting
- * @param {string} id
- */
- notificationSchema.statics.delete = id => {
- // return new Promise((resolve, reject) => {
- // remove
- // return resolve()
- //}
- };
- /**
- * update notification setting
- * @param {string} id
- */
- notificationSchema.statics.update = id => {
- // return new Promise((resolve, reject) => {
- // save
- // return resolve(Notification)
- //}
- };
- /**
- * find a notification setting by id
- * @param {string} id
- */
- notificationSchema.statics.findSettingById = id => {
- // return new Promise((resolve, reject) => {
- // findOne
- // return resolve(Notification)
- //}
- };
- /**
- * find a list of notification settings by path and a list of events
- * @param {string} path
- * @param {string} event
- */
- notificationSchema.statics.findSettingByPathAndEvent = (path, event) => {
- // return new Promise((resolve, reject) => {
- // find
- // return resolve([Notification])
- //}
- };
- // classify a list of notification settings into enabled and disabled
- notificationSchema.methods.classify = settings => {
- // return resolve({enabled: [Notification], disabled: [Notification]})
- };
- // returns only enabled notification settings
- notificationSchema.methods.getEnabeldSettings = settings => {
- // return resolve([Notification])
- };
- // sort a list of notifications by path from short to long
- notificationSchema.methods.sortByPath = settings => {
- // return resolve([Notification])
- };
- return mongoose.model('GlobalNotificationSetting', notificationSchema);
- };
|