feat(content): 상세 조회에서 번역을 동기로 완료해 반환한다
This commit is contained in:
@@ -23,7 +23,6 @@ import kr.co.vividnext.sodalive.content.pin.PinContentRepository
|
||||
import kr.co.vividnext.sodalive.content.theme.AudioContentThemeQueryRepository
|
||||
import kr.co.vividnext.sodalive.content.theme.translation.ContentThemeTranslationRepository
|
||||
import kr.co.vividnext.sodalive.content.translation.ContentTranslationRepository
|
||||
import kr.co.vividnext.sodalive.content.translation.TranslatedContent
|
||||
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
|
||||
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
|
||||
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
|
||||
@@ -34,7 +33,6 @@ import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationEvent
|
||||
import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationTargetType
|
||||
import kr.co.vividnext.sodalive.i18n.translation.ResourceTranslationJobScheduler
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
@@ -83,8 +81,8 @@ class AudioContentService(
|
||||
private val pinContentRepository: PinContentRepository,
|
||||
private val memberRepository: MemberRepository,
|
||||
|
||||
private val resourceTranslationJobScheduler: ResourceTranslationJobScheduler,
|
||||
private val contentTranslationRepository: ContentTranslationRepository,
|
||||
private val detailTranslationService: AudioContentDetailTranslationService,
|
||||
|
||||
private val s3Uploader: S3Uploader,
|
||||
private val objectMapper: ObjectMapper,
|
||||
@@ -875,54 +873,14 @@ class AudioContentService(
|
||||
listOf()
|
||||
}
|
||||
|
||||
var translated: TranslatedContent? = null
|
||||
|
||||
/**
|
||||
* audioContent.languageCode != languageCode
|
||||
*
|
||||
* 번역 콘텐츠를 조회한다. - contentId, locale
|
||||
* 번역 콘텐츠가 있으면
|
||||
* TranslatedContent로 가공한다
|
||||
*
|
||||
* 번역 콘텐츠가 없으면
|
||||
* 누락 번역 job을 예약하고 원문 응답을 유지한다.
|
||||
*
|
||||
* 번역 대상: title, detail, tags
|
||||
*
|
||||
* 파파고로 번역한 데이터를 TranslatedContent로 가공한다
|
||||
*/
|
||||
if (audioContent.languageCode.isNullOrBlank()) {
|
||||
val translation = detailTranslationService.resolve(id, langContext.lang.code)
|
||||
if (translation.detectionQuery != null) {
|
||||
applicationEventPublisher.publishEvent(
|
||||
LanguageDetectEvent(
|
||||
id = id,
|
||||
query = listOf(audioContent.title.trim(), audioContent.detail.trim(), tag.trim())
|
||||
.filter { it.isNotBlank() }
|
||||
.joinToString(" ")
|
||||
query = translation.detectionQuery
|
||||
)
|
||||
)
|
||||
} else if (audioContent.languageCode != langContext.lang.code) {
|
||||
resourceTranslationJobScheduler.restartFailedResourceTranslations(
|
||||
LanguageTranslationTargetType.CONTENT,
|
||||
listOf(id),
|
||||
langContext.lang.code
|
||||
)
|
||||
val existing = contentTranslationRepository
|
||||
.findByContentIdAndLocale(audioContent.id!!, langContext.lang.code)
|
||||
|
||||
if (existing != null) {
|
||||
val payload = existing.renderedPayload
|
||||
translated = TranslatedContent(
|
||||
title = payload.title,
|
||||
detail = payload.detail,
|
||||
tags = payload.tags
|
||||
)
|
||||
} else {
|
||||
resourceTranslationJobScheduler.scheduleResourceTranslation(
|
||||
resourceType = LanguageTranslationTargetType.CONTENT,
|
||||
resourceId = audioContent.id!!,
|
||||
targetLanguage = langContext.lang.code
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -964,7 +922,7 @@ class AudioContentService(
|
||||
contentId = audioContent.id!!,
|
||||
title = audioContent.title,
|
||||
detail = contentDetail,
|
||||
languageCode = audioContent.languageCode,
|
||||
languageCode = translation.languageCode,
|
||||
coverImageUrl = "$coverImageHost/${audioContent.coverImage!!}",
|
||||
contentUrl = audioContentUrl,
|
||||
themeStr = themeStrTranslated,
|
||||
@@ -1009,7 +967,7 @@ class AudioContentService(
|
||||
nextContent = nextContent,
|
||||
buyerList = buyerList,
|
||||
isAvailableUsePoint = audioContent.isPointAvailable && audioContent.price > 0,
|
||||
translated = translated,
|
||||
translated = translation.translated,
|
||||
subtitle = if (
|
||||
(isExistsAudioContent || creatorId == member.id || audioContent.price <= 0) &&
|
||||
(audioContent.releaseDate == null || audioContent.releaseDate!! <= LocalDateTime.now() || creatorId == member.id)
|
||||
|
||||
Reference in New Issue
Block a user