From 58425dac0661aa00f4170d81e4b51615a460e781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Sun, 7 Jan 2024 00:57:11 +0900 Subject: [PATCH] =?UTF-8?q?[HOTFIX]=20=EC=95=8C=EB=A6=BC=EC=97=90=20id=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/service/FriendService.java | 7 ++++--- .../backend/domain/group/service/GroupService.java | 8 +++++--- .../notification/dto/NotificationRequest.java | 5 +++++ .../backend/domain/plan/service/PlanService.java | 14 ++++++++------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java b/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java index ccab37a7..42388bff 100644 --- a/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java +++ b/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java @@ -38,15 +38,16 @@ public void addRequest(final FriendRequest friendRequest) { final Member member = memberService.getMemberById(friendRequest.getMemberId()); friendRepository.save(friendMapper.toEntity(loginMember, member)); - sendNotification(member.getDeviceTokenValue(), loginMember.getNickname()); + sendNotification(member.getDeviceTokenValue(), loginMember.getNickname(), loginMember.getId()); } - private void sendNotification(final String deviceToken, final String nickname) { + private void sendNotification(final String deviceToken, final String nickname, final UUID id) { fcmProducer.sendNotification( new NotificationRequest( deviceToken, NotificationTitle.FRIEND_REQUEST_TITLE.getName(), - NotificationBody.FRIEND_REQUEST_BODY.toNotificationBody(nickname))); + NotificationBody.FRIEND_REQUEST_BODY.toNotificationBody(nickname), + id)); } @Transactional diff --git a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java index 9e4121ea..7b442b5b 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java @@ -119,17 +119,19 @@ public GroupInfoResponse inviteGroup(InviteGroupRequest inviteGroupRequest) { group.inviteAll(friends); String groupName = group.getName(); - friends.forEach(friend -> sendNotification(friend.getDeviceTokenValue(), groupName)); + final UUID id = group.getId(); + friends.forEach(friend -> sendNotification(friend.getDeviceTokenValue(), groupName, id)); return groupMapper.toGroupInfo(group); } - private void sendNotification(final String deviceToken, final String groupName) { + private void sendNotification(final String deviceToken, final String groupName, final UUID id) { fcmProducer.sendNotification( new NotificationRequest( deviceToken, NotificationTitle.GROUP_REQUEST_TITLE.getName(), - NotificationBody.GROUP_REQUEST_BODY.toNotificationBody(groupName))); + NotificationBody.GROUP_REQUEST_BODY.toNotificationBody(groupName), + id)); } public GroupInfoResponse getGroupInfoResponse(Group group) { diff --git a/backend/src/main/java/com/twtw/backend/domain/notification/dto/NotificationRequest.java b/backend/src/main/java/com/twtw/backend/domain/notification/dto/NotificationRequest.java index a962e383..f9cdad80 100644 --- a/backend/src/main/java/com/twtw/backend/domain/notification/dto/NotificationRequest.java +++ b/backend/src/main/java/com/twtw/backend/domain/notification/dto/NotificationRequest.java @@ -10,6 +10,8 @@ import lombok.NoArgsConstructor; import lombok.ToString; +import java.util.UUID; + @Getter @ToString @NoArgsConstructor @@ -21,16 +23,19 @@ public class NotificationRequest { .putHeader("apns-priority", "5") .setAps(Aps.builder().setBadge(1).build()) .build(); + private static final String ID = "id"; private String deviceToken; private String title; private String body; + private UUID id; public Message toMessage() { return Message.builder() .setApnsConfig(APNS_CONFIG) .setToken(deviceToken) .setNotification(toNotification()) + .putData(ID, id.toString()) .build(); } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java index c4f5d85c..1b31ceb4 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java @@ -100,17 +100,18 @@ public PlanResponse invitePlan(PlanMemberRequest request) { Plan plan = getPlanEntity(request.getPlanId()); plan.addMember(member); - sendRequestNotification(member.getDeviceTokenValue(), plan.getName()); + sendRequestNotification(member.getDeviceTokenValue(), plan.getName(), plan.getId()); return planMapper.toPlanResponse(plan); } - private void sendRequestNotification(final String deviceToken, final String planName) { + private void sendRequestNotification(final String deviceToken, final String planName, final UUID id) { fcmProducer.sendNotification( new NotificationRequest( deviceToken, NotificationTitle.PLAN_REQUEST_TITLE.getName(), - NotificationBody.PLAN_REQUEST_BODY.toNotificationBody(planName))); + NotificationBody.PLAN_REQUEST_BODY.toNotificationBody(planName), + id)); } public void outPlan(PlanMemberRequest request) { @@ -186,17 +187,18 @@ public void updatePlan(final UpdatePlanRequest updatePlanRequest) { .forEach( planMember -> sendDestinationNotification( - planMember.getDeviceTokenValue(), placeName)); + planMember.getDeviceTokenValue(), placeName, plan.getId())); } private void sendDestinationNotification( - final String deviceToken, final String destinationName) { + final String deviceToken, final String destinationName, final UUID id) { fcmProducer.sendNotification( new NotificationRequest( deviceToken, NotificationTitle.DESTINATION_CHANGE_TITLE.getName(), NotificationBody.DESTINATION_CHANGE_BODY.toNotificationBody( - destinationName))); + destinationName), + id)); } @Transactional