From 8c1f5c7752ea828b1a42bf921a321fbd68fc7758 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sun, 10 Dec 2023 17:44:40 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20JSON=E3=83=9E=E3=83=83=E3=83=94?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E7=94=A8=E3=81=AEPOJO=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/usbharu/hideout/activitypub/domain/model/Undo.kt | 9 +++++---- .../activity/like/ApRemoveReactionJobProcessor.kt | 2 +- .../service/activity/undo/APSendUndoServiceImpl.kt | 4 ++-- .../activitypub/service/activity/undo/APUndoProcessor.kt | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt index 01dbc17c..b1399777 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt @@ -1,5 +1,6 @@ package dev.usbharu.hideout.activitypub.domain.model +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer @@ -9,7 +10,7 @@ open class Undo( override val actor: String, override val id: String, @JsonDeserialize(using = ObjectDeserializer::class) - @Suppress("VariableNaming") val `object`: Object, + @JsonProperty("object") val apObject: Object, val published: String ) : Object(add(type, "Undo")), HasId, HasActor { @@ -20,7 +21,7 @@ open class Undo( other as Undo - if (`object` != other.`object`) return false + if (apObject != other.apObject) return false if (published != other.published) return false if (actor != other.actor) return false if (id != other.id) return false @@ -30,7 +31,7 @@ open class Undo( override fun hashCode(): Int { var result = super.hashCode() - result = 31 * result + `object`.hashCode() + result = 31 * result + apObject.hashCode() result = 31 * result + published.hashCode() result = 31 * result + actor.hashCode() result = 31 * result + id.hashCode() @@ -38,5 +39,5 @@ open class Undo( } override fun toString(): String = - "Undo(`object`=$`object`, published=$published, actor='$actor', id='$id') ${super.toString()}" + "Undo(`object`=$apObject, published=$published, actor='$actor', id='$id') ${super.toString()}" } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt index 285670b5..0409b9a0 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt @@ -31,7 +31,7 @@ class ApRemoveReactionJobProcessor( param.inbox, Undo( actor = param.actor, - `object` = like, + apObject = like, id = "${applicationConfig.url}/undo/like/${param.id}", published = Instant.now().toString() ), diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APSendUndoServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APSendUndoServiceImpl.kt index 3945cc5a..e1d4c6fd 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APSendUndoServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APSendUndoServiceImpl.kt @@ -22,7 +22,7 @@ class APSendUndoServiceImpl( Undo( actor = user.url, id = "${applicationConfig.url}/undo/follow/${user.id}/${target.url}", - `object` = Follow( + apObject = Follow( apObject = user.url, actor = target.url ), @@ -40,7 +40,7 @@ class APSendUndoServiceImpl( Undo( actor = user.url, id = "${applicationConfig.url}/undo/block/${user.id}/${target.url}", - `object` = Block( + apObject = Block( apObject = user.url, actor = target.url, id = "${applicationConfig.url}/block/${user.id}/${target.id}" diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APUndoProcessor.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APUndoProcessor.kt index 6f44abc6..f6a3ff0e 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APUndoProcessor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/undo/APUndoProcessor.kt @@ -28,13 +28,13 @@ class APUndoProcessor( } val type = - undo.`object`.type.orEmpty() + undo.apObject.type.orEmpty() .firstOrNull { it == "Block" || it == "Follow" || it == "Like" || it == "Announce" || it == "Accept" } ?: return when (type) { "Follow" -> { - val follow = undo.`object` as Follow + val follow = undo.apObject as Follow apUserService.fetchPerson(undo.actor, follow.apObject) val follower = userQueryService.findByUrl(undo.actor)