diff --git a/src/main/java/com/project/qvick/domain/auth/client/api/AuthController.java b/src/main/java/com/project/qvick/domain/auth/client/api/AuthController.java index b0c72017..1637fd13 100644 --- a/src/main/java/com/project/qvick/domain/auth/client/api/AuthController.java +++ b/src/main/java/com/project/qvick/domain/auth/client/api/AuthController.java @@ -62,10 +62,4 @@ public BaseResponseData refresh(RefreshTokenRequest reques authService.refresh(request.getRefreshToken())); } -// @PostMapping("/firebase") -// @Operation(summary = "firebase 인증", description = "firebase 인증 서비스") -// public void firebase(@Validated @RequestBody FirebaseRequest request){ -// authService.firebase(request); -// } - } diff --git a/src/main/java/com/project/qvick/domain/auth/service/AuthServiceImpl.java b/src/main/java/com/project/qvick/domain/auth/service/AuthServiceImpl.java index 3932c296..21a00a76 100644 --- a/src/main/java/com/project/qvick/domain/auth/service/AuthServiceImpl.java +++ b/src/main/java/com/project/qvick/domain/auth/service/AuthServiceImpl.java @@ -10,7 +10,6 @@ import com.project.qvick.domain.user.domain.mapper.UserMapper; import com.project.qvick.domain.user.domain.repository.jpa.UserRepository; import com.project.qvick.domain.user.exception.PasswordWrongException; -import com.project.qvick.domain.user.exception.UserNotFoundException; import com.project.qvick.global.security.jwt.JwtExtract; import com.project.qvick.global.security.jwt.JwtProvider; import com.project.qvick.global.security.jwt.enums.JwtType; @@ -83,14 +82,4 @@ public RefreshTokenResponse refresh(String token) { (UserRole) claims.getHeader().get("authority"))).build(); } -/* - @Override - public void firebase(FirebaseRequest request){ - User user = userUtil.findUser(); - if(StringUtils.hasText(request.getFcmToken())){ - firebaseNotificationService.saveToken(user.getEmail(), request.getFcmToken()); - } - } -*/ - } diff --git a/src/main/java/com/project/qvick/global/infra/firebase/config/FirebaseConfig.java b/src/main/java/com/project/qvick/global/infra/firebase/config/FirebaseConfig.java deleted file mode 100644 index a7d0d2ee..00000000 --- a/src/main/java/com/project/qvick/global/infra/firebase/config/FirebaseConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.project.qvick.global.infra.firebase.config; - -import com.google.auth.oauth2.GoogleCredentials; -import com.google.firebase.FirebaseApp; -import com.google.firebase.FirebaseOptions; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.messaging.FirebaseMessaging; -import jakarta.annotation.PostConstruct; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.ResourcePatternUtils; - -import java.io.IOException; -import java.io.InputStream; - -@Configuration -public class FirebaseConfig { - - @Value("${firebase.sdk.path}") - private String firebaseSdkPath; - private FirebaseApp firebaseApp; - - @PostConstruct - public FirebaseApp initializeFCM() throws IOException { - Resource resource = ResourcePatternUtils.getResourcePatternResolver(new DefaultResourceLoader()).getResource("classpath:/" + firebaseSdkPath); - InputStream is = resource.getInputStream(); - FirebaseOptions options = new FirebaseOptions.Builder() - .setCredentials(GoogleCredentials.fromStream(is)) - .build(); - firebaseApp = FirebaseApp.initializeApp(options); - return firebaseApp; - } - - @Bean - public FirebaseAuth initFirebaseAuth() { - FirebaseAuth instance = FirebaseAuth.getInstance(firebaseApp); - return instance; - } - - @Bean - public FirebaseMessaging initFirebaseMessaging() { - FirebaseMessaging instance = FirebaseMessaging.getInstance(firebaseApp); - return instance; - } - -} diff --git a/src/main/java/com/project/qvick/global/infra/firebase/config/FirebaseNotificationConfig.java b/src/main/java/com/project/qvick/global/infra/firebase/config/FirebaseNotificationConfig.java deleted file mode 100644 index bdc81338..00000000 --- a/src/main/java/com/project/qvick/global/infra/firebase/config/FirebaseNotificationConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.project.qvick.global.infra.firebase.config; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Getter -@Setter -@Configuration -@ConfigurationProperties(prefix = "firebase.notification") -public class FirebaseNotificationConfig { - - private String nonCheckTitle; - private String nonCheckMessage; - -} diff --git a/src/main/java/com/project/qvick/global/infra/firebase/domain/repository/FirebaseTokenRepository.java b/src/main/java/com/project/qvick/global/infra/firebase/domain/repository/FirebaseTokenRepository.java deleted file mode 100644 index 0682239b..00000000 --- a/src/main/java/com/project/qvick/global/infra/firebase/domain/repository/FirebaseTokenRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.project.qvick.global.infra.firebase.domain.repository; - -public interface FirebaseTokenRepository { - - void saveToken(final String email, final String token); - - String getToken(final String email); - - void deleteToken(final String email); - - boolean hasKey(final String email); - -} diff --git a/src/main/java/com/project/qvick/global/infra/firebase/domain/repository/FirebaseTokenRepositoryImpl.java b/src/main/java/com/project/qvick/global/infra/firebase/domain/repository/FirebaseTokenRepositoryImpl.java deleted file mode 100644 index 7b6f8884..00000000 --- a/src/main/java/com/project/qvick/global/infra/firebase/domain/repository/FirebaseTokenRepositoryImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.project.qvick.global.infra.firebase.domain.repository; - -import lombok.RequiredArgsConstructor; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -@Repository -@RequiredArgsConstructor -public class FirebaseTokenRepositoryImpl implements FirebaseTokenRepository { - - private final StringRedisTemplate redisTemplate; - - public void saveToken(final String email, final String token) { - redisTemplate.opsForValue().set(email, token); - } - - public String getToken(final String email) { - return redisTemplate.opsForValue().get(email); - } - - public void deleteToken(final String email) { - redisTemplate.delete(email); - } - - public boolean hasKey(final String email) { - return redisTemplate.hasKey(email); - } - -} diff --git a/src/main/java/com/project/qvick/global/infra/firebase/dto/FirebaseNotification.java b/src/main/java/com/project/qvick/global/infra/firebase/dto/FirebaseNotification.java deleted file mode 100644 index e724ee56..00000000 --- a/src/main/java/com/project/qvick/global/infra/firebase/dto/FirebaseNotification.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.project.qvick.global.infra.firebase.dto; - -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Getter -@Setter -@Builder -public class FirebaseNotification { - - private List tokens; - private String message; - private String title; - @Builder.Default - Map data = new HashMap<>(); - -} - diff --git a/src/main/java/com/project/qvick/global/infra/firebase/service/FirebaseNotificationService.java b/src/main/java/com/project/qvick/global/infra/firebase/service/FirebaseNotificationService.java deleted file mode 100644 index e127a3fd..00000000 --- a/src/main/java/com/project/qvick/global/infra/firebase/service/FirebaseNotificationService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.project.qvick.global.infra.firebase.service; - -import java.util.List; -import java.util.concurrent.ExecutionException; -import com.project.qvick.global.infra.firebase.dto.FirebaseNotification; - -public interface FirebaseNotificationService { - - void sendNonCheckNotification(List tokens) throws ExecutionException, InterruptedException; - - void sendNotification(FirebaseNotification firebaseNotification) throws ExecutionException, InterruptedException; - - void saveToken(final String email, final String token); - - boolean hasKey(String email); - - String getToken(String email); - -} \ No newline at end of file diff --git a/src/main/java/com/project/qvick/global/infra/firebase/service/FirebaseNotificationServiceImpl.java b/src/main/java/com/project/qvick/global/infra/firebase/service/FirebaseNotificationServiceImpl.java deleted file mode 100644 index e9519583..00000000 --- a/src/main/java/com/project/qvick/global/infra/firebase/service/FirebaseNotificationServiceImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.project.qvick.global.infra.firebase.service; - -import com.google.firebase.messaging.ApnsConfig; -import com.google.firebase.messaging.Aps; -import com.google.firebase.messaging.FirebaseMessaging; -import com.google.firebase.messaging.Message; -import com.google.firebase.messaging.MulticastMessage; -import com.google.firebase.messaging.Notification; -import com.project.qvick.global.infra.firebase.config.FirebaseNotificationConfig; -import com.project.qvick.global.infra.firebase.domain.repository.FirebaseTokenRepository; -import com.project.qvick.global.infra.firebase.dto.FirebaseNotification; -import lombok.RequiredArgsConstructor; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; - -import java.util.List; -import java.util.concurrent.ExecutionException; - -@Service -@RequiredArgsConstructor -public class FirebaseNotificationServiceImpl implements FirebaseNotificationService { - - private final FirebaseTokenRepository firebaseTokenRepository; - private final FirebaseNotificationConfig firebaseNotificationConfig; - - @Async - public void sendNonCheckNotification(List tokens) throws ExecutionException, InterruptedException { - if (tokens.size() > 0) - send(createMessage(tokens, createNotification(firebaseNotificationConfig.getNonCheckTitle(), firebaseNotificationConfig.getNonCheckMessage()), createApnsConfig())); - } - - @Async - public void sendNotification(FirebaseNotification firebaseNotification) throws ExecutionException, InterruptedException { -// List registrationTokens = firebaseNotification.getEmails().stream().filter(email -> hasKey(email)).map(email -> getToken(email)).toList(); -// if (registrationTokens.size() > 0) -// send(createMessage(registrationTokens, createNotification(firebaseNotification), createApnsConfig())); - } - - private void send(MulticastMessage message) throws ExecutionException, InterruptedException { - FirebaseMessaging.getInstance().sendEachForMulticastAsync(message).get(); - } - - private void send(Message message) throws ExecutionException, InterruptedException { - FirebaseMessaging.getInstance().sendAsync(message).get(); - } - - private MulticastMessage createMessage(List registrationTokens, com.google.firebase.messaging.Notification notification, ApnsConfig apnsConfig) { - - return MulticastMessage.builder() - .setNotification(notification) - .setApnsConfig(apnsConfig) - .addAllTokens(registrationTokens) - .build(); - } - - private ApnsConfig createApnsConfig() { - return ApnsConfig.builder().setAps(Aps.builder().setSound("default").build()).build(); - } - - private Notification createNotification(String title, String message) { - return com.google.firebase.messaging.Notification.builder() - .setTitle(title) - .setBody(message).build(); - } - - private Notification createNotification(FirebaseNotification firebaseNotification) { - return com.google.firebase.messaging.Notification.builder() - .setTitle(firebaseNotification.getTitle()) - .setBody(firebaseNotification.getMessage()).build(); - } - - public void saveToken(final String email, final String token) { - if (StringUtils.hasText(token)) - firebaseTokenRepository.saveToken(email, token); - } - - public void deleteToken(String email) { - firebaseTokenRepository.deleteToken(email); - } - - public boolean hasKey(String email) { - return firebaseTokenRepository.hasKey(email); - } - - public String getToken(String email) { - return firebaseTokenRepository.getToken(email); - } - -} -