Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ public enum SwaggerResponseDescription {
))),
NOTIFICATION_MARK_TO_CHECKED(new LinkedHashSet<>(Set.of(
NOTIFICATION_NOT_FOUND,
NOTIFICATION_ACCESS_FORBIDDEN,
NOTIFICATION_ALREADY_CHECKED
NOTIFICATION_ACCESS_FORBIDDEN
))),
Comment on lines 381 to 383
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

스펙 정합성 OK — 이미 읽음 에러 제거가 의도와 일치합니다

NOTIFICATION_MARK_TO_CHECKED에서 NOTIFICATION_ALREADY_CHECKED 제거는 서비스/컨트롤러/테스트 변경과 일관됩니다.

레거시 참조가 남아있지 않은지 확인 부탁드립니다. 아래 스크립트로 잔존 참조를 점검할 수 있습니다.


🏁 Script executed:

#!/bin/bash
# NOTIFICATION_ALREADY_CHECKED 사용 흔적 검사
rg -nC2 'NOTIFICATION_ALREADY_CHECKED'

Length of output: 2752


레거시 참조 제거 필요 — NOTIFICATION_ALREADY_CHECKED 참조가 남아있음

Swagger 변경(이미 읽음 에러 제거)의 의도대로라면 아래 참조들을 제거하거나 스펙에 맞게 수정하세요.

  • src/main/java/konkuk/thip/common/exception/code/ErrorCode.java:238 — NOTIFICATION_ALREADY_CHECKED 정의
  • src/main/java/konkuk/thip/notification/domain/Notification.java:11(import), 51(throw) — 사용 위치
  • src/test/java/konkuk/thip/notification/domain/NotificationTest.java:9(import), 40(assertion) — 테스트에서 사용

해당 참조들을 삭제하거나 테스트·도메인 로직을 스펙(이미 읽음 에러 제거)에 맞게 업데이트하세요.

🤖 Prompt for AI Agents
In src/main/java/konkuk/thip/common/swagger/SwaggerResponseDescription.java
around lines 381-383, the code still references a legacy error
NOTIFICATION_ALREADY_CHECKED which should be removed per the recent spec change;
remove that enum constant usage here and then delete or refactor all remaining
references: remove NOTIFICATION_ALREADY_CHECKED from
src/main/java/konkuk/thip/common/exception/code/ErrorCode.java (line ~238),
remove the import and any throw statements in
src/main/java/konkuk/thip/notification/domain/Notification.java (remove the
import at line 11 and the throw at line 51 or replace with the new behavior),
and update src/test/java/konkuk/thip/notification/domain/NotificationTest.java
by removing the import at line 9 and adjusting the assertion at line 40 to
reflect the new spec (either assert success/no-error or the new error type);
ensure compilation and tests pass after these deletions/adjustments.


;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public BaseResponse<Void> deleteFcmToken(

@Operation(
summary = "유저의 특정 알림 읽음 처리",
description = "유저가 특정 알림을 읽음 처리합니다 (푸시알림, 알림센터의 알림 모두 포함). 읽음 처리 후, 해당 알림의 페이지로 리다이렉트를 위한 데이터를 응답합니다."
description = "유저가 특정 알림을 읽음 처리합니다 (푸시알림, 알림센터의 알림 모두 포함). 읽음 처리 후, 해당 알림의 페이지로 리다이렉트를 위한 데이터를 응답합니다. " +
"이미 읽음처리가 된 알림에 대해서는 리다이렉트를 위한 데이터만 응답합니다."
)
@ExceptionDescription(NOTIFICATION_MARK_TO_CHECKED)
@PostMapping("/notifications/check")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package konkuk.thip.notification.application.service;

import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.notification.adapter.in.web.response.NotificationMarkToCheckedResponse;
import konkuk.thip.notification.application.port.in.NotificationMarkUseCase;
import konkuk.thip.notification.application.port.out.NotificationCommandPort;
Expand All @@ -22,9 +23,13 @@ public NotificationMarkToCheckedResponse markToChecked(Long notificationId, Long
notification.validateOwner(userId);

// 2. 알림 읽음 처리
notification.markToChecked();
notificationCommandPort.update(notification);

try {
notification.markToChecked();
notificationCommandPort.update(notification);
} catch (InvalidStateException e) {
// 이미 알림 읽음 처리된 경우 -> 무시
}

// 3. 읽음 처리된 알림의 redirectSpec 반환 (for FE 알림 리다이렉트 동작)
return new NotificationMarkToCheckedResponse(
notification.getRedirectSpec().route(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@

import java.util.Map;

import static konkuk.thip.common.exception.code.ErrorCode.NOTIFICATION_ALREADY_CHECKED;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand Down Expand Up @@ -94,13 +92,17 @@ void mark_notification_to_checked_forbidden_when_not_owner() throws Exception {
}

@Test
@DisplayName("이미 읽음 처리된 알림을 다시 읽음 처리하면, 400 에러를 반환한다.")
@DisplayName("이미 읽음 처리된 알림을 다시 읽음 처리하더라도, 에러를 반환하지 않고 알림의 리다이렉트를 위한 데이터를 반환한다.")
void mark_notification_to_checked_already_checked() throws Exception {
// given: owner의 알림을 미리 is_checked=true 상태로 만들어 둔다
UserJpaEntity owner = userJpaRepository.save(TestEntityFactory.createUser(Alias.WRITER));

NotificationRedirectSpec redirectSpec = TestEntityFactory.createNotificationRedirectSpec(
MessageRoute.FEED_USER, Map.of("userId", 123L) // 특정 유저의 피드 페이지로 이동
);

NotificationJpaEntity notification = notificationJpaRepository.save(
TestEntityFactory.createNotification(owner, "이미 읽은 알림", NotificationCategory.FEED));
TestEntityFactory.createNotification(owner, "이미 읽은 알림", NotificationCategory.FEED, redirectSpec));

// is_checked=true 로 강제 세팅
jdbcTemplate.update(
Expand All @@ -116,8 +118,8 @@ void mark_notification_to_checked_already_checked() throws Exception {
.contentType(APPLICATION_JSON)
.content(body)
.requestAttr("userId", owner.getUserId()))
.andExpect(status().isBadRequest())
.andExpect(jsonPath("$.code").value(NOTIFICATION_ALREADY_CHECKED.getCode()))
.andExpect(jsonPath("$.message", containsString(NOTIFICATION_ALREADY_CHECKED.getMessage())));
.andExpect(status().isOk())
.andExpect(jsonPath("$.data.route").value(MessageRoute.FEED_USER.name()))
.andExpect(jsonPath("$.data.params.userId").value(123));
}
}