feature: 暫定でユーザーアイコンを返却するように

This commit is contained in:
usbharu 2023-12-06 21:45:14 +09:00
parent 4fd5c487c6
commit a614459485
2 changed files with 14 additions and 0 deletions

View File

@ -187,6 +187,8 @@ class SecurityConfig {
authorize("/auth/sign_up", hasRole("ANONYMOUS")) authorize("/auth/sign_up", hasRole("ANONYMOUS"))
authorize(GET, "/files", permitAll) authorize(GET, "/files", permitAll)
authorize(GET, "/users/*/icon.jpg", permitAll)
authorize(GET, "/users/*/header.jpg", permitAll)
authorize(GET, "/api/v1/accounts/verify_credentials", hasAnyScope("read", "read:accounts")) authorize(GET, "/api/v1/accounts/verify_credentials", hasAnyScope("read", "read:accounts"))

View File

@ -3,6 +3,7 @@ package dev.usbharu.hideout.core.interfaces.api.media
import dev.usbharu.hideout.application.config.LocalStorageConfig import dev.usbharu.hideout.application.config.LocalStorageConfig
import dev.usbharu.hideout.core.service.media.FileTypeDeterminationService import dev.usbharu.hideout.core.service.media.FileTypeDeterminationService
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.core.io.ClassPathResource
import org.springframework.core.io.PathResource import org.springframework.core.io.PathResource
import org.springframework.core.io.Resource import org.springframework.core.io.Resource
import org.springframework.http.MediaType import org.springframework.http.MediaType
@ -37,4 +38,15 @@ class LocalFileController(
.contentLength(pathResource.contentLength()) .contentLength(pathResource.contentLength())
.body(pathResource) .body(pathResource)
} }
@GetMapping("/users/{user}/icon.jpg", "/users/{user}/header.jpg")
fun icons(): ResponseEntity<Resource> {
val pathResource = ClassPathResource("icon.png")
return ResponseEntity
.ok()
.contentType(MediaType.IMAGE_PNG)
.contentLength(pathResource.contentLength())
.body(pathResource)
}
} }