From acd305d2890cd6cebe6598ae2b2bb48a8403d7d5 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 22 May 2023 15:35:45 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20ActivityPubFollowService=E3=82=92Ac?= =?UTF-8?q?tivityPubReceiveFollowService=E3=81=AB=E3=83=AA=E3=83=8D?= =?UTF-8?q?=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...FollowService.kt => ActivityPubReceiveFollowService.kt} | 2 +- ...rviceImpl.kt => ActivityPubReceiveFollowServiceImpl.kt} | 4 ++-- .../hideout/service/activitypub/ActivityPubServiceImpl.kt | 6 +++--- ...lTest.kt => ActivityPubReceiveFollowServiceImplTest.kt} | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) rename src/main/kotlin/dev/usbharu/hideout/service/activitypub/{ActivityPubFollowService.kt => ActivityPubReceiveFollowService.kt} (89%) rename src/main/kotlin/dev/usbharu/hideout/service/activitypub/{ActivityPubFollowServiceImpl.kt => ActivityPubReceiveFollowServiceImpl.kt} (96%) rename src/test/kotlin/dev/usbharu/hideout/service/activitypub/{ActivityPubFollowServiceImplTest.kt => ActivityPubReceiveFollowServiceImplTest.kt} (96%) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowService.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowService.kt similarity index 89% rename from src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowService.kt rename to src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowService.kt index 40e45767..378b0db6 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowService.kt @@ -5,7 +5,7 @@ import dev.usbharu.hideout.domain.model.ap.Follow import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob import kjob.core.job.JobProps -interface ActivityPubFollowService { +interface ActivityPubReceiveFollowService { suspend fun receiveFollow(follow: Follow): ActivityPubResponse suspend fun receiveFollowJob(props: JobProps) } diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowServiceImpl.kt similarity index 96% rename from src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImpl.kt rename to src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowServiceImpl.kt index 478629d8..31a64738 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowServiceImpl.kt @@ -16,12 +16,12 @@ import kjob.core.job.JobProps import org.koin.core.annotation.Single @Single -class ActivityPubFollowServiceImpl( +class ActivityPubReceiveFollowServiceImpl( private val jobQueueParentService: JobQueueParentService, private val activityPubUserService: ActivityPubUserService, private val userService: IUserService, private val httpClient: HttpClient -) : ActivityPubFollowService { +) : ActivityPubReceiveFollowService { override suspend fun receiveFollow(follow: Follow): ActivityPubResponse { // TODO: Verify HTTP Signature jobQueueParentService.schedule(ReceiveFollowJob) { diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt index 38bb6bf4..dbcc3af2 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt @@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory @Single class ActivityPubServiceImpl( - private val activityPubFollowService: ActivityPubFollowService, + private val activityPubReceiveFollowService: ActivityPubReceiveFollowService, private val activityPubNoteService: ActivityPubNoteService, private val activityPubUndoService: ActivityPubUndoService ) : ActivityPubService { @@ -50,7 +50,7 @@ class ActivityPubServiceImpl( ActivityType.Delete -> TODO() ActivityType.Dislike -> TODO() ActivityType.Flag -> TODO() - ActivityType.Follow -> activityPubFollowService.receiveFollow( + ActivityType.Follow -> activityPubReceiveFollowService.receiveFollow( Config.configData.objectMapper.readValue( json, Follow::class.java @@ -82,7 +82,7 @@ class ActivityPubServiceImpl( override suspend fun processActivity(job: JobContextWithProps, hideoutJob: HideoutJob) { logger.debug("processActivity: ${hideoutJob.name}") when (hideoutJob) { - ReceiveFollowJob -> activityPubFollowService.receiveFollowJob(job.props as JobProps) + ReceiveFollowJob -> activityPubReceiveFollowService.receiveFollowJob(job.props as JobProps) DeliverPostJob -> activityPubNoteService.createNoteJob(job.props as JobProps) } } diff --git a/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowServiceImplTest.kt similarity index 96% rename from src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImplTest.kt rename to src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowServiceImplTest.kt index 2e5b3af0..29525057 100644 --- a/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubReceiveFollowServiceImplTest.kt @@ -25,13 +25,14 @@ import org.mockito.kotlin.* import utils.JsonObjectMapper import java.time.Instant -class ActivityPubFollowServiceImplTest { +class ActivityPubReceiveFollowServiceImplTest { @Test fun `receiveFollow フォロー受付処理`() = runTest { val jobQueueParentService = mock { onBlocking { schedule(eq(ReceiveFollowJob), any()) } doReturn Unit } - val activityPubFollowService = ActivityPubFollowServiceImpl(jobQueueParentService, mock(), mock(), mock()) + val activityPubFollowService = + ActivityPubReceiveFollowServiceImpl(jobQueueParentService, mock(), mock(), mock()) activityPubFollowService.receiveFollow( Follow( emptyList(), @@ -118,7 +119,7 @@ class ActivityPubFollowServiceImplTest { onBlocking { follow(any(), any()) } doReturn false } val activityPubFollowService = - ActivityPubFollowServiceImpl( + ActivityPubReceiveFollowServiceImpl( mock(), activityPubUserService, userService,