fix(comment-nickname): deleted_ 로 시작하는 닉네임 접두사 노출을 제거한다
This commit is contained in:
@@ -4,6 +4,7 @@ import com.querydsl.core.types.dsl.Expressions
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
|
||||
import kr.co.vividnext.sodalive.extensions.removeDeletedNicknamePrefix
|
||||
import kr.co.vividnext.sodalive.fcm.PushTokenInfo
|
||||
import kr.co.vividnext.sodalive.fcm.QPushToken.pushToken
|
||||
import kr.co.vividnext.sodalive.fcm.QPushTokenInfo
|
||||
@@ -103,8 +104,10 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
.orderBy(audioContentComment.createdAt.desc())
|
||||
.fetch()
|
||||
.map {
|
||||
it.replyCount = commentReplyCountByAudioContentCommentId(it.id)
|
||||
it
|
||||
it.copy(
|
||||
nickname = it.nickname.removeDeletedNicknamePrefix(),
|
||||
replyCount = commentReplyCountByAudioContentCommentId(it.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +190,9 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
.limit(limit.toLong())
|
||||
.orderBy(audioContentComment.createdAt.desc())
|
||||
.fetch()
|
||||
.map {
|
||||
it.copy(nickname = it.nickname.removeDeletedNicknamePrefix())
|
||||
}
|
||||
}
|
||||
|
||||
override fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
||||
|
||||
@@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.explorer.profile.CreatorCheers
|
||||
import kr.co.vividnext.sodalive.explorer.profile.QChannelNotice.channelNotice
|
||||
import kr.co.vividnext.sodalive.explorer.profile.QCreatorCheers.creatorCheers
|
||||
import kr.co.vividnext.sodalive.explorer.profile.TimeDifferenceResult
|
||||
import kr.co.vividnext.sodalive.extensions.removeDeletedNicknamePrefix
|
||||
import kr.co.vividnext.sodalive.i18n.Lang
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
@@ -487,7 +488,7 @@ class ExplorerQueryRepository(
|
||||
GetCheersResponseItem(
|
||||
cheersId = it.id!!,
|
||||
memberId = it.member!!.id!!,
|
||||
nickname = it.member!!.nickname,
|
||||
nickname = it.member!!.nickname.removeDeletedNicknamePrefix(),
|
||||
profileUrl = if (it.member!!.profileImage != null) {
|
||||
"$cloudFrontHost/${it.member!!.profileImage}"
|
||||
} else {
|
||||
@@ -505,7 +506,7 @@ class ExplorerQueryRepository(
|
||||
GetCheersResponseItem(
|
||||
cheersId = cheers.id!!,
|
||||
memberId = cheers.member!!.id!!,
|
||||
nickname = cheers.member!!.nickname,
|
||||
nickname = cheers.member!!.nickname.removeDeletedNicknamePrefix(),
|
||||
profileUrl = if (cheers.member!!.profileImage != null) {
|
||||
"$cloudFrontHost/${cheers.member!!.profileImage}"
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment
|
||||
import com.querydsl.core.types.dsl.Expressions
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment.QCreatorCommunityComment.creatorCommunityComment
|
||||
import kr.co.vividnext.sodalive.extensions.removeDeletedNicknamePrefix
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import java.time.LocalDateTime
|
||||
@@ -93,8 +94,10 @@ class CreatorCommunityCommentQueryRepositoryImpl(
|
||||
.orderBy(creatorCommunityComment.createdAt.desc())
|
||||
.fetch()
|
||||
.map {
|
||||
it.replyCount = commentReplyCountByCommentId(it.id)
|
||||
it
|
||||
it.copy(
|
||||
nickname = it.nickname.removeDeletedNicknamePrefix(),
|
||||
replyCount = commentReplyCountByCommentId(it.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,5 +177,8 @@ class CreatorCommunityCommentQueryRepositoryImpl(
|
||||
.limit(limit)
|
||||
.orderBy(creatorCommunityComment.createdAt.desc())
|
||||
.fetch()
|
||||
.map {
|
||||
it.copy(nickname = it.nickname.removeDeletedNicknamePrefix())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
private const val DELETED_NICKNAME_PREFIX = "deleted_"
|
||||
|
||||
fun String.convertLocalDateTime(format: String): LocalDateTime {
|
||||
val dateTimeFormatter = DateTimeFormatter.ofPattern(format)
|
||||
return LocalDateTime.parse(this, dateTimeFormatter)
|
||||
@@ -24,3 +26,11 @@ fun String.convertLocalDateTime(
|
||||
.withZoneSameInstant(ZoneId.of("UTC"))
|
||||
.toLocalDateTime()
|
||||
}
|
||||
|
||||
fun String.removeDeletedNicknamePrefix(): String {
|
||||
return if (startsWith(DELETED_NICKNAME_PREFIX)) {
|
||||
removePrefix(DELETED_NICKNAME_PREFIX)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package kr.co.vividnext.sodalive.extensions
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class StringExtensionsTest {
|
||||
@Test
|
||||
fun shouldRemoveDeletedPrefixWhenNicknameStartsWithDeletedPrefix() {
|
||||
val nickname = "deleted_testUser"
|
||||
|
||||
val sanitizedNickname = nickname.removeDeletedNicknamePrefix()
|
||||
|
||||
assertEquals("testUser", sanitizedNickname)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldKeepNicknameWhenDeletedPrefixDoesNotExist() {
|
||||
val nickname = "testUser"
|
||||
|
||||
val sanitizedNickname = nickname.removeDeletedNicknamePrefix()
|
||||
|
||||
assertEquals("testUser", sanitizedNickname)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldReturnEmptyStringWhenNicknameContainsOnlyDeletedPrefix() {
|
||||
val nickname = "deleted_"
|
||||
|
||||
val sanitizedNickname = nickname.removeDeletedNicknamePrefix()
|
||||
|
||||
assertEquals("", sanitizedNickname)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user