sou 7 лет назад
Родитель
Сommit
30ef461c3a
2 измененных файлов с 103 добавлено и 25 удалено
  1. 35 25
      lib/models/global-notification-setting.js
  2. 68 0
      lib/service/global-notification.js

+ 35 - 25
lib/models/global-notification-setting.js

@@ -14,10 +14,15 @@ module.exports = function(crowi) {
 
   /**
    * create new notification setting
+   * @param {string} triggerPath
+   * @param {[string]} triggerEvents
+   * @param {string} toEmail
    */
-  notificationSchema.statics.create = () => {
-    // save
-    // return Notification
+  notificationSchema.statics.create = (triggerPath, triggerEvents, toEmail) => {
+    // return new Promise((resolve, reject) => {
+      // save
+      // return resolve(Notification)
+    //}
   };
 
   /**
@@ -25,8 +30,10 @@ module.exports = function(crowi) {
    * @param {string} id
    */
   notificationSchema.statics.enable = id => {
-    // save
-    // return Notification
+    // return new Promise((resolve, reject) => {
+      // save
+      // return resolve(Notification)
+    //}
   };
 
   /**
@@ -34,8 +41,10 @@ module.exports = function(crowi) {
    * @param {string} id
    */
   notificationSchema.statics.disable = id => {
-    // save
-    // return Notification
+    // return new Promise((resolve, reject) => {
+      // save
+      // return resolve(Notification)
+    //}
   };
 
   /**
@@ -43,9 +52,10 @@ module.exports = function(crowi) {
    * @param {string} id
    */
   notificationSchema.statics.delete = id => {
-    // delete notification setting
-    // remove
-    // return;
+    // return new Promise((resolve, reject) => {
+      // remove
+      // return resolve()
+    //}
   };
 
   /**
@@ -53,8 +63,10 @@ module.exports = function(crowi) {
    * @param {string} id
    */
   notificationSchema.statics.update = id => {
-    // save
-    // return Notification
+    // return new Promise((resolve, reject) => {
+      // save
+      // return resolve(Notification)
+    //}
   };
 
   /**
@@ -62,8 +74,10 @@ module.exports = function(crowi) {
    * @param {string} id
    */
   notificationSchema.statics.findSettingById = id => {
-    // findOne
-    // return Notification
+    // return new Promise((resolve, reject) => {
+      // findOne
+      // return resolve(Notification)
+    //}
   };
 
   /**
@@ -72,30 +86,26 @@ module.exports = function(crowi) {
    * @param {string} event
    */
   notificationSchema.statics.findSettingByPathAndEvent = (path, event) => {
-    // find
-    // return [Notification]
+    // return new Promise((resolve, reject) => {
+      // find
+      // return resolve([Notification])
+    //}
   };
 
   // classify a list of notification settings into enabled and disabled
   notificationSchema.mothods.classify = settings => {
-    // return {enabled: [Notification], disabled: [Notification]}
+    // return resolve({enabled: [Notification], disabled: [Notification]})
   };
 
   // returns only enabled notification settings
   notificationSchema.mothods.getEnabeldSettings = settings => {
-    // return [Notification]
+    // return resolve([Notification])
   };
 
   // sort a list of notifications by path from short to long
   notificationSchema.mothods.sortByPath = settings => {
-    // return [Notification]
+    // return resolve([Notification])
   };
 
   return mongoose.model('GlobalNotificationSetting', notificationSchema);
 };
-
-
-// const notifications = await findSettingByPathAndEvent(path, event);
-// notifications.forEach(notification => {
-//   notification.send(); //??????????
-// });

+ 68 - 0
lib/service/global-notification.js

@@ -0,0 +1,68 @@
+const debug = require('debug')('growi:service:GlobalNotification');
+
+/**
+ * the service class of GlobalNotificationSetting
+ */
+class GlobalNotification {
+
+  constructor() {
+  }
+
+  /**
+   * send test notification
+   * @memberof GlobalNotification
+   */
+  sendTesteNotification() {}
+
+  /**
+   * send notification at page creation
+   * @memberof GlobalNotification
+   */
+  sendPageCreateNotification() {}
+
+  /**
+   * send notification at page edit
+   * @memberof GlobalNotification
+   */
+  sendPageEditNotification() {}
+
+  /**
+   * send notification at page deletion
+   * @memberof GlobalNotification
+   */
+  sendPageDeleteNotification() {}
+
+  /**
+   * send notification at page move
+   * @memberof GlobalNotification
+   */
+  sendPageMoveNotification() {}
+
+  /**
+   * send notification at page like
+   * @memberof GlobalNotification
+   */
+  sendPageLikeNotification() {}
+
+  /**
+   * send notification at page comment
+   * @memberof GlobalNotification
+   */
+  sendCommentNotification() {}
+}
+
+module.exports = GlobalNotification;
+
+// res.send
+// const notifications = await findSettingByPathAndEvent(path, 'comment');
+// notifications.forEach(notification => {
+//   sendCommentNotification(notification);
+// });
+
+
+// const mailOption = {
+//   to: '',
+//   from: '',
+//   text: '#comment',
+//   subject: '',
+// };