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) logger.info("Instance not found. try fetch instance info. url: {}", resolveInstanceUrl)
@Suppress("TooGenericExceptionCaught")
try { try {
val nodeinfoJson = resourceResolveService.resolve("$resolveInstanceUrl/.well-known/nodeinfo").bodyAsText() val nodeinfoJson = resourceResolveService.resolve("$resolveInstanceUrl/.well-known/nodeinfo").bodyAsText()
val nodeinfo = objectMapper.readValue(nodeinfoJson, Nodeinfo::class.java) val nodeinfo = objectMapper.readValue(nodeinfoJson, Nodeinfo::class.java)
val nodeinfoPathMap = nodeinfo.links.associate { it.rel to it.href } val nodeinfoPathMap = nodeinfo.links.associate { it.rel to it.href }
for ((key, value) in nodeinfoPathMap) { for ((key, value) in nodeinfoPathMap) {
when (key) { when (key) {
"http://nodeinfo.diaspora.software/ns/schema/2.0" -> { "http://nodeinfo.diaspora.software/ns/schema/2.0",
val nodeinfo20 = objectMapper.readValue( "http://nodeinfo.diaspora.software/ns/schema/2.1",
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" -> {
val nodeinfo20 = objectMapper.readValue( val nodeinfo20 = objectMapper.readValue(
resourceResolveService.resolve(value!!).bodyAsText(), resourceResolveService.resolve(value!!).bodyAsText(),
Nodeinfo2_0::class.java Nodeinfo2_0::class.java
@ -102,8 +83,6 @@ class InstanceServiceImpl(
} }
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
logger.warn("FAILED Fetch Instance", e) logger.warn("FAILED Fetch Instance", e)
} }

View File

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