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

fix delete and like notification

mizozobu 6 лет назад
Родитель
Сommit
f36a437915
2 измененных файлов с 13 добавлено и 13 удалено
  1. 1 1
      src/server/routes/page.js
  2. 12 12
      src/server/service/global-notification.js

+ 1 - 1
src/server/routes/page.js

@@ -999,7 +999,7 @@ module.exports = function(crowi, app) {
     res.json(ApiResponse.success(result));
 
     // global notification
-    return globalNotificationService.notifyPageDelete(page);
+    return globalNotificationService.notifyPageDelete(page, req.user);
   };
 
   /**

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

@@ -100,7 +100,7 @@ class GlobalNotificationService {
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  async notifyPageDelete(page) {
+  async notifyPageDelete(page, triggeredBy) {
     const notifications = await this.GlobalNotification.findSettingByPathAndEvent(page.path, 'pageDelete');
     const lang = 'en-US'; // FIXME
     const baseOption = {
@@ -108,12 +108,12 @@ class GlobalNotificationService {
       vars: {
         appTitle: this.appTitle,
         path: page.path,
-        username: page.creator.username,
+        username: triggeredBy.username,
       },
     };
     const option = {
       mail: {
-        subject: `#pageDelete - ${page.creator.username} deleted ${page.path}`, // FIXME
+        subject: `#pageDelete - ${triggeredBy.username} deleted ${page.path}`, // FIXME
         ...baseOption,
       },
       slack: {
@@ -130,7 +130,7 @@ class GlobalNotificationService {
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  async notifyPageMove(page, oldPagePath, user) {
+  async notifyPageMove(page, oldPagePath, triggeredBy) {
     const notifications = await this.GlobalNotification.findSettingByPathAndEvent(page.path, 'pageMove');
     const lang = 'en-US'; // FIXME
     const baseOption = {
@@ -139,12 +139,12 @@ class GlobalNotificationService {
         appTitle: this.appTitle,
         oldPath: oldPagePath,
         newPath: page.path,
-        username: user.username,
+        username: triggeredBy.username,
       },
     };
     const option = {
       mail: {
-        subject: `#pageMove - ${user.username} moved ${page.path} to ${page.path}`, // FIXME
+        subject: `#pageMove - ${triggeredBy.username} moved ${page.path} to ${page.path}`, // FIXME
         ...baseOption,
       },
       slack: {
@@ -160,7 +160,7 @@ class GlobalNotificationService {
    * @memberof GlobalNotification
    * @param {obejct} page
    */
-  async notifyPageLike(page, user) {
+  async notifyPageLike(page, triggeredBy) {
     const notifications = await this.GlobalNotification.findSettingByPathAndEvent(page.path, 'pageLike');
     const lang = 'en-US'; // FIXME
     const baseOption = {
@@ -168,12 +168,12 @@ class GlobalNotificationService {
       vars: {
         appTitle: this.appTitle,
         path: page.path,
-        username: page.creator.username,
+        username: triggeredBy.username,
       },
     };
     const option = {
       mail: {
-        subject: `#pageLike - ${user.username} liked ${page.path}`,
+        subject: `#pageLike - ${triggeredBy.username} liked ${page.path}`,
         ...baseOption,
       },
       slack: {
@@ -193,19 +193,19 @@ class GlobalNotificationService {
   async notifyComment(comment, path) {
     const notifications = await this.GlobalNotification.findSettingByPathAndEvent(path, 'comment');
     const lang = 'en-US'; // FIXME
-    const user = await this.User.findOne({ _id: comment.creator });
+    const triggeredBy = await this.User.findOne({ _id: comment.creator });
     const baseOption = {
       template: nodePath.join(this.crowi.localeDir, `${lang}/notifications/comment.txt`),
       vars: {
         appTitle: this.appTitle,
         path,
-        username: user.username,
+        username: triggeredBy.username,
         comment: comment.comment,
       },
     };
     const option = {
       mail: {
-        subject: `#comment - ${user.username} commented on ${path}`,
+        subject: `#comment - ${triggeredBy.username} commented on ${path}`,
         ...baseOption,
       },
       slack: {