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

change concat method to push method

WNomunomu 2 лет назад
Родитель
Сommit
dda126393b

+ 1 - 1
apps/app/src/server/routes/comment.js

@@ -284,7 +284,7 @@ module.exports = function(crowi, app) {
 
 
         const mentionedUsers = await crowi.commentService.getMentionedUsers(activity.event);
         const mentionedUsers = await crowi.commentService.getMentionedUsers(activity.event);
 
 
-        props.concat(activeNotificationUsers, mentionedUsers);
+        props.push(...activeNotificationUsers, ...mentionedUsers);
 
 
       };
       };
 
 

+ 1 - 1
apps/app/src/server/routes/login.js

@@ -54,7 +54,7 @@ module.exports = function(crowi, app) {
     const preNotify = async(props) => {
     const preNotify = async(props) => {
       const adminUsers = await User.findAdmins();
       const adminUsers = await User.findAdmins();
 
 
-      props.concat(adminUsers);
+      props.push(...adminUsers);
     };
     };
 
 
     await activityEvent.emit('updated', activity, user, preNotify);
     await activityEvent.emit('updated', activity, user, preNotify);

+ 10 - 9
apps/app/src/server/service/preNotify.ts

@@ -1,18 +1,20 @@
-import type { IPage, IUser, Ref } from '@growi/core';
+import type {
+  IPage, IUser, Ref,
+} from '@growi/core';
 
 
 import { ActivityDocument } from '../models/activity';
 import { ActivityDocument } from '../models/activity';
 import Subscription from '../models/subscription';
 import Subscription from '../models/subscription';
 import { getModelSafely } from '../util/mongoose-utils';
 import { getModelSafely } from '../util/mongoose-utils';
 
 
 export type PreNotifyProps = {
 export type PreNotifyProps = {
-  notificationTargetUsers?: IUser[],
+  notificationTargetUsers?: Ref<IUser>[],
 }
 }
 
 
 export type PreNotify = (props: PreNotifyProps) => Promise<void>;
 export type PreNotify = (props: PreNotifyProps) => Promise<void>;
 
 
 export const generateInitialPreNotifyProps = (): PreNotifyProps => {
 export const generateInitialPreNotifyProps = (): PreNotifyProps => {
 
 
-  const initialPreNotifyProps: IUser[] = [];
+  const initialPreNotifyProps: Ref<IUser>[] = [];
 
 
   return { notificationTargetUsers: initialPreNotifyProps };
   return { notificationTargetUsers: initialPreNotifyProps };
 };
 };
@@ -32,14 +34,13 @@ export const generateDefaultPreNotify = (activity: ActivityDocument): PreNotify
       status: User.STATUS_ACTIVE,
       status: User.STATUS_ACTIVE,
     }).distinct('_id');
     }).distinct('_id');
 
 
-    notificationTargetUsers?.concat(activeNotificationUsers);
-
+    notificationTargetUsers?.push(...activeNotificationUsers);
   };
   };
 
 
   return preNotify;
   return preNotify;
 };
 };
 
 
-export const generatePreNotifyAlsoDescendants = (activity: ActivityDocument, descendantsSubscribedUsers): PreNotify => {
+export const generatePreNotifyAlsoDescendants = (activity: ActivityDocument, descendantsSubscribedUsers: Ref<IUser>[]): PreNotify => {
 
 
   const preNotify = async(props: PreNotifyProps) => {
   const preNotify = async(props: PreNotifyProps) => {
     const { notificationTargetUsers } = props;
     const { notificationTargetUsers } = props;
@@ -54,9 +55,9 @@ export const generatePreNotifyAlsoDescendants = (activity: ActivityDocument, des
       status: User.STATUS_ACTIVE,
       status: User.STATUS_ACTIVE,
     }).distinct('_id');
     }).distinct('_id');
 
 
-    notificationTargetUsers?.concat(
-      activeNotificationUsers,
-      descendantsSubscribedUsers as IUser[],
+    notificationTargetUsers?.push(
+      ...activeNotificationUsers,
+      ...descendantsSubscribedUsers,
     );
     );
 
 
   };
   };