mirror of https://github.com/usbharu/Hideout.git
feat: 連合に失敗する問題を修正
This commit is contained in:
parent
ecd25436a4
commit
0021061aa2
|
@ -29,6 +29,9 @@ class UserRepositoryImpl(private val idGenerateService: IdGenerateService) :
|
||||||
it[createdAt] = user.createdAt.toEpochMilli()
|
it[createdAt] = user.createdAt.toEpochMilli()
|
||||||
it[publicKey] = user.publicKey
|
it[publicKey] = user.publicKey
|
||||||
it[privateKey] = user.privateKey
|
it[privateKey] = user.privateKey
|
||||||
|
it[keyId] = user.keyId
|
||||||
|
it[following] = user.following
|
||||||
|
it[followers] = user.followers
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Users.update({ Users.id eq user.id }) {
|
Users.update({ Users.id eq user.id }) {
|
||||||
|
@ -43,6 +46,9 @@ class UserRepositoryImpl(private val idGenerateService: IdGenerateService) :
|
||||||
it[createdAt] = user.createdAt.toEpochMilli()
|
it[createdAt] = user.createdAt.toEpochMilli()
|
||||||
it[publicKey] = user.publicKey
|
it[publicKey] = user.publicKey
|
||||||
it[privateKey] = user.privateKey
|
it[privateKey] = user.privateKey
|
||||||
|
it[keyId] = user.keyId
|
||||||
|
it[following] = user.following
|
||||||
|
it[followers] = user.followers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return user
|
return user
|
||||||
|
|
|
@ -49,18 +49,18 @@ class APReceiveFollowServiceImpl(
|
||||||
val person = apUserService.fetchPerson(actor, targetActor)
|
val person = apUserService.fetchPerson(actor, targetActor)
|
||||||
val follow = objectMapper.readValue<Follow>(props[ReceiveFollowJob.follow])
|
val follow = objectMapper.readValue<Follow>(props[ReceiveFollowJob.follow])
|
||||||
|
|
||||||
val signer = userQueryService.findByUrl(actor)
|
val signer = userQueryService.findByUrl(targetActor)
|
||||||
|
|
||||||
val urlString = person.inbox ?: throw IllegalArgumentException("inbox is not found")
|
val urlString = person.inbox ?: throw IllegalArgumentException("inbox is not found")
|
||||||
|
|
||||||
apRequestService.apPost(
|
apRequestService.apPost(
|
||||||
urlString,
|
url = urlString,
|
||||||
Accept(
|
body = Accept(
|
||||||
name = "Follow",
|
name = "Follow",
|
||||||
`object` = follow,
|
`object` = follow,
|
||||||
actor = targetActor
|
actor = targetActor
|
||||||
),
|
),
|
||||||
signer
|
signer = signer
|
||||||
)
|
)
|
||||||
|
|
||||||
val targetEntity = userQueryService.findByUrl(targetActor)
|
val targetEntity = userQueryService.findByUrl(targetActor)
|
||||||
|
|
|
@ -16,6 +16,7 @@ import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.util.*
|
import io.ktor.util.*
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.beans.factory.annotation.Qualifier
|
import org.springframework.beans.factory.annotation.Qualifier
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
@ -53,7 +54,7 @@ class APRequestServiceImpl(
|
||||||
httpRequest = HttpRequest(
|
httpRequest = HttpRequest(
|
||||||
url = u,
|
url = u,
|
||||||
headers = HttpHeaders(headers.toMap()),
|
headers = HttpHeaders(headers.toMap()),
|
||||||
dev.usbharu.httpsignature.common.HttpMethod.GET
|
HttpMethod.GET
|
||||||
),
|
),
|
||||||
privateKey = PrivateKey(
|
privateKey = PrivateKey(
|
||||||
keyId = "${signer.url}#pubkey",
|
keyId = "${signer.url}#pubkey",
|
||||||
|
@ -102,6 +103,8 @@ class APRequestServiceImpl(
|
||||||
val date = dateTimeFormatter.format(ZonedDateTime.now(ZoneId.of("GMT")))
|
val date = dateTimeFormatter.format(ZonedDateTime.now(ZoneId.of("GMT")))
|
||||||
val u = URL(url)
|
val u = URL(url)
|
||||||
if (signer?.privateKey == null) {
|
if (signer?.privateKey == null) {
|
||||||
|
logger.debug("NOT SIGN Request: {}", url)
|
||||||
|
logger.trace("{}", signer)
|
||||||
return httpClient.post(url) {
|
return httpClient.post(url) {
|
||||||
header("Accept", ContentType.Application.Activity)
|
header("Accept", ContentType.Application.Activity)
|
||||||
header("Date", date)
|
header("Date", date)
|
||||||
|
@ -111,6 +114,8 @@ class APRequestServiceImpl(
|
||||||
}.bodyAsText()
|
}.bodyAsText()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug("SIGN Request: {}", url)
|
||||||
|
|
||||||
val headers = headers {
|
val headers = headers {
|
||||||
append("Accept", ContentType.Application.Activity)
|
append("Accept", ContentType.Application.Activity)
|
||||||
append("Date", date)
|
append("Date", date)
|
||||||
|
@ -123,7 +128,7 @@ class APRequestServiceImpl(
|
||||||
u, HttpHeaders(headers.toMap()), HttpMethod.POST
|
u, HttpHeaders(headers.toMap()), HttpMethod.POST
|
||||||
),
|
),
|
||||||
privateKey = PrivateKey(
|
privateKey = PrivateKey(
|
||||||
keyId = "${signer.url}#pubkey",
|
keyId = signer.keyId,
|
||||||
privateKey = RsaUtil.decodeRsaPrivateKeyPem(signer.privateKey)
|
privateKey = RsaUtil.decodeRsaPrivateKeyPem(signer.privateKey)
|
||||||
),
|
),
|
||||||
signHeaders = listOf("(request-target)", "date", "host", "digest")
|
signHeaders = listOf("(request-target)", "date", "host", "digest")
|
||||||
|
@ -134,10 +139,15 @@ class APRequestServiceImpl(
|
||||||
headers {
|
headers {
|
||||||
appendAll(headers)
|
appendAll(headers)
|
||||||
append("Signature", sign.signatureHeader)
|
append("Signature", sign.signatureHeader)
|
||||||
|
remove("Host")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setBody(requestBody)
|
setBody(requestBody)
|
||||||
contentType(ContentType.Application.Activity)
|
contentType(ContentType.Application.Activity)
|
||||||
}.bodyAsText()
|
}.bodyAsText()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(APRequestServiceImpl::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ spring:
|
||||||
default-property-inclusion: always
|
default-property-inclusion: always
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: org.h2.Driver
|
driver-class-name: org.h2.Driver
|
||||||
url: "jdbc:h2:./test-dev2;MODE=POSTGRESQL"
|
url: "jdbc:h2:./test-dev3;MODE=POSTGRESQL"
|
||||||
username: ""
|
username: ""
|
||||||
password: ""
|
password: ""
|
||||||
data:
|
data:
|
||||||
|
|
Loading…
Reference in New Issue