Skip to content

Commit

Permalink
rename: add status change log in the collection
Browse files Browse the repository at this point in the history
  • Loading branch information
psychology50 committed Dec 19, 2024
1 parent 5a68b27 commit f9d45d3
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import kr.co.pennyway.domain.domains.user.domain.User;
import kr.co.pennyway.domain.domains.user.exception.UserErrorCode;
import kr.co.pennyway.domain.domains.user.exception.UserErrorException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.NonNull;

import java.util.List;

@Slf4j
public class DeviceTokenRegisterCollection {
private final List<DeviceToken> userDeviceTokens;
private DeviceToken deviceToken;
Expand Down Expand Up @@ -53,6 +55,7 @@ public DeviceTokenRegisterCollection(DeviceToken deviceToken, List<DeviceToken>
*/
public DeviceToken register(User owner, @NonNull String deviceId, @NonNull String deviceName, @NonNull String token) {
if (owner == null) {
log.error("λ””λ°”μ΄μŠ€ 토큰을 등둝할 μ‚¬μš©μž 정보가 μ—†μŠ΅λ‹ˆλ‹€.");
throw new UserErrorException(UserErrorCode.NOT_FOUND);
}

Expand All @@ -73,10 +76,12 @@ private DeviceToken getDeviceTokenByToken(String token) {

private DeviceToken updateDevice(User user, String deviceId, DeviceToken originalDeviceToken) {
if (isDuplicatedDeviceToken(deviceId, originalDeviceToken)) {
log.error("ν™œμ„±ν™”λœ 토큰을 λ‹€λ₯Έ λ””λ°”μ΄μŠ€μ—μ„œ μ‚¬μš© μ€‘μž…λ‹ˆλ‹€.");
throw new DeviceTokenErrorException(DeviceTokenErrorCode.DUPLICATED_DEVICE_TOKEN);
}

originalDeviceToken.handleOwner(user, deviceId);
log.info("λ””λ°”μ΄μŠ€ 토큰이 κ°±μ‹ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. deviceId: {}, token: {}", deviceId, originalDeviceToken.getToken());

return originalDeviceToken;
}
Expand All @@ -87,6 +92,7 @@ private boolean isDuplicatedDeviceToken(String deviceId, DeviceToken originalDev

private DeviceToken createDevice(User user, String deviceId, String deviceName, String token) {
this.deviceToken = DeviceToken.of(token, deviceId, deviceName, user);
log.info("μƒˆλ‘œμš΄ λ””λ°”μ΄μŠ€ 토큰이 μƒμ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€. deviceId: {}, token: {}", deviceId, token);

deactivateExistingTokens();

Expand Down

0 comments on commit f9d45d3

Please sign in to comment.