fix: リモートユーザーを取得時に使用したURLでurlが登録されてしまう問題を修正

This commit is contained in:
usbharu 2023-11-21 15:47:38 +09:00
parent d93c34adb4
commit 9ce7b6e6dd
1 changed files with 11 additions and 9 deletions

View File

@ -80,26 +80,27 @@ class APUserServiceImpl(
override suspend fun fetchPersonWithEntity(url: String, targetActor: String?): Pair<Person, User> {
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<Person>(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"),