Skip to content

Commit

Permalink
Merge pull request #281 from PLADI-ALM/feat/PDS-164-send-notification
Browse files Browse the repository at this point in the history
[PDS-164/feat] 푸쉬 알림 message body 수정
  • Loading branch information
dangnak2 authored Dec 3, 2023
2 parents cae0448 + 6268579 commit 871b38b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void rejectProductBooking(User user, Long carBookingId) {
emailUtil.createBookingData(SendEmailReq.toDto(carBooking, REJECT_BOOKING_TEXT)), BOOKING_TEMPLATE);
// 차랑 예약 반려 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.CAR, Constants.Notification.BODY_DENIED, user);
notificationService.sendNotification(carBooking.getCar().getName(), Constants.NotificationCategory.CAR, Constants.Notification.BODY_DENIED, user);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -148,7 +148,7 @@ private void sendReturnNotification(User user, CarBooking carBooking) {
emailUtil.createBookingData(SendEmailReq.toDto(carBooking, RETURN_BOOKING_TEXT)), BOOKING_TEMPLATE);
// 차랑 예약 반납 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.CAR, Constants.Notification.BODY_RETURNED, user);
notificationService.sendNotification(carBooking.getCar().getName(), Constants.NotificationCategory.CAR, Constants.Notification.BODY_RETURNED, user);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public void cancelBookingProduct(User user, Long carBookingId) {

// 차량 예약 취소 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.CAR, Constants.Notification.BODY_CANCELED, user);
notificationService.sendNotification(carBooking.getCar().getName(), Constants.NotificationCategory.CAR, Constants.Notification.BODY_CANCELED, user);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void cancelBookingOffice(User user, Long officeBookingId) {

// 회의실 예약 취소 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_CANCELED, user);
notificationService.sendNotification(officeBooking.getOffice().getName(), Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_CANCELED, user);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public void cancelBookingOfficeByAdmin(User user, Long officeBookingId) {

// 회의실 예약 반려 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_DENIED, user);
notificationService.sendNotification(officeBooking.getOffice().getName(), Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_DENIED, user);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void cancelBookingProduct(User user, Long resourceBookingId) {

// 장비 예약 취소 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_CANCELED, user);
notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_CANCELED, user);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -175,7 +175,7 @@ public void rejectProductBooking(User user, Long resourceBookingId) {

// 장비 예약 반려 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_DENIED, resourceBooking.getUser());
notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_DENIED, resourceBooking.getUser());
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -201,7 +201,7 @@ public void allowProductBooking(User user, Long resourceBookingId) {
emailUtil.createBookingData(SendEmailReq.toDto(resourceBooking, APPROVE_BOOKING_TEXT)), BOOKING_TEMPLATE);
// 장비 예약 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resourceBooking.getResource().getUser());
notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resourceBooking.getResource().getUser());
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -225,7 +225,7 @@ private void sendReturnNotification(User user, ResourceBooking resourceBooking)
emailUtil.createBookingData(SendEmailReq.toDto(resourceBooking, RETURN_BOOKING_TEXT)), BOOKING_TEMPLATE);
// 장비 반납 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_RETURNED, user);
notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_RETURNED, user);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ public static class NotificationCategory{
}

public static class Notification {
public static final String BODY_SUCCESS = "예약이 완료되었습니다.";
public static final String SPACE = " ";
public static final String BODY_SUCCESS = "예약이 승인되었습니다.";
public static final String BODY_DENIED = "예약이 반려되었습니다.";
public static final String BODY_CANCELED = "예약이 취소되었습니다.";
public static final String BODY_RETURNED = "예약이 종료되었습니다.";
public static final String BODY_RETURNED = "반납 확인되었습니다.";
public static final String TITLE_SUCCESS = "예약 완료";
public static final String TITLE_DENIED = "예약 반려";
public static final String TITLE_CANCELED = "예약 취소";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public class PushNotificationService {
private final EmailUtil emailUtil;

@Transactional
public void sendNotification(String category, String type, User user) throws IOException {
public void sendNotification(String name, String category, String type, User user) throws IOException {
String title = getTitle(category, type);
String messageBody = category + type;
String messageBody = name + Constants.Notification.SPACE + type;
if (user.getFcmToken() != null) {
FcmMessage fcmMessage = FcmMessage.makeMessage(user.getFcmToken(), title, messageBody);
Response response = sendMessage(objectMapper.writeValueAsString(fcmMessage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void bookProduct(User user, Long resourceId, ProductReq productReq) {
emailUtil.createBookingData(SendEmailReq.toDto(carBooking, NEW_BOOKING_TEXT)), BOOKING_TEMPLATE);
// 차량 예약 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, car.getUser());
notificationService.sendNotification(car.getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, car.getUser());
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void bookProduct(User user, Long resourceId, ProductReq productReq) {

// 차량 예약 알림
try {
notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resource.getUser());
notificationService.sendNotification(resource.getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resource.getUser());
} catch (IOException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 871b38b

Please sign in to comment.