Sotaro KARASAWA пре 9 година
родитељ
комит
fe63fc68a8
1 измењених фајлова са 8 додато и 1 уклоњено
  1. 8 1
      lib/routes/page.js

+ 8 - 1
lib/routes/page.js

@@ -12,6 +12,14 @@ module.exports = function(crowi, app) {
 
     , actions = {};
 
+  // register page events
+
+  var pageEvent = crowi.event('page');
+  pageEvent.on('update', function(page, user) {
+    crowi.getIo().sockets.emit('page edited', {page, user});
+  });
+
+
   function getPathFromRequest(req) {
     var path = '/' + (req.params[0] || '');
     return path.replace(/\.md$/, '');
@@ -395,7 +403,6 @@ module.exports = function(crowi, app) {
         throw new Error('Data not found');
       }
       // TODO: move to events
-      crowi.getIo().sockets.emit('page edited', {page: data, user: req.user});
       if (notify.slack) {
         if (notify.slack.on && notify.slack.channel) {
           data.updateSlackChannel(notify.slack.channel).then(function(){}).catch(function(){});