From 9c6c0a450b880700c93aeb57992e18a4d27d5219 Mon Sep 17 00:00:00 2001 From: usbharu Date: Thu, 12 Oct 2023 01:55:32 +0900 Subject: [PATCH] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../kotlin/dev/usbharu/hideout/config/HttpClientConfig.kt | 2 -- src/main/kotlin/dev/usbharu/hideout/config/SecurityConfig.kt | 1 - .../dev/usbharu/hideout/repository/PostRepositoryImpl.kt | 1 - .../kotlin/dev/usbharu/hideout/service/ap/APLikeService.kt | 1 - src/main/kotlin/dev/usbharu/hideout/service/ap/APService.kt | 5 +++-- .../dev/usbharu/hideout/service/core/MdcXrequestIdFilter.kt | 1 - .../usbharu/hideout/service/reaction/ReactionServiceImpl.kt | 1 - 7 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/config/HttpClientConfig.kt b/src/main/kotlin/dev/usbharu/hideout/config/HttpClientConfig.kt index 324f1e93..f373805c 100644 --- a/src/main/kotlin/dev/usbharu/hideout/config/HttpClientConfig.kt +++ b/src/main/kotlin/dev/usbharu/hideout/config/HttpClientConfig.kt @@ -22,10 +22,8 @@ class HttpClientConfig { install(Logging) { logger = Logger.DEFAULT level = LogLevel.INFO - } install(HttpCache) { - } expectSuccess = true } diff --git a/src/main/kotlin/dev/usbharu/hideout/config/SecurityConfig.kt b/src/main/kotlin/dev/usbharu/hideout/config/SecurityConfig.kt index f87c4dfd..82f61ed9 100644 --- a/src/main/kotlin/dev/usbharu/hideout/config/SecurityConfig.kt +++ b/src/main/kotlin/dev/usbharu/hideout/config/SecurityConfig.kt @@ -40,7 +40,6 @@ import java.security.interfaces.RSAPrivateKey import java.security.interfaces.RSAPublicKey import java.util.* - @EnableWebSecurity(debug = false) @Configuration class SecurityConfig { diff --git a/src/main/kotlin/dev/usbharu/hideout/repository/PostRepositoryImpl.kt b/src/main/kotlin/dev/usbharu/hideout/repository/PostRepositoryImpl.kt index f179ce7f..9100422a 100644 --- a/src/main/kotlin/dev/usbharu/hideout/repository/PostRepositoryImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/repository/PostRepositoryImpl.kt @@ -55,7 +55,6 @@ class PostRepositoryImpl(private val idGenerateService: IdGenerateService) : Pos } } - assert(Posts.select { Posts.id eq post.id }.singleOrNull() != null) { "Faild to insert" } diff --git a/src/main/kotlin/dev/usbharu/hideout/service/ap/APLikeService.kt b/src/main/kotlin/dev/usbharu/hideout/service/ap/APLikeService.kt index 3ddba560..d7d62fc3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/ap/APLikeService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/ap/APLikeService.kt @@ -32,7 +32,6 @@ class APLikeServiceImpl( val content = like.content ?: throw IllegalActivityPubObjectException("content is null") like.`object` ?: throw IllegalActivityPubObjectException("object is null") transaction.transaction { - LOGGER.trace("FETCH Liked Person $actor") val person = apUserService.fetchPersonWithEntity(actor) LOGGER.trace("{}", person.second) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/ap/APService.kt b/src/main/kotlin/dev/usbharu/hideout/service/ap/APService.kt index 00e7a822..6e241375 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/ap/APService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/ap/APService.kt @@ -206,8 +206,9 @@ class APServiceImpl( logger.debug("process activity: {}", type) return when (type) { ActivityType.Accept -> apAcceptService.receiveAccept(objectMapper.readValue(json)) - ActivityType.Follow -> apReceiveFollowService - .receiveFollow(objectMapper.readValue(json, Follow::class.java)) + ActivityType.Follow -> + apReceiveFollowService + .receiveFollow(objectMapper.readValue(json, Follow::class.java)) ActivityType.Create -> apCreateService.receiveCreate(objectMapper.readValue(json)) ActivityType.Like -> apLikeService.receiveLike(objectMapper.readValue(json)) ActivityType.Undo -> apUndoService.receiveUndo(objectMapper.readValue(json)) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/core/MdcXrequestIdFilter.kt b/src/main/kotlin/dev/usbharu/hideout/service/core/MdcXrequestIdFilter.kt index f3ecdcf6..d934449c 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/core/MdcXrequestIdFilter.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/core/MdcXrequestIdFilter.kt @@ -18,7 +18,6 @@ class MdcXrequestIdFilter : Filter { } finally { MDC.remove(KEY) } - } companion object { diff --git a/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt index 6e56143f..4ccac212 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt @@ -16,7 +16,6 @@ class ReactionServiceImpl( ) : ReactionService { override suspend fun receiveReaction(name: String, domain: String, userId: Long, postId: Long) { if (reactionQueryService.reactionAlreadyExist(postId, userId, 0).not()) { - try { reactionRepository.save( Reaction(reactionRepository.generateId(), 0, postId, userId)