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

Merge pull request #1149 from weseek/fix/global-notification

BugFix: Global Notification
Yuki Takei 6 лет назад
Родитель
Сommit
4ae7acd014
3 измененных файлов с 14 добавлено и 13 удалено
  1. 1 0
      CHANGES.md
  2. 7 7
      src/server/service/global-notification.js
  3. 6 6
      src/server/util/mailer.js

+ 1 - 0
CHANGES.md

@@ -4,6 +4,7 @@
 
 * Fix: Saving new page is failed when empty string tag is set
 * Fix: Link of Create template page button in New Page Modal is broken
+* Fix: Global Notification dows not work when creating/moving/deleting/like/comment
 
 ## 3.5.5
 

+ 7 - 7
src/server/service/global-notification.js

@@ -1,5 +1,5 @@
 const logger = require('@alias/logger')('growi:service:GlobalNotification');
-const path = require('path');
+const nodePath = require('path');
 /**
  * the service class of GlobalNotificationSetting
  */
@@ -43,7 +43,7 @@ class GlobalNotificationService {
     const option = {
       mail: {
         subject: `#pageCreate - ${page.creator.username} created ${page.path}`,
-        template: `../../locales/${lang}/notifications/pageCreate.txt`,
+        template: nodePath.join(this.crowi.localeDir, `${lang}/notifications/pageCreate.txt`),
         vars: {
           appTitle: this.appTitle,
           path: page.path,
@@ -69,7 +69,7 @@ class GlobalNotificationService {
     const option = {
       mail: {
         subject: `#pageEdit - ${page.creator.username} edited ${page.path}`,
-        template: path.join(this.crowi.localeDir, `${lang}/notifications/pageEdit.txt`),
+        template: nodePath.join(this.crowi.localeDir, `${lang}/notifications/pageEdit.txt`),
         vars: {
           appTitle: this.appTitle,
           path: page.path,
@@ -95,7 +95,7 @@ class GlobalNotificationService {
     const option = {
       mail: {
         subject: `#pageDelete - ${page.creator.username} deleted ${page.path}`, // FIXME
-        template: `../../locales/${lang}/notifications/pageDelete.txt`,
+        template: nodePath.join(this.crowi.localeDir, `${lang}/notifications/pageDelete.txt`),
         vars: {
           appTitle: this.appTitle,
           path: page.path,
@@ -119,7 +119,7 @@ class GlobalNotificationService {
     const option = {
       mail: {
         subject: `#pageMove - ${user.username} moved ${page.path} to ${page.path}`, // FIXME
-        template: `../../locales/${lang}/notifications/pageMove.txt`,
+        template: nodePath.join(this.crowi.localeDir, `${lang}/notifications/pageMove.txt`),
         vars: {
           appTitle: this.appTitle,
           oldPath: oldPagePath,
@@ -144,7 +144,7 @@ class GlobalNotificationService {
     const option = {
       mail: {
         subject: `#pageLike - ${user.username} liked ${page.path}`,
-        template: `../../locales/${lang}/notifications/pageLike.txt`,
+        template: nodePath.join(this.crowi.localeDir, `${lang}/notifications/pageLike.txt`),
         vars: {
           appTitle: this.appTitle,
           path: page.path,
@@ -170,7 +170,7 @@ class GlobalNotificationService {
     const option = {
       mail: {
         subject: `#comment - ${user.username} commented on ${path}`,
-        template: `../../locales/${lang}/notifications/comment.txt`,
+        template: nodePath.join(this.crowi.localeDir, `${lang}/notifications/comment.txt`),
         vars: {
           appTitle: this.appTitle,
           path,

+ 6 - 6
src/server/util/mailer.js

@@ -3,7 +3,7 @@
  */
 
 module.exports = function(crowi) {
-  const debug = require('debug')('growi:lib:mailer');
+  const logger = require('@alias/logger')('growi:lib:mailer');
   const nodemailer = require('nodemailer');
   const swig = require('swig-templates');
 
@@ -13,7 +13,7 @@ module.exports = function(crowi) {
   let mailer = {};
 
   function createSMTPClient(option) {
-    debug('createSMTPClient option', option);
+    logger.debug('createSMTPClient option', option);
     if (!option) {
       option = { // eslint-disable-line no-param-reassign
         host: configManager.getConfig('crowi', 'mail:smtpHost'),
@@ -34,7 +34,7 @@ module.exports = function(crowi) {
 
     const client = nodemailer.createTransport(option);
 
-    debug('mailer set up for SMTP', client);
+    logger.debug('mailer set up for SMTP', client);
     return client;
   }
 
@@ -49,7 +49,7 @@ module.exports = function(crowi) {
     const ses = require('nodemailer-ses-transport');
     const client = nodemailer.createTransport(ses(option));
 
-    debug('mailer set up for SES', client);
+    logger.debug('mailer set up for SES', client);
     return client;
   }
 
@@ -75,7 +75,7 @@ module.exports = function(crowi) {
     mailConfig.from = configManager.getConfig('crowi', 'mail:from');
     mailConfig.subject = `${appService.getAppTitle()}からのメール`;
 
-    debug('mailer initialized');
+    logger.debug('mailer initialized');
   }
 
   function setupMailConfig(overrideConfig) {
@@ -110,7 +110,7 @@ module.exports = function(crowi) {
       );
     }
 
-    debug('Mailer is not completed to set up. Please set up SMTP or AWS setting.');
+    logger.debug('Mailer is not completed to set up. Please set up SMTP or AWS setting.');
     return callback(new Error('Mailer is not completed to set up. Please set up SMTP or AWS setting.'), null);
   }