sou 7 лет назад
Родитель
Сommit
72fe98c2bd
2 измененных файлов с 14 добавлено и 14 удалено
  1. 7 1
      lib/models/global-notification-setting.js
  2. 7 13
      lib/service/global-notification.js

+ 7 - 1
lib/models/global-notification-setting.js

@@ -58,8 +58,14 @@ class GlobalNotificationSetting {
    */
   static findSettingByPathAndEvent(path, event, enabled) {
     // return new Promise((resolve, reject) => {
+      // if(enabled == null) {
+      //   find all
+      // }
+      // else {
+      //   find only enabled/disabled
+      // }
       // sort by path in mongoDB
-      // find
+
       // return resolve([Notification])
     //}
   }

+ 7 - 13
lib/service/global-notification.js

@@ -76,21 +76,20 @@ const commentMailNotify = (notifications, comment, path) => {
 
 /**
  * the service class of GlobalNotificationSetting
- * @static
  */
 class GlobalNotification {
 
   constructor(crowi) {
+    this.crowi = crowi;
     this.config = crowi.getConfig();
   }
 
   /**
    * send notification at page creation
-   * @static
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  static sendPageCreateNotification(page) {
+  sendPageCreateNotification(page) {
     const notifications = Notification.findSettingByPathAndEvent(page.path, 'pageCreate');
     pageCreateMailNotify(notifications, page);
     // slackNotify(notifications, page);
@@ -98,11 +97,10 @@ class GlobalNotification {
 
   /**
    * send notification at page edit
-   * @static
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  static sendPageEditNotification(page) {
+  sendPageEditNotification(page) {
     const notifications = Notification.findSettingByPathAndEvent(page.path, 'pageEdit');
     pageEditMailNotify(notifications, page);
     // slackNotify(notifications, page);
@@ -110,11 +108,10 @@ class GlobalNotification {
 
   /**
    * send notification at page deletion
-   * @static
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  static sendPageDeleteNotification(page) {
+  sendPageDeleteNotification(page) {
     const notifications = Notification.findSettingByPathAndEvent(page.path, 'pageDelete');
     pageDeleteMailNotify(notifications, page);
     // slackNotify(notifications, page);
@@ -122,11 +119,10 @@ class GlobalNotification {
 
   /**
    * send notification at page move
-   * @static
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  static sendPageMoveNotification(page) {
+  sendPageMoveNotification(page) {
     const notifications = Notification.findSettingByPathAndEvent(page.path, 'pageMove');
     pageMoveMailNotify(notifications, page);
     // slackNotify(notifications, page);
@@ -134,11 +130,10 @@ class GlobalNotification {
 
   /**
    * send notification at page like
-   * @static
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  static sendPageLikeNotification(page) {
+  sendPageLikeNotification(page) {
     const notifications = Notification.findSettingByPathAndEvent(page.path, 'pageLike');
     pageLikeMailNotify(notifications, page);
     // slackNotify(notifications, page);
@@ -146,12 +141,11 @@ class GlobalNotification {
 
   /**
    * send notification at page comment
-   * @static
    * @memberof GlobalNotification
    * @param {obejct} page
    * @param {obejct} comment
    */
-  static sendCommentNotification(comment, path) {
+  sendCommentNotification(comment, path) {
     const notifications = Notification.findSettingByPathAndEvent(path, 'comment');
     commentMailNotify(notifications, comment, path);
     // slackNotify(notifications, comment, path);