mirror of https://github.com/usbharu/Hideout.git
Compare commits
No commits in common. "ea3deb1359adb9ecfc5350a2c08349b0503bfcd3" and "42036dd8b0d26ccae89fa5f483686c449f2517f2" have entirely different histories.
ea3deb1359
...
42036dd8b0
|
@ -42,7 +42,6 @@ import java.util.*
|
||||||
|
|
||||||
@EnableWebSecurity(debug = false)
|
@EnableWebSecurity(debug = false)
|
||||||
@Configuration
|
@Configuration
|
||||||
@Suppress("FunctionMaxLength ")
|
|
||||||
class SecurityConfig {
|
class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -47,12 +47,13 @@ abstract class UserDetailsMixin
|
||||||
|
|
||||||
class UserDetailsDeserializer : JsonDeserializer<UserDetailsImpl>() {
|
class UserDetailsDeserializer : JsonDeserializer<UserDetailsImpl>() {
|
||||||
|
|
||||||
|
private val SIMPLE_GRANTED_AUTHORITY_SET = object : TypeReference<Set<SimpleGrantedAuthority>>() {}
|
||||||
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UserDetailsImpl {
|
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UserDetailsImpl {
|
||||||
val mapper = p.codec as ObjectMapper
|
val mapper = p.codec as ObjectMapper
|
||||||
val jsonNode: JsonNode = mapper.readTree(p)
|
val jsonNode: JsonNode = mapper.readTree(p)
|
||||||
val authorities: Set<GrantedAuthority> = mapper.convertValue(
|
val authorities: Set<GrantedAuthority> = mapper.convertValue(
|
||||||
jsonNode["authorities"],
|
jsonNode["authorities"],
|
||||||
Companion.SIMPLE_GRANTED_AUTHORITY_SET
|
SIMPLE_GRANTED_AUTHORITY_SET
|
||||||
)
|
)
|
||||||
|
|
||||||
val password = jsonNode.readText("password")
|
val password = jsonNode.readText("password")
|
||||||
|
@ -74,8 +75,4 @@ class UserDetailsDeserializer : JsonDeserializer<UserDetailsImpl>() {
|
||||||
else -> defaultValue
|
else -> defaultValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val SIMPLE_GRANTED_AUTHORITY_SET = object : TypeReference<Set<SimpleGrantedAuthority>>() {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package dev.usbharu.hideout.domain.model.mastodon
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.StatusesRequestPoll
|
import dev.usbharu.hideout.domain.mastodon.model.generated.StatusesRequestPoll
|
||||||
|
|
||||||
@Suppress("VariableNaming", "EnumEntryName")
|
@Suppress("VariableNaming")
|
||||||
class StatusesRequest {
|
class StatusesRequest {
|
||||||
@JsonProperty("status")
|
@JsonProperty("status")
|
||||||
var status: String? = null
|
var status: String? = null
|
||||||
|
|
|
@ -219,12 +219,9 @@ class APServiceImpl(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("REDUNDANT_ELSE_IN_WHEN")
|
|
||||||
override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
|
override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
|
||||||
logger.debug("processActivity: ${hideoutJob.name}")
|
logger.debug("processActivity: ${hideoutJob.name}")
|
||||||
|
|
||||||
@Suppress("ElseCaseInsteadOfExhaustiveWhen")
|
|
||||||
// Springで作成されるプロキシの都合上パターンマッチングが壊れるので必須
|
|
||||||
when (hideoutJob) {
|
when (hideoutJob) {
|
||||||
is ReceiveFollowJob -> {
|
is ReceiveFollowJob -> {
|
||||||
apReceiveFollowService.receiveFollowJob(
|
apReceiveFollowService.receiveFollowJob(
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dev.usbharu.hideout.domain.mastodon.model.generated.Status
|
||||||
import dev.usbharu.hideout.domain.model.hideout.entity.Timeline
|
import dev.usbharu.hideout.domain.model.hideout.entity.Timeline
|
||||||
import dev.usbharu.hideout.query.mastodon.StatusQueryService
|
import dev.usbharu.hideout.query.mastodon.StatusQueryService
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
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.MongoTemplate
|
||||||
import org.springframework.data.mongodb.core.query.Criteria
|
import org.springframework.data.mongodb.core.query.Criteria
|
||||||
import org.springframework.data.mongodb.core.query.Query
|
import org.springframework.data.mongodb.core.query.Query
|
||||||
|
@ -27,7 +26,6 @@ class MongoGenerateTimelineService(
|
||||||
limit: Int
|
limit: Int
|
||||||
): List<Status> {
|
): List<Status> {
|
||||||
val query = Query()
|
val query = Query()
|
||||||
|
|
||||||
if (forUserId != null) {
|
if (forUserId != null) {
|
||||||
val criteria = Criteria.where("userId").`is`(forUserId)
|
val criteria = Criteria.where("userId").`is`(forUserId)
|
||||||
query.addCriteria(criteria)
|
query.addCriteria(criteria)
|
||||||
|
@ -45,10 +43,7 @@ class MongoGenerateTimelineService(
|
||||||
query.addCriteria(criteria)
|
query.addCriteria(criteria)
|
||||||
}
|
}
|
||||||
|
|
||||||
query.limit(limit)
|
val timelines = mongoTemplate.find(query.limit(limit), Timeline::class.java)
|
||||||
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) })
|
return statusQueryService.findByPostIds(timelines.flatMap { setOfNotNull(it.postId, it.replyId, it.repostId) })
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ object HttpUtil {
|
||||||
|
|
||||||
fun isContentTypeOfActivityPub(
|
fun isContentTypeOfActivityPub(
|
||||||
contentType: String,
|
contentType: String,
|
||||||
subType: String
|
subType: String,
|
||||||
|
parameter: String
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (contentType != "application") {
|
if (contentType != "application") {
|
||||||
return false
|
return false
|
||||||
|
@ -31,7 +32,8 @@ object HttpUtil {
|
||||||
fun isContentTypeOfActivityPub(contentType: ContentType): Boolean {
|
fun isContentTypeOfActivityPub(contentType: ContentType): Boolean {
|
||||||
return isContentTypeOfActivityPub(
|
return isContentTypeOfActivityPub(
|
||||||
contentType.contentType,
|
contentType.contentType,
|
||||||
contentType.contentSubtype
|
contentType.contentSubtype,
|
||||||
|
contentType.parameter("profile").orEmpty()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// fun
|
// fun
|
||||||
|
|
Loading…
Reference in New Issue