mirror of https://github.com/usbharu/Hideout.git
fix: ポート番号をしっかり扱えてなかったので修正
This commit is contained in:
parent
d33a9065e9
commit
309ea569e8
|
@ -24,6 +24,7 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
|||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||
import dev.usbharu.hideout.core.domain.model.media.MediaRepository
|
||||
import dev.usbharu.hideout.core.domain.model.support.acct.Acct
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.apHost
|
||||
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
|
@ -45,7 +46,7 @@ class GetActorDetailApplicationService(
|
|||
?: throw IllegalArgumentException("Actor ${command.id} not found.")
|
||||
} else if (command.actorName != null) {
|
||||
val host = if (command.actorName.host.isEmpty()) {
|
||||
applicationConfig.url.host
|
||||
applicationConfig.url.apHost
|
||||
} else {
|
||||
command.actorName.host
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class RegisterLocalActorApplicationService(
|
|||
if (actorDomainService.usernameAlreadyUse(command.name)) {
|
||||
throw IllegalArgumentException("Username already exists")
|
||||
}
|
||||
val instance = instanceRepository.findByUrl(applicationConfig.url.toURI())
|
||||
val instance = instanceRepository.findByUrl(applicationConfig.url)
|
||||
?: throw InternalServerException("Local instance not found.")
|
||||
|
||||
val actor = actorFactoryImpl.createLocal(
|
||||
|
|
|
@ -46,7 +46,7 @@ class GetLocalInstanceApplicationService(
|
|||
}
|
||||
|
||||
val instance = (
|
||||
instanceRepository.findByUrl(applicationConfig.url.toURI())
|
||||
instanceRepository.findByUrl(applicationConfig.url)
|
||||
?: throw InternalServerException("Local instance not found.")
|
||||
)
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.application.instance
|
|||
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||
import dev.usbharu.hideout.core.config.ApplicationConfig
|
||||
import dev.usbharu.hideout.core.domain.model.instance.*
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.apHost
|
||||
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent
|
||||
import org.springframework.boot.info.BuildProperties
|
||||
|
@ -36,15 +37,15 @@ class InitLocalInstanceApplicationService(
|
|||
) {
|
||||
@EventListener(ApplicationReadyEvent::class)
|
||||
suspend fun init() = transaction.transaction {
|
||||
val findByUrl = instanceRepository.findByUrl(applicationConfig.url.toURI())
|
||||
val findByUrl = instanceRepository.findByUrl(applicationConfig.url)
|
||||
|
||||
if (findByUrl == null) {
|
||||
val instance = Instance(
|
||||
id = InstanceId(idGenerateService.generateId()),
|
||||
name = InstanceName(applicationConfig.url.host),
|
||||
name = InstanceName(applicationConfig.url.apHost),
|
||||
description = InstanceDescription(""),
|
||||
url = applicationConfig.url.toURI(),
|
||||
iconUrl = applicationConfig.url.toURI(),
|
||||
url = applicationConfig.url,
|
||||
iconUrl = applicationConfig.url,
|
||||
sharedInbox = null,
|
||||
software = InstanceSoftware("hideout"),
|
||||
version = InstanceVersion(buildProperties.version),
|
||||
|
|
|
@ -18,6 +18,7 @@ package dev.usbharu.hideout.core.application.model
|
|||
|
||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||
import dev.usbharu.hideout.core.domain.model.media.Media
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.apHost
|
||||
import java.net.URI
|
||||
|
||||
data class ActorDetail(
|
||||
|
@ -41,7 +42,7 @@ data class ActorDetail(
|
|||
id = actor.id.id,
|
||||
name = actor.name.name,
|
||||
screenName = actor.screenName.screenName,
|
||||
host = actor.url.host,
|
||||
host = actor.url.apHost,
|
||||
instanceId = actor.instance.instanceId,
|
||||
remoteUrl = actor.url,
|
||||
locked = actor.locked,
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
package dev.usbharu.hideout.core.config
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
@ConfigurationProperties("hideout")
|
||||
data class ApplicationConfig(
|
||||
val url: URL,
|
||||
val url: URI,
|
||||
val private: Boolean = true,
|
||||
val keySize: Int = 2048,
|
||||
)
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package dev.usbharu.hideout.core.domain.model.support.domain
|
||||
|
||||
import java.net.URI
|
||||
|
||||
@JvmInline
|
||||
value class Domain(val domain: String) {
|
||||
init {
|
||||
|
@ -23,6 +25,15 @@ value class Domain(val domain: String) {
|
|||
}
|
||||
|
||||
companion object {
|
||||
const val LENGTH = 1000
|
||||
const val LENGTH: Int = 1000
|
||||
|
||||
fun of(uri: URI): Domain = Domain(uri.apHost)
|
||||
}
|
||||
}
|
||||
|
||||
val URI.apHost: String
|
||||
get() = if (port == -1) {
|
||||
host
|
||||
} else {
|
||||
"$host:$port"
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package dev.usbharu.hideout.core.domain.service.actor
|
|||
|
||||
import dev.usbharu.hideout.core.config.ApplicationConfig
|
||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.apHost
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
interface IRemoteActorCheckDomainService {
|
||||
|
@ -26,5 +27,5 @@ interface IRemoteActorCheckDomainService {
|
|||
|
||||
@Service
|
||||
class RemoteActorCheckDomainService(private val applicationConfig: ApplicationConfig) : IRemoteActorCheckDomainService {
|
||||
override fun isRemoteActor(actor: Actor): Boolean = actor.domain.domain != applicationConfig.url.host
|
||||
override fun isRemoteActor(actor: Actor): Boolean = actor.domain.domain != applicationConfig.url.apHost
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.config.ApplicationConfig
|
|||
import dev.usbharu.hideout.core.domain.model.actor.ActorPrivateKey
|
||||
import dev.usbharu.hideout.core.domain.model.actor.ActorPublicKey
|
||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.apHost
|
||||
import org.springframework.stereotype.Service
|
||||
import java.security.KeyPairGenerator
|
||||
|
||||
|
@ -29,7 +30,7 @@ class LocalActorDomainServiceImpl(
|
|||
private val applicationConfig: ApplicationConfig,
|
||||
) : LocalActorDomainService {
|
||||
override suspend fun usernameAlreadyUse(name: String): Boolean =
|
||||
actorRepository.findByNameAndDomain(name, applicationConfig.url.host) != null
|
||||
actorRepository.findByNameAndDomain(name, applicationConfig.url.apHost) != null
|
||||
|
||||
override suspend fun generateKeyPair(): Pair<ActorPublicKey, ActorPrivateKey> {
|
||||
val keyPairGenerator = KeyPairGenerator.getInstance("RSA")
|
||||
|
|
|
@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.config.ApplicationConfig
|
|||
import dev.usbharu.hideout.core.domain.model.actor.*
|
||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.apHost
|
||||
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
|
||||
import org.springframework.stereotype.Component
|
||||
import java.net.URI
|
||||
|
@ -40,7 +41,7 @@ class ActorFactoryImpl(
|
|||
return Actor(
|
||||
id = ActorId(idGenerateService.generateId()),
|
||||
name = actorName,
|
||||
domain = Domain(applicationConfig.url.host),
|
||||
domain = Domain(applicationConfig.url.apHost),
|
||||
screenName = ActorScreenName(name),
|
||||
description = ActorDescription(""),
|
||||
inbox = URI.create("$userUrl/inbox"),
|
||||
|
|
|
@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.infrastructure.springframework.oauth2
|
|||
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||
import dev.usbharu.hideout.core.config.ApplicationConfig
|
||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.apHost
|
||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.slf4j.MDCContext
|
||||
|
@ -39,7 +40,7 @@ class UserDetailsServiceImpl(
|
|||
throw UsernameNotFoundException("Username not found")
|
||||
}
|
||||
transaction.transaction {
|
||||
val actor = actorRepository.findByNameAndDomain(username, applicationConfig.url.host)
|
||||
val actor = actorRepository.findByNameAndDomain(username, applicationConfig.url.apHost)
|
||||
?: throw UsernameNotFoundException("$username not found")
|
||||
val userDetail = userDetailRepository.findByActorId(actor.id.id)
|
||||
?: throw UsernameNotFoundException("${actor.id.id} not found")
|
||||
|
|
Loading…
Reference in New Issue