Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -40,7 +41,7 @@ public void createComment(

@Operation(summary = "댓글 작성(첨부 파일)")
@Parameter(name = "taskId", description = "댓글 작성할 작업 고유 ID", required = true, in = ParameterIn.PATH)
@PostMapping("/attachment/{taskId}")
@PostMapping(value = "/attachment/{taskId}", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
@Secured({"ROLE_MANAGER", "ROLE_USER"})
public void createAttachmentComment(
@AuthenticationPrincipal SecurityUserDetails userInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ public void save(Long userId, Long taskId, CreateCommentRequest request) {
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.COMMENT, task, null, member, savedComment);
commandTaskHistoryPort.save(taskHistory);

String taskTitle = task.getTitle();
Member receiver;
Member processor = task.getProcessor();
Member requester = task.getRequester();
if (member.getMemberInfo().getRole() == MemberRole.ROLE_USER) {
receiver = task.getProcessor();
publishNotification(receiver, task, request.content(), member.getNickname(), taskTitle, receiver.getMemberInfo().getEmail());
publishNotification(processor, task, request.content(), requester.getNickname());
} else {
receiver = task.getRequester();
publishNotification(receiver, task, request.content(), receiver.getNickname(), taskTitle, receiver.getMemberInfo().getEmail());
publishNotification(requester, task, request.content(), processor.getNickname());
}
}
}
Expand All @@ -77,12 +75,12 @@ public void saveCommentAttachment(Long userId, Long taskId, MultipartFile file)
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.COMMENT_FILE, task, null, member, savedComment);
commandTaskHistoryPort.save(taskHistory);

Member processor = task.getProcessor();
Member requester = task.getRequester();
if (member.getMemberInfo().getRole() == MemberRole.ROLE_USER) {
Member receiver = task.getProcessor();
publishNotification(receiver, task, fileName + "(첨부파일)", member.getNickname(), task.getTitle(), receiver.getMemberInfo().getEmail());
publishNotification(processor, task, fileName + "(첨부파일)", requester.getNickname());
} else {
Member receiver = task.getRequester();
publishNotification(receiver, task, fileName + "(첨부파일)", task.getProcessor().getNickname(), task.getTitle(), receiver.getMemberInfo().getEmail());
publishNotification(requester, task, fileName + "(첨부파일)", processor.getNickname());
}
}
}
Expand All @@ -94,8 +92,7 @@ private String saveAttachment(MultipartFile file, Task task, Comment comment) {
return file.getOriginalFilename();
}

private void publishNotification(Member receiver, Task task, String message, String commenterName, String taskTitle, String email) {
sendNotificationService.sendPushNotification(receiver, email, NotificationType.COMMENT, task, taskTitle, message, commenterName);
private void publishNotification(Member receiver, Task task, String message, String commenterName) {
sendNotificationService.sendPushNotification(receiver, NotificationType.COMMENT, task, message, commenterName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public ApprovalTaskResponse approvalTaskByReviewer(Long reviewerId, Long taskId,
commandTaskHistoryPort.save(taskHistory);

List<Member> receivers = List.of(reviewer, processor);
String processorName = task.getProcessor().getNickname();
publishNotification(receivers, task, task.getTitle(), processorName);
String processorName = processor.getNickname();
publishNotification(receivers, task, processorName);

return TaskResponseMapper.toApprovalTaskResponse(taskService.upsert(task));
}
Expand All @@ -71,13 +71,13 @@ public FindApprovalFormResponse findApprovalForm(Long managerId, Long taskId) {
return TaskResponseMapper.toFindApprovalFormResponse(task);
}

private void publishNotification(List<Member> receivers, Task task, String taskTitle, String processorName){
private void publishNotification(List<Member> receivers, Task task, String processorName){
receivers.forEach(receiver -> {
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getEmail(), NotificationType.PROCESSOR_ASSIGNED,
task, taskTitle, processorName, null);
sendNotificationService.sendPushNotification(receiver, NotificationType.PROCESSOR_ASSIGNED,
task, processorName, null);
});
sendNotificationService.sendAgitNotification(NotificationType.PROCESSOR_CHANGED,
task, taskTitle, processorName, null);
task, processorName, null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CreateTaskResponse createTask(Long requesterId, CreateTaskRequest createT

if (files != null) {
saveAttachments(files, savedTask);}
publishNotification(savedTask, savedTask.getTitle());
publishNotification(savedTask);
return TaskResponseMapper.toCreateTaskResponse(savedTask);
}

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

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

sendNotificationService.sendAgitNotification(NotificationType.TASK_REQUESTED,
task, taskTitle, null, null);
task, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ public void validateRequest(UpdateTaskOrderRequest request, TaskStatus targetSta
private void publishNotification(Task task, NotificationType notificationType, String message, String taskTitle) {
List<Member> receivers = List.of(task.getRequester(), task.getProcessor());
receivers.forEach(receiver -> {
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getNickname(), notificationType,
task, taskTitle, message, null);
sendNotificationService.sendPushNotification(receiver, notificationType, task, message, null);
});
sendNotificationService.sendAgitNotification(notificationType,
task, message, taskTitle, null);
task, message, null);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public void updateTaskStatus(Long memberId, Long taskId, TaskStatus taskStatus)
Task updateTask = taskService.upsert(task);
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.STATUS_SWITCHED, task, taskStatus.getDescription(), null,null);
commandTaskHistoryPort.save(taskHistory);

String taskTitle = task.getTitle();
publishNotification(updateTask, NotificationType.STATUS_SWITCHED, String.valueOf(updateTask.getTaskStatus()), taskTitle);
publishNotification(updateTask, NotificationType.STATUS_SWITCHED, String.valueOf(updateTask.getTaskStatus()));
}
}

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

String taskTitle = task.getTitle();
publishNotification(updateTask, NotificationType.PROCESSOR_CHANGED, updateTask.getProcessor().getNickname(), taskTitle);
publishNotification(updateTask, NotificationType.PROCESSOR_CHANGED, processor.getNickname());
}

@Transactional
Expand Down Expand Up @@ -142,13 +140,13 @@ private List<Attachment> validateAndGetAttachments(List<Long> attachmentIdsToDel
return attachmentsOfTask;
}

private void publishNotification(Task task, NotificationType notificationType, String message, String taskTitle) {
private void publishNotification(Task task, NotificationType notificationType, String message) {
List<Member> receivers = List.of(task.getRequester(), task.getProcessor());
receivers.forEach(receiver -> {
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getEmail(), notificationType,
task, taskTitle, message, null);
sendNotificationService.sendPushNotification(receiver, notificationType,
task, message, null);
});

sendNotificationService.sendAgitNotification(notificationType, task, taskTitle, message, null);
sendNotificationService.sendAgitNotification(notificationType, task, message, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public class SendNotificationService {
private final CommandNotificationPort commandNotificationPort;

@Async("notificationExecutor")
public void sendPushNotification(Member receiver, String email, NotificationType notificationType,
Task task, String taskTitle, String message, String commenterName) {
public void sendPushNotification(Member receiver, NotificationType notificationType,
Task task, String message, String commenterName) {
String email = receiver.getMemberInfo().getEmail();
String taskTitle = task.getTitle();
String requesterNickname = task.getRequester().getNickname();

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

@Async("notificationExecutor")
public void sendAgitNotification(NotificationType notificationType,
Task task, String taskTitle, String message, String commenterName) {
Task task, String message, String commenterName) {
PushNotificationTemplate pushNotificationTemplate = new PushNotificationTemplate(
null,
notificationType,
taskTitle,
task.getTitle(),
task.getRequester().getNickname(),
message,
commenterName
Expand Down