@@ -7,7 +7,7 @@ import prisma from '../prisma/prisma';
77import taskTransformer from '../transformers/tasks.transformer' ;
88import { NotFoundException , AccessDeniedException , HttpException , DeletedException } from '../utils/errors.utils' ;
99import { hasPermissionToEditTask , sendSlackTaskAssignedNotificationToUsers } from '../utils/tasks.utils' ;
10- import { areUsersPartOfTeams , isUserOnTeam } from '../utils/teams.utils' ;
10+ import { allUsersOnTeam , areUsersPartOfTeams , isUserOnTeam } from '../utils/teams.utils' ;
1111import { getUsers } from '../utils/users.utils' ;
1212import { wbsNumOf } from '../utils/utils' ;
1313
@@ -80,6 +80,9 @@ export default class TasksService {
8080 if ( ! areUsersPartOfTeams ( teams , users ) )
8181 throw new HttpException ( 400 , `All assignees must be part of one of the project's team!` ) ;
8282
83+ if ( ! teams . some ( ( team ) => allUsersOnTeam ( team , users ) ) )
84+ throw new HttpException ( 400 , 'All assignees must be part of the same team!' ) ;
85+
8386 if ( ! isUnderWordCount ( title , 15 ) ) throw new HttpException ( 400 , 'Title must be less than 15 words' ) ;
8487 if ( ! isUnderWordCount ( notes , 250 ) ) throw new HttpException ( 400 , 'Notes must be less than 250 words' ) ;
8588
@@ -202,6 +205,9 @@ export default class TasksService {
202205 throw new HttpException ( 400 , "All assignees must be part of one of the project's teams" ) ;
203206 }
204207
208+ if ( ! teams . some ( ( team ) => allUsersOnTeam ( team , assigneeUsers ) ) )
209+ throw new HttpException ( 400 , 'All assignees must be part of the same team!' ) ;
210+
205211 // retrieve userId for every assignee to update task's assignees in the database
206212 const transformedAssigneeUsers = assigneeUsers . map ( ( user ) => {
207213 return {
0 commit comments