mirror of https://github.com/usbharu/Hideout.git
feat: Timeline APIのログインユーザー取得部分を共通化
This commit is contained in:
parent
34170d9b80
commit
54b89c290a
|
@ -1,6 +1,7 @@
|
||||||
package dev.usbharu.hideout.mastodon.interfaces.api.timeline
|
package dev.usbharu.hideout.mastodon.interfaces.api.timeline
|
||||||
|
|
||||||
import dev.usbharu.hideout.controller.mastodon.generated.TimelineApi
|
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.domain.mastodon.model.generated.Status
|
||||||
import dev.usbharu.hideout.mastodon.service.timeline.TimelineApiService
|
import dev.usbharu.hideout.mastodon.service.timeline.TimelineApiService
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
@ -8,21 +9,22 @@ import kotlinx.coroutines.flow.asFlow
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.springframework.http.HttpStatus
|
import org.springframework.http.HttpStatus
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.security.core.context.SecurityContextHolder
|
|
||||||
import org.springframework.security.oauth2.jwt.Jwt
|
|
||||||
import org.springframework.stereotype.Controller
|
import org.springframework.stereotype.Controller
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
class MastodonTimelineApiController(private val timelineApiService: TimelineApiService) : TimelineApi {
|
class MastodonTimelineApiController(
|
||||||
|
private val timelineApiService: TimelineApiService,
|
||||||
|
private val loginUserContextHolder: LoginUserContextHolder
|
||||||
|
) : TimelineApi {
|
||||||
override fun apiV1TimelinesHomeGet(
|
override fun apiV1TimelinesHomeGet(
|
||||||
maxId: String?,
|
maxId: String?,
|
||||||
sinceId: String?,
|
sinceId: String?,
|
||||||
minId: String?,
|
minId: String?,
|
||||||
limit: Int?
|
limit: Int?
|
||||||
): ResponseEntity<Flow<Status>> = runBlocking {
|
): ResponseEntity<Flow<Status>> = runBlocking {
|
||||||
val jwt = SecurityContextHolder.getContext().authentication.principal as Jwt
|
|
||||||
val homeTimeline = timelineApiService.homeTimeline(
|
val homeTimeline = timelineApiService.homeTimeline(
|
||||||
userId = jwt.getClaim<String>("uid").toLong(),
|
userId = loginUserContextHolder.getLoginUserId(),
|
||||||
maxId = maxId?.toLongOrNull(),
|
maxId = maxId?.toLongOrNull(),
|
||||||
minId = minId?.toLongOrNull(),
|
minId = minId?.toLongOrNull(),
|
||||||
sinceId = sinceId?.toLongOrNull(),
|
sinceId = sinceId?.toLongOrNull(),
|
||||||
|
|
Loading…
Reference in New Issue