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 kjob.core.job.JobProps
|
||||
|
||||
interface ActivityPubFollowService {
|
||||
interface ActivityPubReceiveFollowService {
|
||||
suspend fun receiveFollow(follow: Follow): ActivityPubResponse
|
||||
suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>)
|
||||
}
|
|
@ -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) {
|
|
@ -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 <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
|
||||
logger.debug("processActivity: ${hideoutJob.name}")
|
||||
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>)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<JobQueueParentService> {
|
||||
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,
|
Loading…
Reference in New Issue