Skip to content
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

#62 - 유저는 차단된 유저 목록을 관리할 수 있다. #79

Merged
merged 11 commits into from
Aug 8, 2024

Conversation

sectionr0
Copy link
Contributor

1. 🔗 관련 이슈

2. 📄 구현한 내용 또는 수정한 내용

  • SignUp, SignIn Response 변경
  • 차단 API 분리
  • 메시지 목록 조회 버그 수정

3. 🙌 추가적으로 알리고 싶은 내용

  • SignUp, SignIn Response 가 변경되었는데, 재연짱이 나중에 알림 설정 부분 개발할떄
    해당 부분도 참고하시면 좋을 것 같아요!!

4. 🙄 TODO / 고민하고 있는 것들

5. ✅ 배포 Checklist

  • 본인을 Assign 해주세요.
  • 본인을 제외한 백엔드 개발자를 리뷰어로 지정해주세요.
  • 변경된 DB 업데이트 해주세요. (꼭 해주세요 배포 안돼요!!!)

@sectionr0 sectionr0 added 🌱기능🌱 새로운 기능을 추가해요 ! 🔧리팩터링🔧 리팩터링일까요 리팩토링일까요? 🥭망고🥭 24기 조기천 labels Aug 7, 2024
@sectionr0 sectionr0 requested a review from kpeel5839 August 7, 2024 13:52
@sectionr0 sectionr0 self-assigned this Aug 7, 2024
Copy link
Contributor

@kpeel5839 kpeel5839 left a comment

Choose a reason for hiding this comment

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

자기야 간단하게 코멘트 남겼어요!
고생했어잉~🥰

import com.wespot.user.dto.response.UserResponse
import java.time.LocalDateTime

@JsonInclude(JsonInclude.Include.NON_NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

이거는 어떤 설정이죵?! Null이면 포함 안하는 건가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네네 null인 데이터는 안내려줍니다!

setting = SettingResponse(
isMessageNotification = false, // TODO : userConsent에 저장되어 있는 값으로 변경
isVoteNotification = false, // TODO : userConsent에 저장되어 있는 값으로 변경
isMarketingNotification = user.userConsent.consentValue ?: false
Copy link
Contributor

Choose a reason for hiding this comment

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

앗 마케팅으로 가는건가요 킹스트맨 명세 바꿔야겠네요오옹

receiverId: Long,
cursorId: Long,
blockedUserIds: List<Long>,
blockedMessages: List<Long>,
Copy link
Contributor

Choose a reason for hiding this comment

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

ids라고 명시적으로 네이밍해주는 것도 좋을 것 같아요!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋아요! 수정하겠습니다!

Comment on lines 43 to 44
println("findAllByBlockerId")
println(blockerId)
Copy link
Contributor

Choose a reason for hiding this comment

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

개발할 때 사용했던 출력은 지워주기~~~🥰

Copy link
Contributor Author

Choose a reason for hiding this comment

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

헤헤 미안행 ㅠㅠ

Comment on lines 31 to 38
check(!isAlreadyBlocked) { "이미 차단된 사용자입니다." }

return when (isBlocked(loginUser.id, blockedUser.id)) {
true -> unblockUser(loginUser.id, blockedUser.id)
false -> blockUser(loginUser.id, blockedUser.id)
}
val createBlockedUser = BlockedUser.create(
blockerId = loginUser.id,
blockedId = blockedUser.id,
messageId = messageId
)
val saveBlockedUser = blockedUserPort.save(createBlockedUser)
Copy link
Contributor

Choose a reason for hiding this comment

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

DDD 책에 한번 나온적이 있는데, 이런 것들은 Domain 영역으로 뺄 수 있을 것 같아요.
BlokcedUser.create하기 이전에 사용자가 차단당한적이 있었었는지 boolean 값을 넣어준다면, 이를 도메인 내부에서 처리할 수 있지 않을까요?!

data class BlockedUser(
    val id: Long,
    val blockerId: Long,
    val blockedId: Long,
    val messageId: Long,
    val createdAt: LocalDateTime
) {

    companion object {
        fun create(
            blockerId: Long,
            blockedId: Long,
            messageId: Long,
            isAlreadyBlocked: Boolean,
        ): BlockedUser {
            check(!isAlreadyBlocked) { "이미 차단된 사용자입니다." }

            return BlockedUser(
                id = 0,
                blockerId = blockerId,
                blockedId = blockedId,
                messageId = messageId,
                createdAt = LocalDateTime.now()
            )
        }
    }

}
override fun blockedUser(messageId: Long): BlockedUserResponse {
    val (loginUser, blockedUser) = findAndValidateUsers(messageId)
    val isAlreadyBlocked = blockedUserPort.existsByBlockerIdAndBlockedIdAndMessageId(
        blockerId = loginUser.id,
        blockedId = blockedUser.id,
        messageId = messageId
    )
    val createBlockedUser = BlockedUser.create(
        blockerId = loginUser.id,
        blockedId = blockedUser.id,
        messageId = messageId,
        isAlreadyBlocked = isAlreadyBlocked
    )
//        check(!isAlreadyBlocked) { "이미 차단된 사용자입니다." }
//        val createBlockedUser = BlockedUser.create(
//            blockerId = loginUser.id,
//            blockedId = blockedUser.id,
//            messageId = messageId,
//            isAlreadyBlocked = isAlreadyBlocked
//        )
    val saveBlockedUser = blockedUserPort.save(createBlockedUser)
    return BlockedUserResponse.of(saveBlockedUser.id)
}

이런 느낌으로요!

항상 말씀드리지만 선택적으로 반영해주세요~🥰

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋습니다!!
순간적으로 db쪽이랑 연결되어서 넣으면 안된다고 생각했던 것 같아요 ㅜ.ㅜ

저거 반영해서 수정하면 좋을 것 같네요! 수정하겠습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

네네 알러뷰~

@sectionr0 sectionr0 force-pushed the feature/#62-blocked-message-manage branch from 884767f to 169051c Compare August 8, 2024 15:44
@sectionr0 sectionr0 merged commit 55eadc5 into develop Aug 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱기능🌱 새로운 기능을 추가해요 ! 🔧리팩터링🔧 리팩터링일까요 리팩토링일까요? 🥭망고🥭 24기 조기천
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants