From 56f91da0b28da23461a6c634dfed38d92be4658d Mon Sep 17 00:00:00 2001 From: Jeong-In-Hee Date: Wed, 25 Oct 2023 18:06:40 +0900 Subject: [PATCH] feat: implement allow and deny expiration notifications method --- .../gifthub/auth/service/UserService.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java b/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java index 190026f8..b4e87df5 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java +++ b/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java @@ -191,16 +191,27 @@ public UserInfoResponseDto readInfo(String username) { .username(username) .nickname(user.getNickname()) .oauth(oAuthService.list(user)) - .allowNotifications(isExistDeviceToken(user)) + .allowNotifications(user.isAllowNotifications()) .anonymous(user.isAnonymous()) .build(); return userInfoResponseDto; } /** - * DeviceToken 조회 메서드 (user) + * 알림 동의 여부 허용 메서드 (user) */ - public boolean isExistDeviceToken(User user) { - return !deviceTokenRepository.findAllByUser(user).isEmpty(); + public void allowNotifications(String username) { + User user = read(username); + user.setAllowNotifications(true); + userRepository.save(user); + } + + /** + * 알림 동의 여부 거부 메서드 (user) + */ + public void denyNotifications(String username) { + User user = read(username); + user.setAllowNotifications(false); + userRepository.save(user); } } \ No newline at end of file