크리에이터 콘텐츠 카테고리 언어 감지 및 번역 기능 추가

This commit is contained in:
2025-12-19 01:08:56 +09:00
parent 67a8de9e7a
commit 68cfa201eb
6 changed files with 126 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.content
import kr.co.vividnext.sodalive.chat.character.comment.CharacterCommentRepository
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterRepository
import kr.co.vividnext.sodalive.chat.original.OriginalWorkRepository
import kr.co.vividnext.sodalive.content.category.CategoryRepository
import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository
import kr.co.vividnext.sodalive.content.series.ContentSeriesRepository
import kr.co.vividnext.sodalive.explorer.profile.CreatorCheersRepository
@@ -34,7 +35,9 @@ enum class LanguageDetectTargetType {
CHARACTER_COMMENT,
CREATOR_CHEERS,
SERIES,
ORIGINAL_WORK
ORIGINAL_WORK,
CREATOR_CONTENT_CATEGORY
}
class LanguageDetectEvent(
@@ -56,6 +59,7 @@ class LanguageDetectListener(
private val creatorCheersRepository: CreatorCheersRepository,
private val seriesRepository: ContentSeriesRepository,
private val originalWorkRepository: OriginalWorkRepository,
private val categoryRepository: CategoryRepository,
private val applicationEventPublisher: ApplicationEventPublisher,
@@ -89,6 +93,7 @@ class LanguageDetectListener(
LanguageDetectTargetType.CREATOR_CHEERS -> handleCreatorCheersLanguageDetect(event)
LanguageDetectTargetType.SERIES -> handleSeriesLanguageDetect(event)
LanguageDetectTargetType.ORIGINAL_WORK -> handleOriginalWorkLanguageDetect(event)
LanguageDetectTargetType.CREATOR_CONTENT_CATEGORY -> handleCreatorContentCategoryLanguageDetect(event)
}
}
@@ -341,6 +346,25 @@ class LanguageDetectListener(
)
}
private fun handleCreatorContentCategoryLanguageDetect(event: LanguageDetectEvent) {
val categoryId = event.id
val category = categoryRepository.findByIdOrNull(categoryId) ?: return
if (!category.languageCode.isNullOrBlank()) return
val langCode = requestPapagoLanguageCode(event.query, categoryId) ?: return
category.languageCode = langCode
categoryRepository.save(category)
applicationEventPublisher.publishEvent(
LanguageTranslationEvent(
id = categoryId,
targetType = LanguageTranslationTargetType.CREATOR_CONTENT_CATEGORY
)
)
}
private fun requestPapagoLanguageCode(query: String, targetIdForLog: Long): String? {
return try {
val headers = HttpHeaders().apply {