From 9ce7b6e6ddbc58dcfa125473df735f17a57d1259 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:47:38 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=AA=E3=83=A2=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=82=92=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E6=99=82=E3=81=AB=E4=BD=BF=E7=94=A8=E3=81=97=E3=81=9FURL?= =?UTF-8?q?=E3=81=A7url=E3=81=8C=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/objects/user/APUserService.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt index 9c0777e9..03de36a3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt @@ -80,26 +80,27 @@ class APUserServiceImpl( override suspend fun fetchPersonWithEntity(url: String, targetActor: String?): Pair { return try { val userEntity = userQueryService.findByUrl(url) + val id = userEntity.url return Person( type = emptyList(), name = userEntity.name, - id = url, + id = id, preferredUsername = userEntity.name, summary = userEntity.description, - inbox = "$url/inbox", - outbox = "$url/outbox", - url = url, + inbox = "$id/inbox", + outbox = "$id/outbox", + url = id, icon = Image( type = emptyList(), - name = "$url/icon.png", + name = "$id/icon.png", mediaType = "image/png", - url = "$url/icon.png" + url = "$id/icon.png" ), publicKey = Key( type = emptyList(), name = "Public Key", id = userEntity.keyId, - owner = url, + owner = id, publicKeyPem = userEntity.publicKey ), endpoints = mapOf("sharedInbox" to "${applicationConfig.url}/inbox"), @@ -109,17 +110,18 @@ class APUserServiceImpl( } catch (ignore: FailedToGetResourcesException) { val person = apResourceResolveService.resolve(url, null as Long?) + val id = person.id ?: throw IllegalActivityPubObjectException("id is null") person to userService.createRemoteUser( RemoteUserCreateDto( name = person.preferredUsername ?: throw IllegalActivityPubObjectException("preferredUsername is null"), - domain = url.substringAfter("://").substringBefore("/"), + domain = id.substringAfter("://").substringBefore("/"), screenName = (person.name ?: person.preferredUsername) ?: throw IllegalActivityPubObjectException("preferredUsername is null"), description = person.summary.orEmpty(), inbox = person.inbox ?: throw IllegalActivityPubObjectException("inbox is null"), outbox = person.outbox ?: throw IllegalActivityPubObjectException("outbox is null"), - url = url, + url = id, publicKey = person.publicKey?.publicKeyPem ?: throw IllegalActivityPubObjectException("publicKey is null"), keyId = person.publicKey?.id ?: throw IllegalActivityPubObjectException("publicKey keyId is null"),