Skip to content

Commit 8c89ea2

Browse files
authored
Merge pull request #1318 from Moadong/hotfix/app-init-fail
[hotfix] fcm 토큰없으면 빈배열 응답
2 parents 0ce93c6 + 6d7e299 commit 8c89ea2

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

backend/src/main/java/moadong/fcm/controller/StudentFcmController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ public class StudentFcmController {
3333
@SecurityRequirement(name = "BearerAuth")
3434
public ResponseEntity<?> rotateFcmToken(
3535
@RequestHeader("Authorization") String authorization,
36-
@RequestBody @Validated StudentFcmTokenRotateRequest request
36+
@RequestBody StudentFcmTokenRotateRequest request
3737
) {
38+
if (request.fcmToken() == null) return Response.ok("pass");
3839
String studentId = studentJwtService.extractStudentId(authorization);
3940
StudentFcmTokenRotateResponse response = studentFcmTokenService.rotateFcmToken(studentId, request.fcmToken());
4041
return Response.ok(response);

backend/src/main/java/moadong/fcm/payload/request/StudentFcmTokenRotateRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import jakarta.validation.constraints.NotBlank;
44

55
public record StudentFcmTokenRotateRequest(
6-
@NotBlank
6+
// @NotBlank
77
String fcmToken
88
) {
99
}

backend/src/main/java/moadong/fcm/service/StudentFcmTokenService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public ClubSubscribeListResponse getSubscribedClubs(String studentId) {
6666
throw new RestApiException(ErrorCode.TOKEN_INVALID);
6767
}
6868

69-
StudentFcmToken token = studentFcmTokenRepository.findByStudentId(studentId)
70-
.orElseThrow(() -> new RestApiException(ErrorCode.FCMTOKEN_NOT_FOUND));
71-
return new ClubSubscribeListResponse(token.getClubIds());
69+
Optional<StudentFcmToken> token = studentFcmTokenRepository.findByStudentId(studentId);
70+
// .orElseThrow(() -> new RestApiException(ErrorCode.FCMTOKEN_NOT_FOUND));
71+
return token.map(studentFcmToken -> new ClubSubscribeListResponse(studentFcmToken.getClubIds())).orElseGet(() -> new ClubSubscribeListResponse(new ArrayList<>()));
7272
}
7373

7474
@Transactional

0 commit comments

Comments
 (0)