Skip to content

Commit 6e765f3

Browse files
authored
Merge pull request #16 from asepindrak/fix/send-email-to-member
Fix/send email to member
2 parents b0c98ab + 86a99ef commit 6e765f3

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

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.3",
3+
"version": "1.1.4",
44
"description": "Backend CommitFlow",
55
"author": "asepindrak",
66
"private": false,

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,16 @@ export class ProjectManagementService {
417417
) {
418418
const exists = await prisma.task.findUnique({ where: { id } });
419419
if (!exists) throw new NotFoundException("Task not found");
420-
420+
let project: any = null;
421421
// validate projectId if present and not null (null means detach project)
422422
if (
423423
typeof payload.projectId !== "undefined" &&
424424
payload.projectId !== null
425425
) {
426-
const p = await prisma.project.findUnique({
426+
project = await prisma.project.findUnique({
427427
where: { id: payload.projectId },
428428
});
429-
if (!p) throw new NotFoundException("Project not found");
429+
if (!project) throw new NotFoundException("Project not found");
430430
}
431431
let assignee: any = null;
432432
// validate assignee if present and not null
@@ -482,25 +482,11 @@ export class ProjectManagementService {
482482
});
483483

484484
//send email to team members
485-
const team = await prisma.teamMember.findFirst({
486-
where: { userId, isTrash: false },
487-
});
488-
489-
if (!team) throw new NotFoundException("Team not found");
490-
491485
const teams = await prisma.teamMember.findMany({
492-
where: { workspaceId: team.workspaceId, isTrash: false },
486+
where: { workspaceId: project.workspaceId, isTrash: false },
493487
select: { email: true },
494488
});
495489

496-
// Ambil nama project (optional, tapi lebih keren)
497-
const project = await prisma.project.findFirst({
498-
where: { id: payload.projectId ?? "" },
499-
select: { name: true },
500-
});
501-
502-
if (!project) throw new NotFoundException("Project not found");
503-
504490
const projectName = project?.name ?? "No Project";
505491

506492
const toEmails = teams.map((t) => t.email?.trim()).filter(Boolean);

0 commit comments

Comments
 (0)