@@ -513,13 +513,27 @@ export class ProjectManagementService {
513513
514514 //send email to team members
515515 const teams = await prisma . teamMember . findMany ( {
516- where : { workspaceId : project . workspaceId , isTrash : false } ,
516+ where : {
517+ workspaceId : project . workspaceId ,
518+ isTrash : false ,
519+ OR : [
520+ { isAdmin : true } ,
521+ { id : data . assigneeId } ,
522+ { id : data . createdById } ,
523+ ] ,
524+ } ,
517525 select : { email : true } ,
518526 } ) ;
519527
520528 const projectName = project ?. name ?? "No Project" ;
521529
522- const toEmails = teams . map ( ( t ) => t . email ?. trim ( ) ) . filter ( Boolean ) ;
530+ const toEmails = Array . from (
531+ new Set (
532+ teams
533+ . map ( ( t ) => t . email ?. trim ( ) . toLowerCase ( ) ) // normalisasi
534+ . filter ( Boolean ) // buang null/undefined/empty
535+ )
536+ ) ;
523537
524538 if ( toEmails . length === 0 ) throw new Error ( "No recipient emails found" ) ;
525539 // Format tanggal
@@ -757,11 +771,22 @@ export class ProjectManagementService {
757771
758772 //send email to team members
759773 const teams = await prisma . teamMember . findMany ( {
760- where : { workspaceId : p . workspaceId ?? "" , isTrash : false } ,
774+ where : {
775+ workspaceId : p . workspaceId ?? "" ,
776+ isTrash : false ,
777+ OR : [
778+ { isAdmin : true } ,
779+ { id : task . assigneeId ?? "" } ,
780+ { id : task . createdById ?? "" } ,
781+ ] ,
782+ } ,
761783 select : { email : true } ,
762784 } ) ;
763785
764- const toEmails = teams . map ( ( t ) => t . email ?. trim ( ) ) . filter ( Boolean ) ;
786+ // Extract + normalize + deduplicate emails
787+ const toEmails = Array . from (
788+ new Set ( teams . map ( ( t ) => t . email ?. trim ( ) . toLowerCase ( ) ) . filter ( Boolean ) )
789+ ) ;
765790
766791 if ( toEmails . length === 0 ) throw new Error ( "No recipient emails found" ) ;
767792
0 commit comments