Skip to content

Commit 5ac4f09

Browse files
authored
Merge pull request #23 from asepindrak/dev
Dev
2 parents 9fedcc6 + 8b4369d commit 5ac4f09

File tree

8 files changed

+61
-28
lines changed

8 files changed

+61
-28
lines changed

.changeset/salty-bats-act.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"commitflow": patch
3+
---
4+
5+
fix send email to member

backend/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commitflow-api",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"description": "Backend CommitFlow",
55
"author": "asepindrak",
66
"private": false,

backend/prisma/schema.prisma

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ model TeamMember {
7878
isAdmin Boolean @default(false)
7979
createdAt DateTime @default(now())
8080
updatedAt DateTime?
81-
Task Task[]
81+
Task Task[] @relation("TaskMembers")
82+
TaskCreatedBy Task[] @relation("TaskCreatedBy")
8283
8384
// FK ke Workspace
8485
workspace Workspace? @relation("WorkspaceMembers", fields: [workspaceId], references: [id])
@@ -111,22 +112,24 @@ model Project {
111112
}
112113

113114
model Task {
114-
id String @id @default(uuid())
115-
title String
116-
description String?
117-
status String @default("todo")
118-
projectId String?
119-
project Project? @relation("ProjectTasks", fields: [projectId], references: [id])
120-
assigneeId String?
121-
startDate String?
122-
dueDate String?
123-
priority String?
124-
assignee TeamMember? @relation(fields: [assigneeId], references: [id])
125-
isTrash Boolean @default(false)
126-
comments Comment[] @relation("TaskComments")
127-
clientId String? @unique
128-
createdAt DateTime @default(now())
129-
updatedAt DateTime?
115+
id String @id @default(uuid())
116+
title String
117+
description String?
118+
status String @default("todo")
119+
projectId String?
120+
project Project? @relation("ProjectTasks", fields: [projectId], references: [id])
121+
assigneeId String?
122+
startDate String?
123+
dueDate String?
124+
priority String?
125+
assignee TeamMember? @relation("TaskMembers", fields: [assigneeId], references: [id])
126+
isTrash Boolean @default(false)
127+
comments Comment[] @relation("TaskComments")
128+
clientId String? @unique
129+
createdAt DateTime @default(now())
130+
createdById String?
131+
createdBy TeamMember? @relation("TaskCreatedBy", fields: [createdById], references: [id])
132+
updatedAt DateTime?
130133
}
131134

132135
model Comment {

backend/src/app.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { Injectable } from "@nestjs/common";
33
@Injectable()
44
export class AppService {
55
getHello(): string {
6-
return `CommitFlow API (1.1.8) is running!`;
6+
return `CommitFlow API (1.1.9) is running!`;
77
}
88
}

backend/src/project-management/project-management.service.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

frontend/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "asepindrak",
55
"private": false,
66
"license": "MIT",
7-
"version": "1.3.8",
7+
"version": "1.3.9",
88
"type": "module",
99
"scripts": {
1010
"dev": "vite --host 0.0.0.0",

0 commit comments

Comments
 (0)