Skip to content

Commit 64c11e3

Browse files
committed
CLAP-440 Fix : 작업 상태 변경 알림 중복 전송 에러 해결
1 parent c83a08b commit 64c11e3

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/main/java/clap/server/application/service/task/ApprovalTaskService.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import lombok.RequiredArgsConstructor;
2626
import org.springframework.transaction.annotation.Transactional;
2727

28+
import java.util.ArrayList;
2829
import java.util.List;
2930
import java.util.stream.Collectors;
3031
import java.util.stream.Stream;
@@ -61,11 +62,8 @@ public ApprovalTaskResponse approvalTaskByReviewer(Long reviewerId, Long taskId,
6162
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.PROCESSOR_ASSIGNED, task, null, processor, null);
6263
commandTaskHistoryPort.save(taskHistory);
6364

64-
List<Member> receivers = Stream.of(task.getRequester(), processor)
65-
.distinct()
66-
.collect(Collectors.toList());
6765
String processorName = processor.getNickname();
68-
publishNotification(receivers, task, processorName);
66+
publishNotification(task, processorName);
6967

7068
return TaskResponseMapper.toApprovalTaskResponse(taskService.upsert(task));
7169
}
@@ -78,7 +76,14 @@ public FindApprovalFormResponse findApprovalForm(Long managerId, Long taskId) {
7876
return TaskResponseMapper.toFindApprovalFormResponse(task);
7977
}
8078

81-
private void publishNotification(List<Member> receivers, Task task, String processorName) {
79+
private void publishNotification(Task task, String processorName) {
80+
List<Member> receivers = new ArrayList<>();
81+
receivers.add(task.getRequester());
82+
83+
if (!task.getRequester().getMemberId().equals(task.getProcessor().getMemberId())) {
84+
receivers.add(task.getProcessor());
85+
}
86+
8287
receivers.forEach(receiver -> {
8388
boolean isManager = receiver.getMemberInfo().getRole() == MemberRole.ROLE_MANAGER;
8489
sendNotificationService.sendPushNotification(receiver, NotificationType.PROCESSOR_ASSIGNED,

src/main/java/clap/server/application/service/task/UpdateTaskOrderAndStstusService.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import lombok.extern.slf4j.Slf4j;
2525
import org.springframework.transaction.annotation.Transactional;
2626

27+
import java.util.ArrayList;
2728
import java.util.List;
2829

2930
@Slf4j
@@ -83,7 +84,7 @@ public void updateTaskOrderAndStatus(Long processorId, UpdateTaskOrderRequest re
8384

8485
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.STATUS_SWITCHED, updatedTask, targetStatus.getDescription(), null,null);
8586
commandTaskHistoryPort.save(taskHistory);
86-
publishNotification(targetTask, NotificationType.STATUS_SWITCHED, updatedTask.getDescription());
87+
publishNotification(targetTask);
8788
}
8889

8990
/**
@@ -139,14 +140,14 @@ public void validateRequest(TaskStatus targetStatus) {
139140
}
140141
}
141142

142-
private void publishNotification(Task task, NotificationType notificationType, String message) {
143-
List<Member> receivers = List.of(task.getRequester(), task.getProcessor());
143+
private void publishNotification(Task task) {
144+
List<Member> receivers = List.of(task.getRequester());
144145
receivers.forEach(receiver -> {
145146
boolean isManager = receiver.getMemberInfo().getRole() == MemberRole.ROLE_MANAGER;
146-
sendNotificationService.sendPushNotification(receiver, notificationType, task, message, null, null, isManager);
147+
sendNotificationService.sendPushNotification(receiver, NotificationType.STATUS_SWITCHED, task, task.getTaskStatus().getDescription(), null, null, isManager);
147148
});
148-
sendNotificationService.sendAgitNotification(notificationType,
149-
task, message, null);
149+
sendNotificationService.sendAgitNotification(NotificationType.STATUS_SWITCHED,
150+
task, task.getTaskStatus().getDescription(), null);
150151
}
151152

152153
}

0 commit comments

Comments
 (0)