Skip to content

Commit 998b36a

Browse files
committed
2 parents 917965b + 11bbfe5 commit 998b36a

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/main/java/com/back/domain/chat/room/controller/RoomChatApiController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public ResponseEntity<RsData<ChatClearResponse>> clearRoomMessages(
7070
messageCount,
7171
clearedByInfo.userId(),
7272
clearedByInfo.nickname(),
73-
clearedByInfo.profileImageUrl(),
7473
clearedByInfo.role()
7574
);
7675

src/main/java/com/back/domain/chat/room/dto/ChatClearResponse.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ public record ChatClearResponse(
1010
public record ClearedByDto(
1111
Long userId,
1212
String nickname,
13-
String profileImageUrl,
1413
String role
1514
) {}
1615

1716
// 성공 응답 생성 헬퍼
1817
public static ChatClearResponse create(Long roomId, int deletedCount,
19-
Long userId, String nickname,
20-
String profileImageUrl, String role) {
18+
Long userId, String nickname, String role) {
2119
return new ChatClearResponse(
2220
roomId,
2321
deletedCount,
2422
java.time.LocalDateTime.now(),
25-
new ClearedByDto(userId, nickname, profileImageUrl, role)
23+
new ClearedByDto(userId, nickname, role)
2624
);
2725
}
2826
}

src/main/java/com/back/global/exception/ErrorCode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public enum ErrorCode {
6464
WS_USER_NOT_FOUND(HttpStatus.NOT_FOUND, "WS_013", "WebSocket 사용자를 찾을 수 없습니다."),
6565
WS_INVALID_REQUEST(HttpStatus.BAD_REQUEST, "WS_014", "잘못된 WebSocket 요청입니다."),
6666
WS_INTERNAL_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "WS_015", "WebSocket 내부 오류가 발생했습니다."),
67+
WS_CHAT_DELETE_FORBIDDEN(HttpStatus.FORBIDDEN, "WS_016", "채팅 삭제 권한이 없습니다. 방장 또는 부방장만 가능합니다."),
6768

6869
// ======================== 공통 에러 ========================
6970
BAD_REQUEST(HttpStatus.BAD_REQUEST, "COMMON_400", "잘못된 요청입니다."),

src/main/java/com/back/global/websocket/util/WebSocketErrorHelper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ public void sendErrorToUser(String sessionId, String errorCode, String errorMess
2424

2525
// CustomException을 WebSocket 에러로 전송
2626
public void sendCustomExceptionToUser(String sessionId, CustomException exception) {
27-
sendErrorToUser(sessionId, exception.getErrorCode().getCode(), exception.getMessage());
27+
String errorCode = switch (exception.getErrorCode()) {
28+
case CHAT_DELETE_FORBIDDEN -> "WS_016";
29+
default -> exception.getErrorCode().getCode();
30+
};
31+
32+
sendErrorToUser(sessionId, errorCode, exception.getMessage());
2833
}
2934

3035
// 일반 Exception을 기본 WebSocket 에러로 전송

0 commit comments

Comments
 (0)