Skip to content

Commit

Permalink
Merge pull request #323 from Team-Smeme/fix/#322-fcm-token-update
Browse files Browse the repository at this point in the history
fix: 푸시알림 부재 이슈 대응
  • Loading branch information
thguss authored Jul 16, 2024
2 parents d91e2ce + a3d5545 commit eea5818
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public class AuthService implements AuthUseCase {
public SignInResponse signIn(String socialAccessToken, SignInRequest request) {
val social = oauthPort.login(request.socialType(), socialAccessToken);
val signedMember = signIn(social, request);
memberPort.update(signedMember.updateSmeemToken(tokenGenerator.generateRefreshToken(signedMember.getId())));
signedMember.updateTokenInLogin(
tokenGenerator.generateRefreshToken(signedMember.getId()),
request.fcmToken());
memberPort.update(signedMember);
return SignInResponse.of(tokenGenerator.generateAccessToken(signedMember.getId()), signedMember);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ public void visit() {
this.visitDays++;
}

public boolean signUp() {
return this.username == null;
}

/**
* update
*/
public Member updateSmeemToken(String refreshToken) {
public void updateTokenInLogin(String refreshToken, String fcmToken) {
this.refreshToken = refreshToken;
return this;
this.fcmToken = fcmToken;
}

public Member updateDiaryComboCount(boolean diaryWrittenYesterday) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class MemberService implements MemberUseCase {
@Transactional
public UpdateMemberResponse updateMember(long memberId, UpdateMemberRequest request) {
val foundMember = memberPort.findById(memberId);
val isSignIn = foundMember.getUsername() == null;
val acquiredBadges = new ArrayList<Badge>();

if (request.username() != null) {
Expand All @@ -50,7 +49,8 @@ public UpdateMemberResponse updateMember(long memberId, UpdateMemberRequest requ
}
memberPort.update(foundMember);

if (isSignIn) {
if (foundMember.signUp()) {
acquiredBadges.add(badgePort.saveWelcomeBadgeToMember(foundMember.getId()));
hookLogger.send(LoggingMessage.signIn(request.username(), memberPort.countAll()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public SmeemResponse<GenerateTokenResponse> generateToken(Principal principal) {
return SmeemResponse.of(authUseCase.generateToken(memberId), SmeemMessage.GENERATE_TOKEN);
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseStatus(HttpStatus.OK)
@PostMapping("/sign-out")
public SmeemResponse<?> signOut(Principal principal) {
val memberId = smeemConverter.toMemberId(principal);
authUseCase.signOut(memberId);
return SmeemResponse.of(SmeemMessage.SIGNED_OUT);
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseStatus(HttpStatus.OK)
@DeleteMapping
public SmeemResponse<?> withdraw(Principal principal, @RequestBody(required = false) WithdrawRequest request) {
val memberId = smeemConverter.toMemberId(principal);
Expand Down

0 comments on commit eea5818

Please sign in to comment.