Repository navigation
[FEAT] 채팅 사용자 차단 및 신고 기능 구현 #164
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
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f877b4a
feat: 채팅 사용자 차단 및 신고 기능 구현
haerxeong 37be0ca
fix: 메일 주소 변경
haerxeong e5ddd12
fix: 채팅 신고 메일 본문에 사용자 입력값 HTML 이스케이프 적용
haerxeong 6078ce3
docs: 신고 접수 API의 메일 발송 실패 500 응답 문서 제거
haerxeong 3188b0d
fix: 메시지 전송-차단 간 TOCTOU 레이스 컨디션 수정
haerxeong ef62ddc
fix: 신고 메일 발송 시 SdkClientException도 실패로 변환
haerxeong e68431a
fix: 신고 접수 API가 메일 발송 동안 DB 커넥션을 점유하지 않도록 수정
haerxeong ac19cba
fix: 신고 메일 수신자 기본값 제거로 설정 누락 시 fail-fast 처리
haerxeong 64e2edf
feat: 채팅방 상세 조회 응답에 메시지 발신 가능 여부 추가
haerxeong 8517aab
fix: 채팅 차단 요청에도 활성 사용자 검증 추가
haerxeong c74b96d
Merge branch 'develop' of https://github.com/TEAM-BUDDYS/BUDDYS-SERVE…
haerxeong a8a6502
feat: migration 버전 수정
haerxeong d0df5a6
feat: 채팅 상대방 신고 시에도 메시지 발신을 차단하도록 수정
haerxeong 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
65 changes: 65 additions & 0 deletions
65
src/main/java/org/sopt/buddys/domain/chat/controller/swagger/BlockChatPartnerSwagger.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package org.sopt.buddys.domain.chat.controller.swagger; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.ExampleObject; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.sopt.buddys.global.response.BaseResponse; | ||
| import org.sopt.buddys.global.swagger.CommonErrorResponses; | ||
|
|
||
| @Target(ElementType.METHOD) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Operation( | ||
| summary = "채팅 상대방 차단", | ||
| description = """ | ||
| 해당 채팅방의 상대방을 차단합니다. | ||
|
|
||
| - 차단 후에는 양쪽 모두 해당 상대방과 서로 메시지를 보낼 수 없습니다. | ||
| - 기존 채팅 내역은 삭제되지 않고 그대로 유지됩니다. | ||
| - 이미 차단한 상대방을 다시 차단해도 오류 없이 처리됩니다(멱등). | ||
| """ | ||
| ) | ||
| @ApiResponses({ | ||
| @ApiResponse(responseCode = "200", description = "차단 성공"), | ||
| @ApiResponse( | ||
| responseCode = "403", | ||
| description = "채팅방 접근 권한 없음", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = BaseResponse.class), | ||
| examples = @ExampleObject(value = """ | ||
| { | ||
| "success": false, | ||
| "code": "GLB-E003", | ||
| "message": "접근 권한이 없습니다.", | ||
| "data": null | ||
| } | ||
| """) | ||
| ) | ||
| ), | ||
| @ApiResponse( | ||
| responseCode = "404", | ||
| description = "채팅방을 찾을 수 없음", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = BaseResponse.class), | ||
| examples = @ExampleObject(value = """ | ||
| { | ||
| "success": false, | ||
| "code": "CHAT-E002", | ||
| "message": "채팅방을 찾을 수 없습니다.", | ||
| "data": null | ||
| } | ||
| """) | ||
| ) | ||
| ) | ||
| }) | ||
| @CommonErrorResponses | ||
| public @interface BlockChatPartnerSwagger { | ||
| } |
80 changes: 80 additions & 0 deletions
80
src/main/java/org/sopt/buddys/domain/chat/controller/swagger/ReportChatPartnerSwagger.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package org.sopt.buddys.domain.chat.controller.swagger; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.ExampleObject; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.sopt.buddys.global.response.BaseResponse; | ||
| import org.sopt.buddys.global.swagger.CommonErrorResponses; | ||
|
|
||
| @Target(ElementType.METHOD) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Operation( | ||
| summary = "채팅 상대방 신고", | ||
| description = """ | ||
| 해당 채팅방의 상대방을 신고합니다. | ||
|
|
||
| - 신고 사유(reason)는 선택 입력이며, 생략하면 사유 없이 즉시 접수됩니다. | ||
| - 신고 접수 시 신고자·신고 대상자 정보(및 입력된 사유)를 포함한 메일이 운영팀으로 발송됩니다. | ||
| """ | ||
| ) | ||
| @ApiResponses({ | ||
| @ApiResponse(responseCode = "200", description = "신고 접수 성공"), | ||
| @ApiResponse( | ||
| responseCode = "403", | ||
| description = "채팅방 접근 권한 없음", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = BaseResponse.class), | ||
| examples = @ExampleObject(value = """ | ||
| { | ||
| "success": false, | ||
| "code": "GLB-E003", | ||
| "message": "접근 권한이 없습니다.", | ||
| "data": null | ||
| } | ||
| """) | ||
| ) | ||
| ), | ||
| @ApiResponse( | ||
| responseCode = "404", | ||
| description = "채팅방을 찾을 수 없음", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = BaseResponse.class), | ||
| examples = @ExampleObject(value = """ | ||
| { | ||
| "success": false, | ||
| "code": "CHAT-E002", | ||
| "message": "채팅방을 찾을 수 없습니다.", | ||
| "data": null | ||
| } | ||
| """) | ||
| ) | ||
| ), | ||
| @ApiResponse( | ||
| responseCode = "500", | ||
| description = "신고 접수 메일 발송 실패", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = BaseResponse.class), | ||
| examples = @ExampleObject(value = """ | ||
| { | ||
| "success": false, | ||
| "code": "CHAT-E004", | ||
| "message": "신고 접수 메일 발송에 실패했습니다.", | ||
| "data": null | ||
| } | ||
| """) | ||
| ) | ||
|
haerxeong marked this conversation as resolved.
Outdated
|
||
| ) | ||
| }) | ||
| @CommonErrorResponses | ||
| public @interface ReportChatPartnerSwagger { | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
src/main/java/org/sopt/buddys/domain/chat/dto/request/ReportChatPartnerRequest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.sopt.buddys.domain.chat.dto.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record ReportChatPartnerRequest( | ||
| @Schema( | ||
| description = "신고 사유. 현재는 별도 사유 입력 없이 신고할 수 있어 생략 가능합니다.", | ||
| example = "부적절한 언행", | ||
| nullable = true | ||
| ) | ||
| @Size(max = 500) | ||
| String reason | ||
| ) { | ||
| } |
53 changes: 53 additions & 0 deletions
53
src/main/java/org/sopt/buddys/domain/chat/entity/ChatUserBlock.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package org.sopt.buddys.domain.chat.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.EmbeddedId; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.MapsId; | ||
| import jakarta.persistence.PrePersist; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.sopt.buddys.domain.chat.util.ChatTimeConverter; | ||
| import org.sopt.buddys.domain.user.entity.User; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Table(name = "chat_user_block") | ||
| public class ChatUserBlock { | ||
|
|
||
| @EmbeddedId | ||
| private ChatUserBlockId id; | ||
|
|
||
| @MapsId("blockerId") | ||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "blocker_id", nullable = false) | ||
| private User blocker; | ||
|
|
||
| @MapsId("blockedId") | ||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "blocked_id", nullable = false) | ||
| private User blocked; | ||
|
|
||
| @Column(name = "created_at", nullable = false, updatable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| public ChatUserBlock(User blocker, User blocked) { | ||
| this.blocker = blocker; | ||
| this.blocked = blocked; | ||
| this.id = new ChatUserBlockId(blocker.getId(), blocked.getId()); | ||
| } | ||
|
|
||
| @PrePersist | ||
| private void prePersist() { | ||
| if (createdAt == null) { | ||
| createdAt = ChatTimeConverter.now(); | ||
| } | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/sopt/buddys/domain/chat/entity/ChatUserBlockId.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package org.sopt.buddys.domain.chat.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Embeddable; | ||
| import java.io.Serializable; | ||
| import lombok.AccessLevel; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Embeddable | ||
| @EqualsAndHashCode | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class ChatUserBlockId implements Serializable { | ||
|
|
||
| @Column(name = "blocker_id") | ||
| private Long blockerId; | ||
|
|
||
| @Column(name = "blocked_id") | ||
| private Long blockedId; | ||
|
|
||
| public ChatUserBlockId(Long blockerId, Long blockedId) { | ||
| this.blockerId = blockerId; | ||
| this.blockedId = blockedId; | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
src/main/java/org/sopt/buddys/domain/chat/entity/ChatUserReport.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package org.sopt.buddys.domain.chat.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.PrePersist; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.sopt.buddys.domain.chat.util.ChatTimeConverter; | ||
| import org.sopt.buddys.domain.user.entity.User; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Table(name = "chat_user_report") | ||
| public class ChatUserReport { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "chat_room_id", nullable = false) | ||
| private ChatRoom chatRoom; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "reporter_id", nullable = false) | ||
| private User reporter; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "reported_id", nullable = false) | ||
| private User reported; | ||
|
|
||
| @Column(length = 500) | ||
| private String reason; | ||
|
|
||
| @Column(name = "created_at", nullable = false, updatable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| public ChatUserReport(ChatRoom chatRoom, User reporter, User reported, String reason) { | ||
| this.chatRoom = chatRoom; | ||
| this.reporter = reporter; | ||
| this.reported = reported; | ||
| this.reason = reason; | ||
| } | ||
|
|
||
| @PrePersist | ||
| private void prePersist() { | ||
| if (createdAt == null) { | ||
| createdAt = ChatTimeConverter.now(); | ||
| } | ||
| } | ||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.