From 38b34f8b12cd0a5ef5ae315a78a613dfc4b93c5c Mon Sep 17 00:00:00 2001 From: Ju Do Hyun Date: Wed, 21 Aug 2024 17:37:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[FEATURE]=20=EC=95=8C=EB=A6=BC=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80,?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=EC=97=90=20url=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mvp/thinkerbell/domain/user/service/FCMService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/depth/mvp/thinkerbell/domain/user/service/FCMService.java b/src/main/java/depth/mvp/thinkerbell/domain/user/service/FCMService.java index 77d7828..7c3304f 100644 --- a/src/main/java/depth/mvp/thinkerbell/domain/user/service/FCMService.java +++ b/src/main/java/depth/mvp/thinkerbell/domain/user/service/FCMService.java @@ -14,7 +14,7 @@ public class FCMService { private final CategoryService categoryService; - public void sendFCMMessage(Alarm alarm, String keyword) { + public void sendFCMMessage(Alarm alarm, String keyword, String url) { try{ String category = categoryService.getCategoryNameInKorean(alarm.getNoticeType()); String cutTitle = cutTitle(alarm.getTitle(), 30); @@ -25,7 +25,8 @@ public void sendFCMMessage(Alarm alarm, String keyword) { Message message = Message.builder() .putData("title", "띵커벨") .putData("body", messageBody) - .putData("notification_id", UUID.randomUUID().toString()) // 고유한 ID + .putData("notification_id", UUID.randomUUID().toString())// 고유한 ID + .putData("url", url) .setToken(alarm.getUser().getFcmToken()) .build(); From 5800d5e9f5b37125c4eebd2985aabf1a6f8cc352 Mon Sep 17 00:00:00 2001 From: Ju Do Hyun Date: Wed, 21 Aug 2024 17:37:27 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[FEATURE]=20=EC=95=8C=EB=A6=BC=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80,?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=EC=97=90=20url=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/service/AlarmService.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/depth/mvp/thinkerbell/domain/user/service/AlarmService.java b/src/main/java/depth/mvp/thinkerbell/domain/user/service/AlarmService.java index d3d0ffe..2c31777 100644 --- a/src/main/java/depth/mvp/thinkerbell/domain/user/service/AlarmService.java +++ b/src/main/java/depth/mvp/thinkerbell/domain/user/service/AlarmService.java @@ -76,7 +76,11 @@ public void updateNoticeAndMatchKeyword(){ alarmRepository.save(alarm); - fcmService.sendFCMMessage(alarm, keyword.getKeyword()); + Map noticeDetails = getNoticeDetails(alarm.getNoticeType(), alarm.getNoticeID()); + + String url = (String) noticeDetails.get("url"); + + fcmService.sendFCMMessage(alarm, keyword.getKeyword(), url); } catch (Exception e) { throw new RuntimeException("유저 알림을 저장하거나, fcm 알림을 보내는 도중 오류가 발생했습니다.", e); } @@ -109,7 +113,7 @@ public void updateNoticeAndMatchKeyword(){ } } - public void updateNoticeAndMatchKeywordTest(){ + public void updateNoticeAndMatchKeywordTest(String ssaid, String key){ List crawlingNums; try { @@ -119,6 +123,9 @@ public void updateNoticeAndMatchKeywordTest(){ } for (CrawlingNum crawlingNum : crawlingNums) { + crawlingNum.setNoticeID(0L); + crawlingNumRepository.save(crawlingNum); + List allNoticesViews; try { @@ -136,7 +143,14 @@ public void updateNoticeAndMatchKeywordTest(){ try{ Alarm alarm = new Alarm(notice.getId(), notice.getTableName(), keyword.getUser(), notice.getTitle(), keyword.getKeyword()); - fcmService.sendFCMMessage(alarm, keyword.getKeyword()); + Map noticeDetails = getNoticeDetails(alarm.getNoticeType(), alarm.getNoticeID()); + + String url = (String) noticeDetails.get("url"); + + if (ssaid.equals(keyword.getUser().getSsaid()) && key.equals(keyword.getKeyword())){ + fcmService.sendFCMMessage(alarm, keyword.getKeyword(), url); + } + } catch (Exception e) { throw new RuntimeException("유저 알림을 저장하거나, fcm 알림을 보내는 도중 오류가 발생했습니다.", e); } From 51c3bdbb2bc13d8c54cd407c2f16a999668ed83d Mon Sep 17 00:00:00 2001 From: Ju Do Hyun Date: Wed, 21 Aug 2024 17:37:32 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[FEATURE]=20=EC=95=8C=EB=A6=BC=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/depth/mvp/thinkerbell/TestController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/depth/mvp/thinkerbell/TestController.java b/src/main/java/depth/mvp/thinkerbell/TestController.java index 31c86b9..f210b73 100644 --- a/src/main/java/depth/mvp/thinkerbell/TestController.java +++ b/src/main/java/depth/mvp/thinkerbell/TestController.java @@ -1,5 +1,6 @@ package depth.mvp.thinkerbell; +import depth.mvp.thinkerbell.domain.user.service.AlarmService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -12,9 +13,16 @@ @CrossOrigin("*") public class TestController { + private final AlarmService alarmService; + @GetMapping("/test") public String test(){ return "배포 CD 테스트"; } + @GetMapping("/alarm-test") + public void testAlarm(String ssaid, String keyword){ + alarmService.updateNoticeAndMatchKeywordTest(ssaid, keyword); + } + }