Skip to content

Commit

Permalink
Feat: small bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
versatile0010 committed Nov 22, 2023
1 parent cacf24b commit 00bb4ee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.numberone.backend.domain.token.dto.response;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;

@Getter
@ToString
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class GetTokenResponse {
private String accessToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public GetTokenResponse loginNaver(GetTokenRequest tokenRequest) {

@Transactional
public RefreshTokenResponse refresh(RefreshTokenRequest tokenRequest) {
if (!jwtUtil.isValid(tokenRequest.getToken()))
if (!jwtUtil.isValid(tokenRequest.getToken())){
log.error("invalid token: {}", tokenRequest.getToken());
throw new NotFoundRefreshTokenException();
}
Token token = tokenRepository.findByRefreshToken(tokenRequest.getToken())
.orElseThrow(NotFoundRefreshTokenException::new);
String email = jwtUtil.getEmail(tokenRequest.getToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public boolean isValid(String token) {
getClaims(token);
return true;
} catch (ExpiredJwtException e) {
e.printStackTrace();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ public void sendFcm(Member member, String title, String body, NotificationTag ta

public void sendFcmToMembers(List<String> tokens, String title, String body, NotificationTag tag) {
log.info("{} 건의 푸시알람을 전송합니다.", tokens.size());
if (tokens.isEmpty()) return;
if (tokens.isEmpty()) {
return;
}
List<Message> messages = tokens.stream().map(
token -> Message.builder()
.putData("time", LocalDateTime.now().toString())
.setNotification(
Notification.builder()
.setTitle(title)
Expand All @@ -60,7 +61,7 @@ public void sendFcmToMembers(List<String> tokens, String title, String body, Not
)
.setToken(token)
.build()
).toList();
).filter(Objects::isNull).toList();

try {
BatchResponse response = FirebaseMessaging.getInstance().sendAll(messages);
Expand Down

0 comments on commit 00bb4ee

Please sign in to comment.