mirror of https://github.com/usbharu/Hideout.git
refactor: ActivityPubFollowServiceをActivityPubReceiveFollowServiceにリネーム
This commit is contained in:
parent
3d0ef1cb76
commit
acd305d289
|
@ -5,7 +5,7 @@ import dev.usbharu.hideout.domain.model.ap.Follow
|
||||||
import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob
|
import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob
|
||||||
import kjob.core.job.JobProps
|
import kjob.core.job.JobProps
|
||||||
|
|
||||||
interface ActivityPubFollowService {
|
interface ActivityPubReceiveFollowService {
|
||||||
suspend fun receiveFollow(follow: Follow): ActivityPubResponse
|
suspend fun receiveFollow(follow: Follow): ActivityPubResponse
|
||||||
suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>)
|
suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>)
|
||||||
}
|
}
|
|
@ -16,12 +16,12 @@ import kjob.core.job.JobProps
|
||||||
import org.koin.core.annotation.Single
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
@Single
|
@Single
|
||||||
class ActivityPubFollowServiceImpl(
|
class ActivityPubReceiveFollowServiceImpl(
|
||||||
private val jobQueueParentService: JobQueueParentService,
|
private val jobQueueParentService: JobQueueParentService,
|
||||||
private val activityPubUserService: ActivityPubUserService,
|
private val activityPubUserService: ActivityPubUserService,
|
||||||
private val userService: IUserService,
|
private val userService: IUserService,
|
||||||
private val httpClient: HttpClient
|
private val httpClient: HttpClient
|
||||||
) : ActivityPubFollowService {
|
) : ActivityPubReceiveFollowService {
|
||||||
override suspend fun receiveFollow(follow: Follow): ActivityPubResponse {
|
override suspend fun receiveFollow(follow: Follow): ActivityPubResponse {
|
||||||
// TODO: Verify HTTP Signature
|
// TODO: Verify HTTP Signature
|
||||||
jobQueueParentService.schedule(ReceiveFollowJob) {
|
jobQueueParentService.schedule(ReceiveFollowJob) {
|
|
@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
@Single
|
@Single
|
||||||
class ActivityPubServiceImpl(
|
class ActivityPubServiceImpl(
|
||||||
private val activityPubFollowService: ActivityPubFollowService,
|
private val activityPubReceiveFollowService: ActivityPubReceiveFollowService,
|
||||||
private val activityPubNoteService: ActivityPubNoteService,
|
private val activityPubNoteService: ActivityPubNoteService,
|
||||||
private val activityPubUndoService: ActivityPubUndoService
|
private val activityPubUndoService: ActivityPubUndoService
|
||||||
) : ActivityPubService {
|
) : ActivityPubService {
|
||||||
|
@ -50,7 +50,7 @@ class ActivityPubServiceImpl(
|
||||||
ActivityType.Delete -> TODO()
|
ActivityType.Delete -> TODO()
|
||||||
ActivityType.Dislike -> TODO()
|
ActivityType.Dislike -> TODO()
|
||||||
ActivityType.Flag -> TODO()
|
ActivityType.Flag -> TODO()
|
||||||
ActivityType.Follow -> activityPubFollowService.receiveFollow(
|
ActivityType.Follow -> activityPubReceiveFollowService.receiveFollow(
|
||||||
Config.configData.objectMapper.readValue(
|
Config.configData.objectMapper.readValue(
|
||||||
json,
|
json,
|
||||||
Follow::class.java
|
Follow::class.java
|
||||||
|
@ -82,7 +82,7 @@ class ActivityPubServiceImpl(
|
||||||
override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
|
override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
|
||||||
logger.debug("processActivity: ${hideoutJob.name}")
|
logger.debug("processActivity: ${hideoutJob.name}")
|
||||||
when (hideoutJob) {
|
when (hideoutJob) {
|
||||||
ReceiveFollowJob -> activityPubFollowService.receiveFollowJob(job.props as JobProps<ReceiveFollowJob>)
|
ReceiveFollowJob -> activityPubReceiveFollowService.receiveFollowJob(job.props as JobProps<ReceiveFollowJob>)
|
||||||
DeliverPostJob -> activityPubNoteService.createNoteJob(job.props as JobProps<DeliverPostJob>)
|
DeliverPostJob -> activityPubNoteService.createNoteJob(job.props as JobProps<DeliverPostJob>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,14 @@ import org.mockito.kotlin.*
|
||||||
import utils.JsonObjectMapper
|
import utils.JsonObjectMapper
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
class ActivityPubFollowServiceImplTest {
|
class ActivityPubReceiveFollowServiceImplTest {
|
||||||
@Test
|
@Test
|
||||||
fun `receiveFollow フォロー受付処理`() = runTest {
|
fun `receiveFollow フォロー受付処理`() = runTest {
|
||||||
val jobQueueParentService = mock<JobQueueParentService> {
|
val jobQueueParentService = mock<JobQueueParentService> {
|
||||||
onBlocking { schedule(eq(ReceiveFollowJob), any()) } doReturn Unit
|
onBlocking { schedule(eq(ReceiveFollowJob), any()) } doReturn Unit
|
||||||
}
|
}
|
||||||
val activityPubFollowService = ActivityPubFollowServiceImpl(jobQueueParentService, mock(), mock(), mock())
|
val activityPubFollowService =
|
||||||
|
ActivityPubReceiveFollowServiceImpl(jobQueueParentService, mock(), mock(), mock())
|
||||||
activityPubFollowService.receiveFollow(
|
activityPubFollowService.receiveFollow(
|
||||||
Follow(
|
Follow(
|
||||||
emptyList(),
|
emptyList(),
|
||||||
|
@ -118,7 +119,7 @@ class ActivityPubFollowServiceImplTest {
|
||||||
onBlocking { follow(any(), any()) } doReturn false
|
onBlocking { follow(any(), any()) } doReturn false
|
||||||
}
|
}
|
||||||
val activityPubFollowService =
|
val activityPubFollowService =
|
||||||
ActivityPubFollowServiceImpl(
|
ActivityPubReceiveFollowServiceImpl(
|
||||||
mock(),
|
mock(),
|
||||||
activityPubUserService,
|
activityPubUserService,
|
||||||
userService,
|
userService,
|
Loading…
Reference in New Issue