Quellcode durchsuchen

interface architecture

sou vor 7 Jahren
Ursprung
Commit
ad6cc3eaf2
5 geänderte Dateien mit 52 neuen und 21 gelöschten Zeilen
  1. 5 0
      lib/routes/admin.js
  2. 1 0
      lib/routes/comment.js
  3. 1 0
      lib/routes/index.js
  4. 15 0
      lib/routes/page.js
  5. 30 21
      lib/service/global-notification.js

+ 5 - 0
lib/routes/admin.js

@@ -1069,6 +1069,11 @@ module.exports = function(crowi, app) {
     });
     });
   };
   };
 
 
+  // app.get('/_api/admin/notification/testGlobalNotification' , admin.api.testGlobalNotification);
+  // actions.api.testGlobalNotification = function(req, res) {
+  //   // NOTIFICATION: send test notification here
+  // };
+
   /**
   /**
    * save settings, update config cache, and response json
    * save settings, update config cache, and response json
    *
    *

+ 1 - 0
lib/routes/comment.js

@@ -75,6 +75,7 @@ module.exports = function(crowi, app) {
     });
     });
 
 
     return res.json(ApiResponse.success({comment: createdComment}));
     return res.json(ApiResponse.success({comment: createdComment}));
+    // NOTIFICATION: send comment notification here
   };
   };
 
 
   /**
   /**

+ 1 - 0
lib/routes/index.js

@@ -105,6 +105,7 @@ module.exports = function(crowi, app) {
   app.post('/_api/admin/notification.add'    , loginRequired(crowi, app) , middleware.adminRequired() , csrf, admin.api.notificationAdd);
   app.post('/_api/admin/notification.add'    , loginRequired(crowi, app) , middleware.adminRequired() , csrf, admin.api.notificationAdd);
   app.post('/_api/admin/notification.remove' , loginRequired(crowi, app) , middleware.adminRequired() , csrf, admin.api.notificationRemove);
   app.post('/_api/admin/notification.remove' , loginRequired(crowi, app) , middleware.adminRequired() , csrf, admin.api.notificationRemove);
   app.get('/_api/admin/users.search'         , loginRequired(crowi, app) , middleware.adminRequired() , admin.api.usersSearch);
   app.get('/_api/admin/users.search'         , loginRequired(crowi, app) , middleware.adminRequired() , admin.api.usersSearch);
+  // app.post('/_api/admin/notification/testGlobalNotification', loginRequired(crowi, app) , middleware.adminRequired() , csrf, admin.api.testGlobalNotification);
 
 
   app.get('/admin/users'                , loginRequired(crowi, app) , middleware.adminRequired() , admin.user.index);
   app.get('/admin/users'                , loginRequired(crowi, app) , middleware.adminRequired() , admin.user.index);
   app.post('/admin/user/invite'         , form.admin.userInvite ,  loginRequired(crowi, app) , middleware.adminRequired() , csrf, admin.user.invite);
   app.post('/admin/user/invite'         , form.admin.userInvite ,  loginRequired(crowi, app) , middleware.adminRequired() , csrf, admin.user.invite);

+ 15 - 0
lib/routes/page.js

@@ -649,11 +649,17 @@ module.exports = function(crowi, app) {
       if (data) {
       if (data) {
         previousRevision = data.revision;
         previousRevision = data.revision;
         return Page.updatePage(data, body, req.user, { grant, grantUserGroupId });
         return Page.updatePage(data, body, req.user, { grant, grantUserGroupId });
+        // .then(() => {
+        //   // NOTIFICATION: send page edit notification here
+        // })
       }
       }
       else {
       else {
         // new page
         // new page
         updateOrCreate = 'create';
         updateOrCreate = 'create';
         return Page.create(path, body, req.user, { grant, grantUserGroupId });
         return Page.create(path, body, req.user, { grant, grantUserGroupId });
+        // .then(() => {
+        //   // NOTIFICATION: send page create notification here
+        // })
       }
       }
     }).then(function(data) {
     }).then(function(data) {
       // data is a saved page data with revision.
       // data is a saved page data with revision.
@@ -934,6 +940,9 @@ module.exports = function(crowi, app) {
       debug('Like failed', err);
       debug('Like failed', err);
       return res.json(ApiResponse.error({}));
       return res.json(ApiResponse.error({}));
     });
     });
+    // .then(() => {
+    //   // NOTIFICATION: send page like notification here
+    // })
   };
   };
 
 
   /**
   /**
@@ -1039,6 +1048,9 @@ module.exports = function(crowi, app) {
       debug('Error occured while get setting', err, err.stack);
       debug('Error occured while get setting', err, err.stack);
       return res.json(ApiResponse.error('Failed to delete page.'));
       return res.json(ApiResponse.error('Failed to delete page.'));
     });
     });
+    // .then(() => {
+    //   // NOTIFICATION: send page delete notification here
+    // })
   };
   };
 
 
   /**
   /**
@@ -1132,6 +1144,9 @@ module.exports = function(crowi, app) {
       .catch(function(err) {
       .catch(function(err) {
         return res.json(ApiResponse.error('Failed to update page.'));
         return res.json(ApiResponse.error('Failed to update page.'));
       });
       });
+      // .then(() => {
+      //   // NOTIFICATION: send page move notification here
+      // })
     });
     });
   };
   };
 
 

+ 30 - 21
lib/service/global-notification.js

@@ -11,58 +11,67 @@ class GlobalNotification {
   /**
   /**
    * send test notification
    * send test notification
    * @memberof GlobalNotification
    * @memberof GlobalNotification
+   * @param {string} toEmail
    */
    */
-  sendTesteNotification() {}
+  sendTesteNotification(toEmail) {}
 
 
   /**
   /**
    * send notification at page creation
    * send notification at page creation
    * @memberof GlobalNotification
    * @memberof GlobalNotification
+   * @param {string} toEmail
+   * @param {obejct} page
    */
    */
-  sendPageCreateNotification() {}
+  sendCreateNotification(toEmail, page) {
+    // const option = {
+    //   to: toEmail,
+    //   subject: `#create - ${page.creator.username} created ${page.path}`,
+    //   template: 'notification/createPage.txt',
+    //   vars: {}
+    // };
+
+    // return mailer.send(option)
+  }
 
 
   /**
   /**
    * send notification at page edit
    * send notification at page edit
    * @memberof GlobalNotification
    * @memberof GlobalNotification
+   * @param {string} toEmail
+   * @param {obejct} page
    */
    */
-  sendPageEditNotification() {}
+  sendEditNotification(toEmail, page) {}
 
 
   /**
   /**
    * send notification at page deletion
    * send notification at page deletion
    * @memberof GlobalNotification
    * @memberof GlobalNotification
+   * @param {string} toEmail
+   * @param {obejct} page
    */
    */
-  sendPageDeleteNotification() {}
+  sendDeleteNotification(toEmail, page) {}
 
 
   /**
   /**
    * send notification at page move
    * send notification at page move
    * @memberof GlobalNotification
    * @memberof GlobalNotification
+   * @param {string} toEmail
+   * @param {obejct} page
    */
    */
-  sendPageMoveNotification() {}
+  sendMoveNotification(toEmail, page) {}
 
 
   /**
   /**
    * send notification at page like
    * send notification at page like
    * @memberof GlobalNotification
    * @memberof GlobalNotification
+   * @param {string} toEmail
+   * @param {obejct} page
    */
    */
-  sendPageLikeNotification() {}
+  sendLikeNotification(toEmail, page) {}
 
 
   /**
   /**
    * send notification at page comment
    * send notification at page comment
    * @memberof GlobalNotification
    * @memberof GlobalNotification
+   * @param {string} toEmail
+   * @param {obejct} page
+   * @param {obejct} comment
    */
    */
-  sendCommentNotification() {}
+  sendCommentNotification(toEmail, page, comment) {}
 }
 }
 
 
 module.exports = GlobalNotification;
 module.exports = GlobalNotification;
-
-// res.send
-// const notifications = await findSettingByPathAndEvent(path, 'comment');
-// notifications.forEach(notification => {
-//   sendCommentNotification(notification);
-// });
-
-
-// const mailOption = {
-//   to: '',
-//   from: '',
-//   text: '#comment',
-//   subject: '',
-// };