fix: nameがnullのときpreferredUsernameを変わりに使用するように

This commit is contained in:
usbharu 2023-04-21 19:30:32 +09:00
parent 42dc455873
commit 7a11f3cd46
2 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import org.slf4j.LoggerFactory
class ActivityPubUserServiceImpl(
private val userService: UserService,
@ -23,6 +24,8 @@ class ActivityPubUserServiceImpl(
private val httpClient: HttpClient
) :
ActivityPubUserService {
private val logger = LoggerFactory.getLogger(this::class.java)
override suspend fun getPersonByName(name: String): Person {
// TODO: JOINで書き直し
val userEntity = userService.findByName(name)
@ -91,7 +94,7 @@ class ActivityPubUserServiceImpl(
name = person.preferredUsername
?: throw IllegalActivityPubObjectException("preferredUsername is null"),
domain = url.substringAfter(":").substringBeforeLast("/"),
screenName = person.name ?: throw IllegalActivityPubObjectException("name is null"),
screenName = (person.name ?: person.preferredUsername) ?: throw IllegalActivityPubObjectException("preferredUsername is null"),
description = person.summary ?: throw IllegalActivityPubObjectException("summary is null"),
inbox = person.inbox ?: throw IllegalActivityPubObjectException("inbox is null"),
outbox = person.outbox ?: throw IllegalActivityPubObjectException("outbox is null"),

View File

@ -9,4 +9,6 @@
</root>
<logger name="org.eclipse.jetty" level="INFO"/>
<logger name="io.netty" level="INFO"/>
<logger name="kjob.core.internal.scheduler.JobServiceImpl" level="INFO"/>
<logger name="Exposed" level="INFO"/>
</configuration>