Skip to content

Commit cbb584d

Browse files
committed
CLAP-304 Fix : Agit 푸시 알림 redirection url 연결
1 parent 06c24b9 commit cbb584d

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

src/main/java/clap/server/adapter/outbound/api/AgitClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public class AgitClient implements SendAgitPort {
2929
private final ObjectMapper objectMapper;
3030

3131
@Override
32-
public Long sendAgit(PushNotificationTemplate request, Task task) {
32+
public Long sendAgit(PushNotificationTemplate request, Task task, String taskDetailUrl) {
3333

34-
HttpEntity<String> entity = agitTemplateBuilder.createAgitEntity(request, task);
34+
HttpEntity<String> entity = agitTemplateBuilder.createAgitEntity(request, task, taskDetailUrl);
3535

3636
RestTemplate restTemplate = new RestTemplate();
3737
if (request.notificationType() == NotificationType.TASK_REQUESTED) {

src/main/java/clap/server/adapter/outbound/api/AgitTemplateBuilder.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
@Component
1111
public class AgitTemplateBuilder {
1212

13-
public HttpEntity<String> createAgitEntity(PushNotificationTemplate request, Task task) {
14-
return new HttpEntity<>(createPayLoad(request, task), createHeaders());
13+
public HttpEntity<String> createAgitEntity(PushNotificationTemplate request, Task task, String taskDetailUrl) {
14+
return new HttpEntity<>(createPayLoad(request, task, taskDetailUrl), createHeaders());
1515
}
1616

1717

@@ -21,41 +21,40 @@ public HttpHeaders createHeaders() {
2121
return headers;
2222
}
2323

24-
public String createPayLoad(PushNotificationTemplate request, Task task) {
24+
public String createPayLoad(PushNotificationTemplate request, Task task, String taskDetailUrl) {
2525

2626
String payload;
2727
if (request.notificationType() == NotificationType.TASK_REQUESTED) {
2828
payload = "{"
29-
+ "\"text\": \"" + createMessage(request) + "\","
29+
+ "\"text\": \"" + createMessage(request, taskDetailUrl) + "\","
3030
+ "\"mrkdwn\": true" + "}";
3131
}
3232

3333
else {
3434
payload = "{"
3535
+ "\"parent_id\": " + task.getAgitPostId() + ","
36-
+ "\"text\": \"" + createMessage(request) + "\","
36+
+ "\"text\": \"" + createMessage(request, taskDetailUrl) + "\","
3737
+ "\"mrkdwn\": true"
3838
+ "}";
3939
}
4040
return payload;
4141
}
4242

43-
public String createMessage(PushNotificationTemplate request) {
44-
String taskUrl = "https://www.naver.com"; //Todo 작업 상세페이지 url 추가
43+
public String createMessage(PushNotificationTemplate request, String taskDetailUrl) {
4544

4645
return switch (request.notificationType()) {
4746
case TASK_REQUESTED -> "📌 *새 작업 요청:* `" + request.taskName() + "`\\n"
4847
+ "\\t\\t*•요청자: " + request.senderName() + "*\\n"
49-
+ "\\t\\t[OPEN](" + taskUrl + ")";
48+
+ "[확인하러 가기](" + taskDetailUrl + ")";
5049
case STATUS_SWITCHED -> "⚙️ *작업 상태 변경:* `" + request.taskName() + "\\n"
5150
+ "\\t\\t*•작업 상태: " + request.message() + "*\\n"
52-
+ "\\t\\t[OPEN](" + taskUrl + ")";
51+
+ "[확인하러 가기](" + taskDetailUrl + ")";
5352
case PROCESSOR_CHANGED -> "🔄 *담당자 변경:* `" + request.taskName() + "\\n"
5453
+ "\\t\\t*•새 담당자: " + request.message() + "*\\n"
55-
+ "\\t\\t[OPEN](" + taskUrl + ")";
54+
+ "[확인하러 가기](" + taskDetailUrl + ")";
5655
case PROCESSOR_ASSIGNED -> "👤 *작업 담당자 배정:* `" + request.taskName() + "\\n"
5756
+ "\\t\\t*•담당자: " + request.message() + "*\\n"
58-
+ "\\t\\t[OPEN](" + taskUrl + ")";
57+
+ "[확인하러 가기](" + taskDetailUrl + ")";
5958
default -> null;
6059
};
6160
}

src/main/java/clap/server/application/port/outbound/webhook/SendAgitPort.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
import clap.server.domain.model.task.Task;
55

66
public interface SendAgitPort {
7-
Long sendAgit(PushNotificationTemplate request, Task task);
7+
Long sendAgit(PushNotificationTemplate request, Task task, String taskDetailUrl);
88
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class SendAgitService {
1515
private final SendAgitPort agitPort;
1616
private final TaskService taskService;
1717

18-
public void sendAgit(PushNotificationTemplate request, Task task) {
19-
Long agitPostId = agitPort.sendAgit(request, task);
18+
public void sendAgit(PushNotificationTemplate request, Task task, String taskDetailUrl) {
19+
Long agitPostId = agitPort.sendAgit(request, task, taskDetailUrl);
2020

2121
if (request.notificationType().equals(NotificationType.TASK_REQUESTED)) {
2222
task.updateAgitPostId(agitPostId);

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@RequiredArgsConstructor
1919
public class SendNotificationService {
2020

21-
private final SendSseService sendSseService;
21+
//private final SendSseService sendSseService;
2222
private final SendAgitService sendAgitService;
2323
private final SendWebhookEmailService sendWebhookEmailService;
2424
private final SendKaKaoWorkService sendKaKaoWorkService;
@@ -74,19 +74,6 @@ public void sendPushNotification(Member receiver, NotificationType notificationT
7474
allOf.join();
7575
}
7676

77-
private String extractTaskUrl(NotificationType notificationType, Task task, Boolean isManager) {
78-
String taskDetailUrl = "http://localhost:5173/my-request?taskId=" + task.getTaskId();
79-
if (isManager) {
80-
if (notificationType == NotificationType.TASK_REQUESTED) {
81-
taskDetailUrl = "http://localhost:5173/requested?taskId=" + task.getTaskId();
82-
}
83-
else {
84-
taskDetailUrl = "http://localhost:5173/my-task?taskId=" + task.getTaskId();
85-
}
86-
}
87-
return taskDetailUrl;
88-
}
89-
9077
@Async("notificationExecutor")
9178
public void sendAgitNotification(NotificationType notificationType,
9279
Task task, String message, String commenterName) {
@@ -98,6 +85,22 @@ public void sendAgitNotification(NotificationType notificationType,
9885
message,
9986
commenterName
10087
);
101-
sendAgitService.sendAgit(pushNotificationTemplate, task);
88+
89+
String taskDetailUrl = extractTaskUrl(notificationType, task, true);
90+
91+
sendAgitService.sendAgit(pushNotificationTemplate, task, taskDetailUrl);
92+
}
93+
94+
private String extractTaskUrl(NotificationType notificationType, Task task, Boolean isManager) {
95+
String taskDetailUrl = "http://localhost:5173/my-request?taskId=" + task.getTaskId();
96+
if (isManager) {
97+
if (notificationType == NotificationType.TASK_REQUESTED) {
98+
taskDetailUrl = "http://localhost:5173/requested?taskId=" + task.getTaskId();
99+
}
100+
else {
101+
taskDetailUrl = "http://localhost:5173/my-task?taskId=" + task.getTaskId();
102+
}
103+
}
104+
return taskDetailUrl;
102105
}
103106
}

0 commit comments

Comments
 (0)