Skip to content

Commit

Permalink
#333 fix: 알림 저장 로직 순서 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
sojungpp committed Aug 6, 2024
1 parent 340b697 commit c613918
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,30 @@ public class NotificationServiceImpl implements NotificationService {
@Transactional
@Override
public void sendWithdrawalAlarm(User user, String fridgeName) {
if (user.getFcmToken() == null) return;
String messageBody = fridgeName + "에서 탈퇴되었습니다.";
fcmUtils.sendMessage((user.getFcmToken()), Constant.PushNotification.FRIDGE, messageBody);
if (user.getFcmToken() != null) {
fcmUtils.sendMessage((user.getFcmToken()), Constant.PushNotification.FRIDGE, messageBody);
}
this.notificationRepository.save(PushNotification.toEntity(Constant.PushNotification.FRIDGE, messageBody, user));
}

@Transactional
@Override
public void sendJoinFridgeAlarm(User user, String fridgeName) {
if (user.getFcmToken() == null) return;
String messageBody = fridgeName + "에서 초대되었습니다.";
fcmUtils.sendMessage((user.getFcmToken()), Constant.PushNotification.FRIDGE, messageBody);
if (user.getFcmToken() != null) {
fcmUtils.sendMessage((user.getFcmToken()), Constant.PushNotification.FRIDGE, messageBody);
}
this.notificationRepository.save(PushNotification.toEntity(Constant.PushNotification.FRIDGE, messageBody, user));
}

@Transactional
@Override
public void sendShelfLifeAlarm(User user, String fridgeName, String foodName) throws IOException {
if (user.getFcmToken() == null) return;
String messageBody = foodName + " 소비기한이 임박해요!";
fcmUtils.sendMessage((user.getFcmToken()), fridgeName, messageBody);
if (user.getFcmToken() != null) {
fcmUtils.sendMessage((user.getFcmToken()), fridgeName, messageBody);
}
this.notificationRepository.save(PushNotification.toEntity(fridgeName, messageBody, user));
}
}

0 comments on commit c613918

Please sign in to comment.