@@ -15,26 +15,24 @@ public class KakaoWorkBlockBuilder {
1515 private final ObjectMapper objectMapper ;
1616
1717 public String makeObjectBlock (PushNotificationTemplate request ){
18+ String taskDetailUrl = "https://www.naver.com" ;
1819 return switch (request .notificationType ()) {
19- case TASK_REQUESTED -> makeTaskRequestBlock (request );
20- case STATUS_SWITCHED -> makeTaskStatusBlock (request );
21- case PROCESSOR_CHANGED -> makeProcessorChangeBlock (request );
22- case PROCESSOR_ASSIGNED -> makeNewProcessorBlock (request );
23- case COMMENT -> makeCommentBlock (request );
20+ case TASK_REQUESTED -> makeTaskRequestBlock (request , taskDetailUrl );
21+ case STATUS_SWITCHED -> makeTaskStatusBlock (request , taskDetailUrl );
22+ case PROCESSOR_CHANGED -> makeProcessorChangeBlock (request , taskDetailUrl );
23+ case PROCESSOR_ASSIGNED -> makeNewProcessorBlock (request , taskDetailUrl );
24+ case COMMENT -> makeCommentBlock (request , taskDetailUrl );
2425 default -> null ;
2526 };
2627 }
2728
28- private String makeTaskRequestBlock (PushNotificationTemplate request ) {
29- // Blocks 데이터 생성
29+ private String makeTaskRequestBlock (PushNotificationTemplate request , String taskDetailUrl ) {
3030 Object [] blocks = new Object []{
31- // Header 블록
3231 Map .of (
3332 "type" , "header" ,
3433 "text" , "TaskFlow 작업 요청 알림" ,
3534 "style" , "blue"
3635 ),
37- // Text 블록 1
3836 Map .of (
3937 "type" , "text" ,
4038 "text" , "TaskFlow 작업 요청 알림" ,
@@ -46,7 +44,6 @@ private String makeTaskRequestBlock(PushNotificationTemplate request) {
4644 )
4745 }
4846 ),
49- // Text 블록 2: 제목 변수 사용
5047 Map .of (
5148 "type" , "text" ,
5249 "text" , "TaskFlow 작업 요청 알림" ,
@@ -58,7 +55,6 @@ private String makeTaskRequestBlock(PushNotificationTemplate request) {
5855 )
5956 }
6057 ),
61- // Text 블록 3: 요청자 변수 사용
6258 Map .of (
6359 "type" , "text" ,
6460 "text" , "TaskFlow 작업 요청 알림" ,
@@ -70,15 +66,14 @@ private String makeTaskRequestBlock(PushNotificationTemplate request) {
7066 )
7167 }
7268 ),
73- // Button 블록
7469 Map .of (
7570 "type" , "button" ,
7671 "text" , "확인하기" ,
7772 "style" , "default" ,
7873 "action" , Map .of (
7974 "type" , "open_system_browser" ,
8075 "name" , "button1" ,
81- "value" , "http://example.com/details/999"
76+ "value" , taskDetailUrl
8277 )
8378 )
8479 };
@@ -87,7 +82,7 @@ private String makeTaskRequestBlock(PushNotificationTemplate request) {
8782 try {
8883 payload = "{" +
8984 "\" email\" :\" " + request .email () + "\" ," +
90- "\" text\" : \" 신규 작업 요청 알림\" ," + // fallback 메시지
85+ "\" text\" : \" 신규 작업 요청 알림\" ," +
9186 "\" blocks\" :" + objectMapper .writeValueAsString (blocks ) +
9287 "}" ;
9388 } catch (JsonProcessingException e ) {
@@ -97,7 +92,7 @@ private String makeTaskRequestBlock(PushNotificationTemplate request) {
9792 return payload ;
9893 }
9994
100- private String makeNewProcessorBlock (PushNotificationTemplate request ) {
95+ private String makeNewProcessorBlock (PushNotificationTemplate request , String taskDetailUrl ) {
10196 Object [] blocks = new Object []{
10297 Map .of (
10398 "type" , "header" ,
@@ -144,7 +139,7 @@ private String makeNewProcessorBlock(PushNotificationTemplate request) {
144139 "action" , Map .of (
145140 "type" , "open_system_browser" ,
146141 "name" , "button1" ,
147- "value" , "http://example.com/details/999"
142+ "value" , taskDetailUrl
148143 )
149144 )
150145 };
@@ -153,7 +148,7 @@ private String makeNewProcessorBlock(PushNotificationTemplate request) {
153148 try {
154149 payload = "{" +
155150 "\" email\" :\" " + request .email () + "\" ," +
156- "\" text\" :\" 작업 담당자 선정 알림\" ," + // fallback 메시지
151+ "\" text\" :\" 작업 담당자 선정 알림\" ," +
157152 "\" blocks\" :" + objectMapper .writeValueAsString (blocks ) +
158153 "}" ;
159154 } catch (JsonProcessingException e ) {
@@ -163,7 +158,7 @@ private String makeNewProcessorBlock(PushNotificationTemplate request) {
163158 return payload ;
164159 }
165160
166- private String makeProcessorChangeBlock (PushNotificationTemplate request ) {
161+ private String makeProcessorChangeBlock (PushNotificationTemplate request , String taskDetailUrl ) {
167162 Object [] blocks = new Object []{
168163 Map .of (
169164 "type" , "header" ,
@@ -210,7 +205,7 @@ private String makeProcessorChangeBlock(PushNotificationTemplate request) {
210205 "action" , Map .of (
211206 "type" , "open_system_browser" ,
212207 "name" , "button1" ,
213- "value" , "http://example.com/details/999"
208+ "value" , taskDetailUrl
214209 )
215210 )
216211 };
@@ -219,7 +214,7 @@ private String makeProcessorChangeBlock(PushNotificationTemplate request) {
219214 try {
220215 payload = "{" +
221216 "\" email\" :\" " + request .email () + "\" ," +
222- "\" text\" :\" 작업 담당자 변경 알림\" ," + // fallback 메시지
217+ "\" text\" :\" 작업 담당자 변경 알림\" ," +
223218 "\" blocks\" :" + objectMapper .writeValueAsString (blocks ) +
224219 "}" ;
225220 } catch (JsonProcessingException e ) {
@@ -230,7 +225,7 @@ private String makeProcessorChangeBlock(PushNotificationTemplate request) {
230225 return payload ;
231226 }
232227
233- private String makeCommentBlock (PushNotificationTemplate request ) {
228+ private String makeCommentBlock (PushNotificationTemplate request , String taskDetailUrl ) {
234229 Object [] blocks = new Object []{
235230 Map .of (
236231 "type" , "header" ,
@@ -288,7 +283,7 @@ private String makeCommentBlock(PushNotificationTemplate request) {
288283 "action" , Map .of (
289284 "type" , "open_system_browser" ,
290285 "name" , "button1" ,
291- "value" , "http://example.com/details/999"
286+ "value" , taskDetailUrl
292287 )
293288 )
294289 };
@@ -297,7 +292,7 @@ private String makeCommentBlock(PushNotificationTemplate request) {
297292 try {
298293 payload = "{" +
299294 "\" email\" :\" " + request .email () + "\" ," +
300- "\" text\" :\" 댓글 알림\" ," + // fallback 메시지
295+ "\" text\" :\" 댓글 알림\" ," +
301296 "\" blocks\" :" + objectMapper .writeValueAsString (blocks ) +
302297 "}" ;
303298 } catch (JsonProcessingException e ) {
@@ -307,7 +302,7 @@ private String makeCommentBlock(PushNotificationTemplate request) {
307302 return payload ;
308303 }
309304
310- private String makeTaskStatusBlock (PushNotificationTemplate request ) {
305+ private String makeTaskStatusBlock (PushNotificationTemplate request , String taskDetailUrl ) {
311306 Object [] blocks = new Object []{
312307 Map .of (
313308 "type" , "header" ,
@@ -354,7 +349,7 @@ private String makeTaskStatusBlock(PushNotificationTemplate request) {
354349 "action" , Map .of (
355350 "type" , "open_system_browser" ,
356351 "name" , "button1" ,
357- "value" , "http://example.com/details/999"
352+ "value" , taskDetailUrl
358353 )
359354 )
360355 };
@@ -363,7 +358,7 @@ private String makeTaskStatusBlock(PushNotificationTemplate request) {
363358 try {
364359 payload = "{" +
365360 "\" email\" :\" " + request .email () + "\" ," +
366- "\" text\" :\" 작업 상태 변경 알림\" ," + // fallback 메시지
361+ "\" text\" :\" 작업 상태 변경 알림\" ," +
367362 "\" blocks\" :" + objectMapper .writeValueAsString (blocks ) +
368363 "}" ;
369364 } catch (JsonProcessingException e ) {
0 commit comments