Compare commits

...

5 Commits

Author SHA1 Message Date
usbharu ea3deb1359
Merge pull request #84 from usbharu/feature/fix-lint
Feature/fix lint
2023-10-12 11:20:21 +09:00
usbharu 1a56d83f64
style: fix lint 2023-10-12 11:15:34 +09:00
usbharu 9a600b4f5b
style: fix lint 2023-10-12 11:11:36 +09:00
usbharu cae3759e8a
Merge pull request #83 from usbharu/bugfix/fix-timeline
fix: タイムラインが読み込まれないのを修正
2023-10-12 10:53:26 +09:00
usbharu e772a37044
fix: タイムラインが読み込まれないのを修正 2023-10-12 02:32:33 +09:00
6 changed files with 18 additions and 8 deletions

View File

@ -42,6 +42,7 @@ import java.util.*
@EnableWebSecurity(debug = false)
@Configuration
@Suppress("FunctionMaxLength ")
class SecurityConfig {
@Bean

View File

@ -47,13 +47,12 @@ abstract class UserDetailsMixin
class UserDetailsDeserializer : JsonDeserializer<UserDetailsImpl>() {
private val SIMPLE_GRANTED_AUTHORITY_SET = object : TypeReference<Set<SimpleGrantedAuthority>>() {}
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UserDetailsImpl {
val mapper = p.codec as ObjectMapper
val jsonNode: JsonNode = mapper.readTree(p)
val authorities: Set<GrantedAuthority> = mapper.convertValue(
jsonNode["authorities"],
SIMPLE_GRANTED_AUTHORITY_SET
Companion.SIMPLE_GRANTED_AUTHORITY_SET
)
val password = jsonNode.readText("password")
@ -75,4 +74,8 @@ class UserDetailsDeserializer : JsonDeserializer<UserDetailsImpl>() {
else -> defaultValue
}
}
companion object {
private val SIMPLE_GRANTED_AUTHORITY_SET = object : TypeReference<Set<SimpleGrantedAuthority>>() {}
}
}

View File

@ -3,7 +3,7 @@ package dev.usbharu.hideout.domain.model.mastodon
import com.fasterxml.jackson.annotation.JsonProperty
import dev.usbharu.hideout.domain.mastodon.model.generated.StatusesRequestPoll
@Suppress("VariableNaming")
@Suppress("VariableNaming", "EnumEntryName")
class StatusesRequest {
@JsonProperty("status")
var status: String? = null

View File

@ -219,9 +219,12 @@ class APServiceImpl(
}
}
@Suppress("REDUNDANT_ELSE_IN_WHEN")
override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
logger.debug("processActivity: ${hideoutJob.name}")
@Suppress("ElseCaseInsteadOfExhaustiveWhen")
// Springで作成されるプロキシの都合上パターンマッチングが壊れるので必須
when (hideoutJob) {
is ReceiveFollowJob -> {
apReceiveFollowService.receiveFollowJob(

View File

@ -4,6 +4,7 @@ import dev.usbharu.hideout.domain.mastodon.model.generated.Status
import dev.usbharu.hideout.domain.model.hideout.entity.Timeline
import dev.usbharu.hideout.query.mastodon.StatusQueryService
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.data.domain.Sort
import org.springframework.data.mongodb.core.MongoTemplate
import org.springframework.data.mongodb.core.query.Criteria
import org.springframework.data.mongodb.core.query.Query
@ -26,6 +27,7 @@ class MongoGenerateTimelineService(
limit: Int
): List<Status> {
val query = Query()
if (forUserId != null) {
val criteria = Criteria.where("userId").`is`(forUserId)
query.addCriteria(criteria)
@ -43,7 +45,10 @@ class MongoGenerateTimelineService(
query.addCriteria(criteria)
}
val timelines = mongoTemplate.find(query.limit(limit), Timeline::class.java)
query.limit(limit)
query.with(Sort.by(Sort.Direction.DESC, "createdAt"))
val timelines = mongoTemplate.find(query, Timeline::class.java)
return statusQueryService.findByPostIds(timelines.flatMap { setOfNotNull(it.postId, it.replyId, it.repostId) })
}

View File

@ -17,8 +17,7 @@ object HttpUtil {
fun isContentTypeOfActivityPub(
contentType: String,
subType: String,
parameter: String
subType: String
): Boolean {
if (contentType != "application") {
return false
@ -32,8 +31,7 @@ object HttpUtil {
fun isContentTypeOfActivityPub(contentType: ContentType): Boolean {
return isContentTypeOfActivityPub(
contentType.contentType,
contentType.contentSubtype,
contentType.parameter("profile").orEmpty()
contentType.contentSubtype
)
}
// fun