fix(chat): AI 캐릭터 성인 접근 판정을 국가별 정책에 맞춘다
This commit is contained in:
22
docs/20260402_AI캐릭터본인인증국가별분기적용.md
Normal file
22
docs/20260402_AI캐릭터본인인증국가별분기적용.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
- [x] chat 패키지의 AI 캐릭터 상세/채팅 본인인증 적용 지점을 확인한다.
|
||||||
|
- [x] 기존 캐릭터 상세의 국가별 본인인증 분기 방식을 확인한다.
|
||||||
|
- [x] chat 패키지의 AI 캐릭터 및 AI 캐릭터 채팅 로직에 동일한 국가별 인증 방식을 반영한다.
|
||||||
|
- [x] 변경 사항에 대한 진단 및 관련 검증을 수행한다.
|
||||||
|
|
||||||
|
## 검증 기록
|
||||||
|
|
||||||
|
### 1차 구현
|
||||||
|
- 무엇을: `ChatRoomController`, `ChatQuotaController`, `ChatRoomQuotaController`의 본인인증 체크를 `member.auth` 직접 검사에서 `MemberContentPreferenceService.getStoredPreference(member).isAdult` 기반 국가별 판정으로 변경했다.
|
||||||
|
- 왜: AI 캐릭터 상세와 동일하게 한국은 본인인증이 필요하고, 그 외 국가는 저장된 성인 노출 설정 기준으로 접근하도록 맞추기 위해서다.
|
||||||
|
- 어떻게:
|
||||||
|
- `./gradlew compileKotlin` → 성공
|
||||||
|
- `./gradlew test` → 성공
|
||||||
|
- 변경 컨트롤러 3개에서 `member.auth == null` 직접 검사가 제거되고 `resolveIsAdultAccessible(...)`로 치환된 것을 확인함
|
||||||
|
|
||||||
|
### 2차 수정
|
||||||
|
- 무엇을: `OriginalWorkController`의 목록/상세 본인인증 체크도 동일한 국가별 판정으로 변경했다.
|
||||||
|
- 왜: `chat/original` 하위에 `member.auth` 직접 검사 잔여 지점이 남아 있어, 최초 요청 범위인 `chat` 패키지 전체 기준으로 정책이 완전히 일치하지 않았기 때문이다.
|
||||||
|
- 어떻게:
|
||||||
|
- `./gradlew compileKotlin` → 성공
|
||||||
|
- `./gradlew test` → 성공
|
||||||
|
- `src/main/kotlin/kr/co/vividnext/sodalive/chat` 전체에서 `member.auth == null|member?.auth != null` 검색 → 결과 없음
|
||||||
@@ -14,6 +14,7 @@ import kr.co.vividnext.sodalive.common.ApiResponse
|
|||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
@@ -33,6 +34,7 @@ import java.time.LocalDateTime
|
|||||||
class OriginalWorkController(
|
class OriginalWorkController(
|
||||||
private val queryService: OriginalWorkQueryService,
|
private val queryService: OriginalWorkQueryService,
|
||||||
private val characterImageRepository: CharacterImageRepository,
|
private val characterImageRepository: CharacterImageRepository,
|
||||||
|
private val memberContentPreferenceService: MemberContentPreferenceService,
|
||||||
|
|
||||||
private val langContext: LangContext,
|
private val langContext: LangContext,
|
||||||
|
|
||||||
@@ -58,7 +60,7 @@ class OriginalWorkController(
|
|||||||
@RequestParam(defaultValue = "20") size: Int,
|
@RequestParam(defaultValue = "20") size: Int,
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
) = run {
|
) = run {
|
||||||
val includeAdult = member?.auth != null
|
val includeAdult = resolveIsAdultAccessible(member)
|
||||||
val pageRes = queryService.listForAppPage(includeAdult, page, size)
|
val pageRes = queryService.listForAppPage(includeAdult, page, size)
|
||||||
val content = pageRes.content.map { OriginalWorkListItemResponse.from(it, imageHost) }
|
val content = pageRes.content.map { OriginalWorkListItemResponse.from(it, imageHost) }
|
||||||
|
|
||||||
@@ -127,7 +129,7 @@ class OriginalWorkController(
|
|||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val ow = queryService.getOriginalWork(id)
|
val ow = queryService.getOriginalWork(id)
|
||||||
val chars = queryService.getActiveCharactersPage(id, page = 0, size = 20).content
|
val chars = queryService.getActiveCharactersPage(id, page = 0, size = 20).content
|
||||||
@@ -196,4 +198,12 @@ class OriginalWorkController(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resolveIsAdultAccessible(member: Member?): Boolean {
|
||||||
|
if (member == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return memberContentPreferenceService.getStoredPreference(member).isAdult
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.can.use.CanUsage
|
|||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PostMapping
|
import org.springframework.web.bind.annotation.PostMapping
|
||||||
@@ -16,7 +17,8 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
@RequestMapping("/api/chat/quota")
|
@RequestMapping("/api/chat/quota")
|
||||||
class ChatQuotaController(
|
class ChatQuotaController(
|
||||||
private val chatQuotaService: ChatQuotaService,
|
private val chatQuotaService: ChatQuotaService,
|
||||||
private val canPaymentService: CanPaymentService
|
private val canPaymentService: CanPaymentService,
|
||||||
|
private val memberContentPreferenceService: MemberContentPreferenceService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
data class ChatQuotaStatusResponse(
|
data class ChatQuotaStatusResponse(
|
||||||
@@ -33,7 +35,7 @@ class ChatQuotaController(
|
|||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
): ApiResponse<ChatQuotaStatusResponse> = run {
|
): ApiResponse<ChatQuotaStatusResponse> = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val s = chatQuotaService.getStatus(member.id!!)
|
val s = chatQuotaService.getStatus(member.id!!)
|
||||||
ApiResponse.ok(ChatQuotaStatusResponse(s.totalRemaining, s.nextRechargeAtEpochMillis))
|
ApiResponse.ok(ChatQuotaStatusResponse(s.totalRemaining, s.nextRechargeAtEpochMillis))
|
||||||
@@ -45,10 +47,9 @@ class ChatQuotaController(
|
|||||||
@RequestBody request: ChatQuotaPurchaseRequest
|
@RequestBody request: ChatQuotaPurchaseRequest
|
||||||
): ApiResponse<ChatQuotaStatusResponse> = run {
|
): ApiResponse<ChatQuotaStatusResponse> = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
if (request.container.isBlank()) throw SodaException(messageKey = "chat.quota.container_required")
|
if (request.container.isBlank()) throw SodaException(messageKey = "chat.quota.container_required")
|
||||||
|
|
||||||
// 30캔 차감 처리 (결제 기록 남김)
|
|
||||||
canPaymentService.spendCan(
|
canPaymentService.spendCan(
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
needCan = 30,
|
needCan = 30,
|
||||||
@@ -56,8 +57,15 @@ class ChatQuotaController(
|
|||||||
container = request.container
|
container = request.container
|
||||||
)
|
)
|
||||||
|
|
||||||
// 글로벌 유료 개념 제거됨: 구매 성공 시에도 글로벌 쿼터 증액 없음
|
|
||||||
val s = chatQuotaService.getStatus(member.id!!)
|
val s = chatQuotaService.getStatus(member.id!!)
|
||||||
ApiResponse.ok(ChatQuotaStatusResponse(s.totalRemaining, s.nextRechargeAtEpochMillis))
|
ApiResponse.ok(ChatQuotaStatusResponse(s.totalRemaining, s.nextRechargeAtEpochMillis))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resolveIsAdultAccessible(member: Member?): Boolean {
|
||||||
|
if (member == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return memberContentPreferenceService.getStoredPreference(member).isAdult
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import kr.co.vividnext.sodalive.chat.room.repository.ChatRoomRepository
|
|||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
@@ -21,7 +22,8 @@ class ChatRoomQuotaController(
|
|||||||
private val chatRoomRepository: ChatRoomRepository,
|
private val chatRoomRepository: ChatRoomRepository,
|
||||||
private val participantRepository: ChatParticipantRepository,
|
private val participantRepository: ChatParticipantRepository,
|
||||||
private val chatRoomQuotaService: ChatRoomQuotaService,
|
private val chatRoomQuotaService: ChatRoomQuotaService,
|
||||||
private val chatQuotaService: ChatQuotaService
|
private val chatQuotaService: ChatQuotaService,
|
||||||
|
private val memberContentPreferenceService: MemberContentPreferenceService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
data class PurchaseRoomQuotaRequest(
|
data class PurchaseRoomQuotaRequest(
|
||||||
@@ -53,17 +55,15 @@ class ChatRoomQuotaController(
|
|||||||
@RequestBody req: PurchaseRoomQuotaRequest
|
@RequestBody req: PurchaseRoomQuotaRequest
|
||||||
): ApiResponse<PurchaseRoomQuotaResponse> = run {
|
): ApiResponse<PurchaseRoomQuotaResponse> = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
if (req.container.isBlank()) throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
if (req.container.isBlank()) throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
||||||
|
|
||||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||||
|
|
||||||
// 내 참여 여부 확인
|
|
||||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||||
?: throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
?: throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
||||||
|
|
||||||
// 캐릭터 참여자 확인(유효한 AI 캐릭터 방인지 체크 및 characterId 기본값 보조)
|
|
||||||
val characterParticipant = participantRepository
|
val characterParticipant = participantRepository
|
||||||
.findByChatRoomAndParticipantTypeAndIsActiveTrue(room, ParticipantType.CHARACTER)
|
.findByChatRoomAndParticipantTypeAndIsActiveTrue(room, ParticipantType.CHARACTER)
|
||||||
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
||||||
@@ -74,7 +74,6 @@ class ChatRoomQuotaController(
|
|||||||
val characterId = character.id
|
val characterId = character.id
|
||||||
?: throw SodaException(messageKey = "chat.room.quota.character_required")
|
?: throw SodaException(messageKey = "chat.room.quota.character_required")
|
||||||
|
|
||||||
// 서비스에서 결제 포함하여 처리
|
|
||||||
val status = chatRoomQuotaService.purchase(
|
val status = chatRoomQuotaService.purchase(
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
chatRoomId = chatRoomId,
|
chatRoomId = chatRoomId,
|
||||||
@@ -99,24 +98,20 @@ class ChatRoomQuotaController(
|
|||||||
@PathVariable chatRoomId: Long
|
@PathVariable chatRoomId: Long
|
||||||
): ApiResponse<RoomQuotaStatusResponse> = run {
|
): ApiResponse<RoomQuotaStatusResponse> = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||||
// 내 참여 여부 확인
|
|
||||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||||
?: throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
?: throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
||||||
// 캐릭터 확인
|
|
||||||
val characterParticipant = participantRepository
|
val characterParticipant = participantRepository
|
||||||
.findByChatRoomAndParticipantTypeAndIsActiveTrue(room, ParticipantType.CHARACTER)
|
.findByChatRoomAndParticipantTypeAndIsActiveTrue(room, ParticipantType.CHARACTER)
|
||||||
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
||||||
val character = characterParticipant.character
|
val character = characterParticipant.character
|
||||||
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
||||||
|
|
||||||
// 글로벌 Lazy refill
|
|
||||||
val globalStatus = chatQuotaService.getStatus(member.id!!)
|
val globalStatus = chatQuotaService.getStatus(member.id!!)
|
||||||
|
|
||||||
// 룸 Lazy refill 상태
|
|
||||||
val roomStatus = chatRoomQuotaService.applyRefillOnEnterAndGetStatus(
|
val roomStatus = chatRoomQuotaService.applyRefillOnEnterAndGetStatus(
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
chatRoomId = chatRoomId,
|
chatRoomId = chatRoomId,
|
||||||
@@ -136,4 +131,12 @@ class ChatRoomQuotaController(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resolveIsAdultAccessible(member: Member?): Boolean {
|
||||||
|
if (member == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return memberContentPreferenceService.getStoredPreference(member).isAdult
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import kr.co.vividnext.sodalive.chat.room.service.ChatRoomService
|
|||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
@@ -20,7 +21,8 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/chat/room")
|
@RequestMapping("/api/chat/room")
|
||||||
class ChatRoomController(
|
class ChatRoomController(
|
||||||
private val chatRoomService: ChatRoomService
|
private val chatRoomService: ChatRoomService,
|
||||||
|
private val memberContentPreferenceService: MemberContentPreferenceService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,7 +45,7 @@ class ChatRoomController(
|
|||||||
@RequestBody request: CreateChatRoomRequest
|
@RequestBody request: CreateChatRoomRequest
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val response = chatRoomService.createOrGetChatRoom(member, request.characterId)
|
val response = chatRoomService.createOrGetChatRoom(member, request.characterId)
|
||||||
ApiResponse.ok(response)
|
ApiResponse.ok(response)
|
||||||
@@ -59,7 +61,7 @@ class ChatRoomController(
|
|||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
@RequestParam(defaultValue = "0") page: Int
|
@RequestParam(defaultValue = "0") page: Int
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null || member.auth == null) {
|
if (member == null || !resolveIsAdultAccessible(member)) {
|
||||||
ApiResponse.ok(emptyList())
|
ApiResponse.ok(emptyList())
|
||||||
} else {
|
} else {
|
||||||
val response = chatRoomService.listMyChatRooms(member, page)
|
val response = chatRoomService.listMyChatRooms(member, page)
|
||||||
@@ -78,7 +80,7 @@ class ChatRoomController(
|
|||||||
@PathVariable chatRoomId: Long
|
@PathVariable chatRoomId: Long
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val isActive = chatRoomService.isMyRoomSessionActive(member, chatRoomId)
|
val isActive = chatRoomService.isMyRoomSessionActive(member, chatRoomId)
|
||||||
ApiResponse.ok(isActive)
|
ApiResponse.ok(isActive)
|
||||||
@@ -96,7 +98,7 @@ class ChatRoomController(
|
|||||||
@RequestParam(required = false) characterImageId: Long?
|
@RequestParam(required = false) characterImageId: Long?
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val response = chatRoomService.enterChatRoom(member, chatRoomId, characterImageId)
|
val response = chatRoomService.enterChatRoom(member, chatRoomId, characterImageId)
|
||||||
ApiResponse.ok(response)
|
ApiResponse.ok(response)
|
||||||
@@ -115,7 +117,7 @@ class ChatRoomController(
|
|||||||
@PathVariable chatRoomId: Long
|
@PathVariable chatRoomId: Long
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
chatRoomService.leaveChatRoom(member, chatRoomId)
|
chatRoomService.leaveChatRoom(member, chatRoomId)
|
||||||
ApiResponse.ok(true)
|
ApiResponse.ok(true)
|
||||||
@@ -135,7 +137,7 @@ class ChatRoomController(
|
|||||||
@RequestParam(required = false) cursor: Long?
|
@RequestParam(required = false) cursor: Long?
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val response = chatRoomService.getChatMessages(member, chatRoomId, cursor, limit)
|
val response = chatRoomService.getChatMessages(member, chatRoomId, cursor, limit)
|
||||||
ApiResponse.ok(response)
|
ApiResponse.ok(response)
|
||||||
@@ -154,7 +156,7 @@ class ChatRoomController(
|
|||||||
@RequestBody request: SendChatMessageRequest
|
@RequestBody request: SendChatMessageRequest
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
if (request.message.isBlank()) {
|
if (request.message.isBlank()) {
|
||||||
ApiResponse.error()
|
ApiResponse.error()
|
||||||
@@ -177,7 +179,7 @@ class ChatRoomController(
|
|||||||
@RequestBody request: ChatMessagePurchaseRequest
|
@RequestBody request: ChatMessagePurchaseRequest
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val result = chatRoomService.purchaseMessage(member, chatRoomId, messageId, request.container)
|
val result = chatRoomService.purchaseMessage(member, chatRoomId, messageId, request.container)
|
||||||
ApiResponse.ok(result)
|
ApiResponse.ok(result)
|
||||||
@@ -196,9 +198,17 @@ class ChatRoomController(
|
|||||||
@RequestBody request: ChatRoomResetRequest
|
@RequestBody request: ChatRoomResetRequest
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
if (!resolveIsAdultAccessible(member)) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||||
|
|
||||||
val response = chatRoomService.resetChatRoom(member, chatRoomId, request.container)
|
val response = chatRoomService.resetChatRoom(member, chatRoomId, request.container)
|
||||||
ApiResponse.ok(response)
|
ApiResponse.ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resolveIsAdultAccessible(member: Member?): Boolean {
|
||||||
|
if (member == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return memberContentPreferenceService.getStoredPreference(member).isAdult
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user