Skip to content

Commit

Permalink
[HOTFIX] 알림에 id 데이터 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Jan 6, 2024
1 parent 8074c9c commit 58425da
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.UUID;

@Getter
@ToString
@NoArgsConstructor
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 58425da

Please sign in to comment.