| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- 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
- */
- notificationSchema.statics.create = () => {
- // save
- // return Notification
- };
- /**
- * enable notification setting
- * @param {string} id
- */
- notificationSchema.statics.enable = id => {
- // save
- // return Notification
- };
- /**
- * disable notification setting
- * @param {string} id
- */
- notificationSchema.statics.disable = id => {
- // save
- // return Notification
- };
- /**
- * delete notification setting
- * @param {string} id
- */
- notificationSchema.statics.delete = id => {
- // delete notification setting
- // remove
- // return;
- };
- /**
- * update notification setting
- * @param {string} id
- */
- notificationSchema.statics.update = id => {
- // save
- // return Notification
- };
- /**
- * find a notification setting by id
- * @param {string} id
- */
- notificationSchema.statics.findSettingById = id => {
- // findOne
- // return 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) => {
- // find
- // return [Notification]
- };
- // classify a list of notification settings into enabled and disabled
- notificationSchema.mothods.classify = settings => {
- // return {enabled: [Notification], disabled: [Notification]}
- };
- // returns only enabled notification settings
- notificationSchema.mothods.getEnabeldSettings = settings => {
- // return [Notification]
- };
- // sort a list of notifications by path from short to long
- notificationSchema.mothods.sortByPath = settings => {
- // return [Notification]
- };
- return mongoose.model('GlobalNotificationSetting', notificationSchema);
- };
- // const notifications = await findSettingByPathAndEvent(path, event);
- // notifications.forEach(notification => {
- // notification.send(); //??????????
- // });
|