Skip to content

Commit a376bd3

Browse files
committed
CLAP-288 Fix : 알림 생성 불필요한 Code 삭제
1 parent 1eaba70 commit a376bd3

File tree

6 files changed

+35
-39
lines changed

6 files changed

+35
-39
lines changed

src/main/java/clap/server/application/service/history/PostCommentService.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ public void save(Long userId, Long taskId, CreateCommentRequest request) {
5151
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.COMMENT, task, null, member, savedComment);
5252
commandTaskHistoryPort.save(taskHistory);
5353

54-
String taskTitle = task.getTitle();
55-
Member receiver;
54+
Member processor = task.getProcessor();
55+
Member requester = task.getRequester();
5656
if (member.getMemberInfo().getRole() == MemberRole.ROLE_USER) {
57-
receiver = task.getProcessor();
58-
publishNotification(receiver, task, request.content(), member.getNickname(), taskTitle, receiver.getMemberInfo().getEmail());
57+
publishNotification(processor, task, request.content(), requester.getNickname());
5958
} else {
60-
receiver = task.getRequester();
61-
publishNotification(receiver, task, request.content(), receiver.getNickname(), taskTitle, receiver.getMemberInfo().getEmail());
59+
publishNotification(requester, task, request.content(), processor.getNickname());
6260
}
6361
}
6462
}
@@ -77,12 +75,12 @@ public void saveCommentAttachment(Long userId, Long taskId, MultipartFile file)
7775
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.COMMENT_FILE, task, null, member, savedComment);
7876
commandTaskHistoryPort.save(taskHistory);
7977

78+
Member processor = task.getProcessor();
79+
Member requester = task.getRequester();
8080
if (member.getMemberInfo().getRole() == MemberRole.ROLE_USER) {
81-
Member receiver = task.getProcessor();
82-
publishNotification(receiver, task, fileName + "(첨부파일)", member.getNickname(), task.getTitle(), receiver.getMemberInfo().getEmail());
81+
publishNotification(processor, task, fileName + "(첨부파일)", requester.getNickname());
8382
} else {
84-
Member receiver = task.getRequester();
85-
publishNotification(receiver, task, fileName + "(첨부파일)", task.getProcessor().getNickname(), task.getTitle(), receiver.getMemberInfo().getEmail());
83+
publishNotification(requester, task, fileName + "(첨부파일)", processor.getNickname());
8684
}
8785
}
8886
}
@@ -94,8 +92,7 @@ private String saveAttachment(MultipartFile file, Task task, Comment comment) {
9492
return file.getOriginalFilename();
9593
}
9694

97-
private void publishNotification(Member receiver, Task task, String message, String commenterName, String taskTitle, String email) {
98-
sendNotificationService.sendPushNotification(receiver, email, NotificationType.COMMENT, task, taskTitle, message, commenterName);
95+
private void publishNotification(Member receiver, Task task, String message, String commenterName) {
96+
sendNotificationService.sendPushNotification(receiver, NotificationType.COMMENT, task, message, commenterName);
9997
}
100-
10198
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public ApprovalTaskResponse approvalTaskByReviewer(Long reviewerId, Long taskId,
5757
commandTaskHistoryPort.save(taskHistory);
5858

5959
List<Member> receivers = List.of(reviewer, processor);
60-
String processorName = task.getProcessor().getNickname();
61-
publishNotification(receivers, task, task.getTitle(), processorName);
60+
String processorName = processor.getNickname();
61+
publishNotification(receivers, task, processorName);
6262

6363
return TaskResponseMapper.toApprovalTaskResponse(taskService.upsert(task));
6464
}
@@ -71,13 +71,13 @@ public FindApprovalFormResponse findApprovalForm(Long managerId, Long taskId) {
7171
return TaskResponseMapper.toFindApprovalFormResponse(task);
7272
}
7373

74-
private void publishNotification(List<Member> receivers, Task task, String taskTitle, String processorName){
74+
private void publishNotification(List<Member> receivers, Task task, String processorName){
7575
receivers.forEach(receiver -> {
76-
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getEmail(), NotificationType.PROCESSOR_ASSIGNED,
77-
task, taskTitle, processorName, null);
76+
sendNotificationService.sendPushNotification(receiver, NotificationType.PROCESSOR_ASSIGNED,
77+
task, processorName, null);
7878
});
7979
sendNotificationService.sendAgitNotification(NotificationType.PROCESSOR_CHANGED,
80-
task, taskTitle, processorName, null);
80+
task, processorName, null);
8181
}
8282

8383
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public CreateTaskResponse createTask(Long requesterId, CreateTaskRequest createT
4949

5050
if (files != null) {
5151
saveAttachments(files, savedTask);}
52-
publishNotification(savedTask, savedTask.getTitle());
52+
publishNotification(savedTask);
5353
return TaskResponseMapper.toCreateTaskResponse(savedTask);
5454
}
5555

@@ -59,12 +59,12 @@ private void saveAttachments(List<MultipartFile> files, Task task) {
5959
commandAttachmentPort.saveAll(attachments);
6060
}
6161

62-
private void publishNotification(Task task, String taskTitle) {
62+
private void publishNotification(Task task) {
6363
List<Member> reviewers = memberService.findReviewers();
64-
reviewers.forEach(reviewer -> {sendNotificationService.sendPushNotification(reviewer, reviewer.getMemberInfo().getNickname(), NotificationType.TASK_REQUESTED,
65-
task, taskTitle, null, null);});
64+
reviewers.forEach(reviewer -> {sendNotificationService.sendPushNotification(reviewer, NotificationType.TASK_REQUESTED,
65+
task, null, null);});
6666

6767
sendNotificationService.sendAgitNotification(NotificationType.TASK_REQUESTED,
68-
task, taskTitle, null, null);
68+
task, null, null);
6969
}
7070
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,10 @@ public void validateRequest(UpdateTaskOrderRequest request, TaskStatus targetSta
184184
private void publishNotification(Task task, NotificationType notificationType, String message, String taskTitle) {
185185
List<Member> receivers = List.of(task.getRequester(), task.getProcessor());
186186
receivers.forEach(receiver -> {
187-
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getNickname(), notificationType,
188-
task, taskTitle, message, null);
187+
sendNotificationService.sendPushNotification(receiver, notificationType, task, message, null);
189188
});
190189
sendNotificationService.sendAgitNotification(notificationType,
191-
task, message, taskTitle, null);
190+
task, message, null);
192191
}
193192

194193
}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ public void updateTaskStatus(Long memberId, Long taskId, TaskStatus taskStatus)
8888
Task updateTask = taskService.upsert(task);
8989
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.STATUS_SWITCHED, task, taskStatus.getDescription(), null,null);
9090
commandTaskHistoryPort.save(taskHistory);
91-
92-
String taskTitle = task.getTitle();
93-
publishNotification(updateTask, NotificationType.STATUS_SWITCHED, String.valueOf(updateTask.getTaskStatus()), taskTitle);
91+
publishNotification(updateTask, NotificationType.STATUS_SWITCHED, String.valueOf(updateTask.getTaskStatus()));
9492
}
9593
}
9694

@@ -108,7 +106,7 @@ public void updateTaskProcessor(Long taskId, Long userId, UpdateTaskProcessorReq
108106
commandTaskHistoryPort.save(taskHistory);
109107

110108
String taskTitle = task.getTitle();
111-
publishNotification(updateTask, NotificationType.PROCESSOR_CHANGED, updateTask.getProcessor().getNickname(), taskTitle);
109+
publishNotification(updateTask, NotificationType.PROCESSOR_CHANGED, processor.getNickname());
112110
}
113111

114112
@Transactional
@@ -142,13 +140,13 @@ private List<Attachment> validateAndGetAttachments(List<Long> attachmentIdsToDel
142140
return attachmentsOfTask;
143141
}
144142

145-
private void publishNotification(Task task, NotificationType notificationType, String message, String taskTitle) {
143+
private void publishNotification(Task task, NotificationType notificationType, String message) {
146144
List<Member> receivers = List.of(task.getRequester(), task.getProcessor());
147145
receivers.forEach(receiver -> {
148-
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getEmail(), notificationType,
149-
task, taskTitle, message, null);
146+
sendNotificationService.sendPushNotification(receiver, notificationType,
147+
task, message, null);
150148
});
151149

152-
sendNotificationService.sendAgitNotification(notificationType, task, taskTitle, message, null);
150+
sendNotificationService.sendAgitNotification(notificationType, task, message, null);
153151
}
154152
}

src/main/java/clap/server/application/service/webhook/SendNotificationService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ public class SendNotificationService {
2525
private final CommandNotificationPort commandNotificationPort;
2626

2727
@Async("notificationExecutor")
28-
public void sendPushNotification(Member receiver, String email, NotificationType notificationType,
29-
Task task, String taskTitle, String message, String commenterName) {
28+
public void sendPushNotification(Member receiver, NotificationType notificationType,
29+
Task task, String message, String commenterName) {
30+
String email = receiver.getMemberInfo().getEmail();
31+
String taskTitle = task.getTitle();
3032
String requesterNickname = task.getRequester().getNickname();
3133

3234
Notification notification = createTaskNotification(task, receiver, notificationType, message, taskTitle);
@@ -69,11 +71,11 @@ public void sendPushNotification(Member receiver, String email, NotificationType
6971

7072
@Async("notificationExecutor")
7173
public void sendAgitNotification(NotificationType notificationType,
72-
Task task, String taskTitle, String message, String commenterName) {
74+
Task task, String message, String commenterName) {
7375
PushNotificationTemplate pushNotificationTemplate = new PushNotificationTemplate(
7476
null,
7577
notificationType,
76-
taskTitle,
78+
task.getTitle(),
7779
task.getRequester().getNickname(),
7880
message,
7981
commenterName

0 commit comments

Comments
 (0)