Merge remote-tracking branch 'origin/feature/mastodon-follow-api' into feature/mastodon-follow-api

This commit is contained in:
usbharu 2023-12-07 15:01:38 +09:00
commit 08c1f63f3a
4 changed files with 27 additions and 36 deletions

View File

@ -31,11 +31,9 @@ open class Image(
override fun toString(): String { override fun toString(): String {
return "Image(" + return "Image(" +
"mediaType=$mediaType, " + "mediaType=$mediaType, " +
"url='$url'" + "url='$url'" +
")" + ")" +
" ${super.toString()}" " ${super.toString()}"
} }
} }

View File

@ -99,7 +99,6 @@ class InboxJobProcessor(
val verify = signature?.let { verifyHttpSignature(httpRequest, it, transaction) } ?: false val verify = signature?.let { verifyHttpSignature(httpRequest, it, transaction) } ?: false
logger.debug("Is verifying success? {}", verify) logger.debug("Is verifying success? {}", verify)
val activityPubProcessor = val activityPubProcessor =
@ -114,7 +113,6 @@ class InboxJobProcessor(
activityPubProcessor.process(ActivityPubProcessContext(value, jsonNode, httpRequest, signature, verify)) activityPubProcessor.process(ActivityPubProcessContext(value, jsonNode, httpRequest, signature, verify))
logger.info("SUCCESS Process inbox. type: {}", param.type) logger.info("SUCCESS Process inbox. type: {}", param.type)
} }
override fun job(): InboxJob = InboxJob override fun job(): InboxJob = InboxJob

View File

@ -37,7 +37,6 @@ class HttpSignatureUserDetailsService(
try { try {
userQueryService.findByKeyId(keyId) userQueryService.findByKeyId(keyId)
} catch (e: FailedToGetResourcesException) { } catch (e: FailedToGetResourcesException) {
throw UsernameNotFoundException("User not found", e) throw UsernameNotFoundException("User not found", e)
} }
} }

View File

@ -92,10 +92,8 @@ class AccountApiServiceImpl(
} }
override suspend fun follow(userid: Long, followeeId: Long): Relationship = transaction.transaction { override suspend fun follow(userid: Long, followeeId: Long): Relationship = transaction.transaction {
val alreadyFollow = followerQueryService.alreadyFollow(followeeId, userid) val alreadyFollow = followerQueryService.alreadyFollow(followeeId, userid)
val followRequest = if (alreadyFollow) { val followRequest = if (alreadyFollow) {
true true
} else { } else {
@ -129,40 +127,38 @@ class AccountApiServiceImpl(
override suspend fun relationships(userid: Long, id: List<Long>, withSuspended: Boolean): List<Relationship> = override suspend fun relationships(userid: Long, id: List<Long>, withSuspended: Boolean): List<Relationship> =
transaction.transaction { transaction.transaction {
if (id.isEmpty()) { if (id.isEmpty()) {
return@transaction emptyList() return@transaction emptyList()
} }
logger.warn("id is too long! ({}) truncate to 20", id.size)
logger.warn("id is too long! ({}) truncate to 20", id.size)
val subList = id.subList(0, min(id.size, 20)) val subList = id.subList(0, min(id.size, 20))
return@transaction subList.map { return@transaction subList.map {
val alreadyFollow = followerQueryService.alreadyFollow(userid, it)
val alreadyFollow = followerQueryService.alreadyFollow(userid, it) val followed = followerQueryService.alreadyFollow(it, userid)
val followed = followerQueryService.alreadyFollow(it, userid) val requested = userRepository.findFollowRequestsById(it, userid)
val requested = userRepository.findFollowRequestsById(it, userid) Relationship(
id = it.toString(),
Relationship( following = alreadyFollow,
id = it.toString(), showingReblogs = true,
following = alreadyFollow, notifying = false,
showingReblogs = true, followedBy = followed,
notifying = false, blocking = false,
followedBy = followed, blockedBy = false,
blocking = false, muting = false,
blockedBy = false, mutingNotifications = false,
muting = false, requested = requested,
mutingNotifications = false, domainBlocking = false,
requested = requested, endorsed = false,
domainBlocking = false, note = ""
endorsed = false, )
note = "" }
)
} }
}
private fun from(account: Account): CredentialAccount { private fun from(account: Account): CredentialAccount {
return CredentialAccount( return CredentialAccount(