From da8d3b9aeaa0e79e582df3df68b2a7239e4d5378 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 8 Dec 2023 12:22:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Block=E3=82=A2=E3=82=AF=E3=83=86?= =?UTF-8?q?=E3=82=A3=E3=83=93=E3=83=86=E3=82=A3=E5=8F=97=E8=A8=BA=E6=99=82?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../block/BlockActivityPubProcessor.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/block/BlockActivityPubProcessor.kt diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/block/BlockActivityPubProcessor.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/block/BlockActivityPubProcessor.kt new file mode 100644 index 00000000..9dd2276d --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/block/BlockActivityPubProcessor.kt @@ -0,0 +1,29 @@ +package dev.usbharu.hideout.activitypub.service.activity.block + +import dev.usbharu.hideout.activitypub.domain.model.Block +import dev.usbharu.hideout.activitypub.service.common.AbstractActivityPubProcessor +import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext +import dev.usbharu.hideout.activitypub.service.common.ActivityType +import dev.usbharu.hideout.application.external.Transaction +import dev.usbharu.hideout.core.query.UserQueryService +import dev.usbharu.hideout.core.service.block.BlockService +import org.springframework.stereotype.Service + + +@Service +class BlockActivityPubProcessor( + private val blockService: BlockService, + private val userQueryService: UserQueryService, + transaction: Transaction +) : + AbstractActivityPubProcessor(transaction) { + override suspend fun internalProcess(activity: ActivityPubProcessContext) { + val user = userQueryService.findByUrl(activity.activity.actor) + val target = userQueryService.findByUrl(activity.activity.apObject) + blockService.block(user.id, target.id) + } + + override fun isSupported(activityType: ActivityType): Boolean = activityType == ActivityType.Block + + override fun type(): Class = Block::class.java +}