Jelajahi Sumber

BugFix: Global Notification

Yuki Takei 6 tahun lalu
induk
melakukan
6ba509c9c8
2 mengubah file dengan 13 tambahan dan 13 penghapusan
  1. 7 7
      src/server/service/global-notification.js
  2. 6 6
      src/server/util/mailer.js

+ 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);
   }