-
Notifications
You must be signed in to change notification settings - Fork 4
[Fix] 메세지 예외 처리 #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
[Fix] 메세지 예외 처리 #379
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
치명적 결함: 잘못된 사용자의 토큰을 확인하고 있습니다
현재 구현은 수신자가 아닌 현재 인증된 사용자의 FCM 토큰을 확인합니다.
문제점:
userService.getUser()는 현재 인증된 사용자(예: 친구 요청을 보낸 사용자 A)를 반환합니다fcmDirectDto.userIds()에 포함된 수신자들(예: 친구 요청을 받는 사용자 B)입니다예시 시나리오:
sendToUsers호출sendToUsers는 B에게 전송 시도 → B는 토큰이 없어서 예외 발생 (Line 122)🔎 수정 제안
수신자 목록에서 토큰이 있는 사용자들에게만 전송하도록 변경:
public void sendToUsersIfTokenExists(FcmDirectDto fcmDirectDto) { - User user = userService.getUser(); - Optional<UserFcmToken> token = userFcmTokenRepository.findByUser(user); + List<User> users = userQueryService.getUsersByIds(fcmDirectDto.userIds()); + List<UserFcmToken> userFcmTokens = userFcmTokenRepository.findByUserIn(users); - if (token.isEmpty()) { - log.info("FCM 토큰이 존재하지 않는 유저입니다. userId={}", user.getId()); + if (userFcmTokens.isEmpty()) { + log.info("FCM 토큰이 존재하지 않는 유저입니다. userIds={}", fcmDirectDto.userIds()); return; } sendToUsers(fcmDirectDto); }참고: 이렇게 수정하면 일부 사용자만 토큰이 없는 경우에도 Line 122의
validateUserToken에서 예외가 발생합니다. 토큰이 있는 사용자에게만 전송하려면 추가 필터링 로직이 필요합니다.