Просмотр исходного кода

mail notification when update page(test)

yusuketk 7 лет назад
Родитель
Сommit
89e4a14f54
2 измененных файлов с 11 добавлено и 5 удалено
  1. 1 3
      lib/routes/page.js
  2. 10 2
      lib/service/global-notification.js

+ 1 - 3
lib/routes/page.js

@@ -709,9 +709,7 @@ module.exports = function(crowi, app) {
         .then((page) => {
           // NOTIFICATION: send page edit notification here
           notification.notifyPageEdit(page);
-        })
-        .catch((err) => {
-          console.log('error');
+          return page;
         });
       }
       else {

+ 10 - 2
lib/service/global-notification.js

@@ -35,7 +35,15 @@ class GlobalNotification {
   }
 
   notifyByMail(notification, mailOption) {
-    mailer.send(Object.assign(mailOption, {to: notification.toEmail}));
+    const crowi = this.crowi;
+    const mailer = crowi.getMailer();
+
+    mailer.send(Object.assign(mailOption, {to: notification.toEmail}),
+      function(err, s) {
+        debug('completed to send email: ', err, s);
+        next();
+      }
+    );
   }
 
   notifyBySlack(notification, slackOption) {
@@ -85,7 +93,7 @@ class GlobalNotification {
     const option = {
       mail: {
         subject: `#pageEdit - ${page.creator.username} edited ${page.path}`,
-        template: path.join(this.crowi.localeDir, lang, 'notifications/pageEdit.txt'),
+        template: `../../locales/${lang}/notifications/pageEdit.txt`,
         vars: {}
       },
       slack: {},