diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/timeline/MastodonTimelineApiController.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/timeline/MastodonTimelineApiController.kt index 41316f1e..38148ebc 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/timeline/MastodonTimelineApiController.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/timeline/MastodonTimelineApiController.kt @@ -1,6 +1,7 @@ package dev.usbharu.hideout.mastodon.interfaces.api.timeline import dev.usbharu.hideout.controller.mastodon.generated.TimelineApi +import dev.usbharu.hideout.core.infrastructure.springframework.security.LoginUserContextHolder import dev.usbharu.hideout.domain.mastodon.model.generated.Status import dev.usbharu.hideout.mastodon.service.timeline.TimelineApiService import kotlinx.coroutines.flow.Flow @@ -8,21 +9,22 @@ import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.runBlocking import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity -import org.springframework.security.core.context.SecurityContextHolder -import org.springframework.security.oauth2.jwt.Jwt import org.springframework.stereotype.Controller @Controller -class MastodonTimelineApiController(private val timelineApiService: TimelineApiService) : TimelineApi { +class MastodonTimelineApiController( + private val timelineApiService: TimelineApiService, + private val loginUserContextHolder: LoginUserContextHolder +) : TimelineApi { override fun apiV1TimelinesHomeGet( maxId: String?, sinceId: String?, minId: String?, limit: Int? ): ResponseEntity> = runBlocking { - val jwt = SecurityContextHolder.getContext().authentication.principal as Jwt + val homeTimeline = timelineApiService.homeTimeline( - userId = jwt.getClaim("uid").toLong(), + userId = loginUserContextHolder.getLoginUserId(), maxId = maxId?.toLongOrNull(), minId = minId?.toLongOrNull(), sinceId = sinceId?.toLongOrNull(),