style: fix lint

This commit is contained in:
usbharu 2024-04-03 14:31:18 +09:00
parent 4f084a375b
commit dc323f7d25
2 changed files with 5 additions and 25 deletions

View File

@ -50,36 +50,17 @@ class InstanceServiceImpl(
}
logger.info("Instance not found. try fetch instance info. url: {}", resolveInstanceUrl)
@Suppress("TooGenericExceptionCaught")
try {
val nodeinfoJson = resourceResolveService.resolve("$resolveInstanceUrl/.well-known/nodeinfo").bodyAsText()
val nodeinfo = objectMapper.readValue(nodeinfoJson, Nodeinfo::class.java)
val nodeinfoPathMap = nodeinfo.links.associate { it.rel to it.href }
for ((key, value) in nodeinfoPathMap) {
when (key) {
"http://nodeinfo.diaspora.software/ns/schema/2.0" -> {
val nodeinfo20 = objectMapper.readValue(
resourceResolveService.resolve(value!!).bodyAsText(),
Nodeinfo2_0::class.java
)
val instanceCreateDto = InstanceCreateDto(
name = nodeinfo20.metadata?.nodeName,
description = nodeinfo20.metadata?.nodeDescription,
url = resolveInstanceUrl,
iconUrl = "$resolveInstanceUrl/favicon.ico",
sharedInbox = sharedInbox,
software = nodeinfo20.software?.name,
version = nodeinfo20.software?.version
)
return createNewInstance(instanceCreateDto)
}
// TODO: 多分2.0と2.1で互換性有るのでそのまま使うけどなおす
"http://nodeinfo.diaspora.software/ns/schema/2.1" -> {
"http://nodeinfo.diaspora.software/ns/schema/2.0",
"http://nodeinfo.diaspora.software/ns/schema/2.1",
-> {
val nodeinfo20 = objectMapper.readValue(
resourceResolveService.resolve(value!!).bodyAsText(),
Nodeinfo2_0::class.java
@ -102,8 +83,6 @@ class InstanceServiceImpl(
}
}
}
} catch (e: Exception) {
logger.warn("FAILED Fetch Instance", e)
}

View File

@ -31,6 +31,7 @@ import org.springframework.security.web.SecurityFilterChain
class MastodonApiSecurityConfig {
@Bean
@Order(4)
@Suppress("LongMethod")
fun mastodonApiSecurityFilterChain(
http: HttpSecurity,
rf: RoleHierarchyAuthorizationManagerFactory,