Merge pull request #275 from usbharu/update-dependencies

Update dependencies
This commit is contained in:
usbharu 2024-02-04 16:49:42 +09:00 committed by GitHub
commit 20c4d3f4e6
31 changed files with 251 additions and 227 deletions

View File

@ -53,10 +53,10 @@ jobs:
build
key: gradle-build-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/*.kt') }}-${{ github.sha }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Build
uses: gradle/gradle-build-action@v2.8.1
@ -104,10 +104,10 @@ jobs:
build
key: gradle-build-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('src') }}-${{ github.sha }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Unit Test
@ -163,10 +163,10 @@ jobs:
build
key: gradle-build-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('src') }}-${{ github.sha }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: MongoDB in GitHub Actions
@ -227,10 +227,10 @@ jobs:
build
key: gradle-build-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('src') }}-${{ github.sha }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Run Kover
@ -322,10 +322,10 @@ jobs:
build
key: gradle-build-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('src') }}-${{ github.sha }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Build with Gradle
@ -380,10 +380,10 @@ jobs:
build
key: gradle-build-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('src') }}-${{ github.sha }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: MongoDB in GitHub Actions

View File

@ -7,16 +7,17 @@ val logback_version: String by project
val exposed_version: String by project
val h2_version: String by project
val koin_version: String by project
val coroutines_version: String by project
val serialization_version: String by project
plugins {
kotlin("jvm") version "1.8.21"
id("org.graalvm.buildtools.native") version "0.9.21"
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("org.springframework.boot") version "3.2.0"
kotlin("plugin.spring") version "1.8.21"
id("org.openapi.generator") version "7.0.1"
kotlin("jvm") version "1.9.22"
id("org.graalvm.buildtools.native") version "0.10.0"
id("io.gitlab.arturbosch.detekt") version "1.23.5"
id("org.springframework.boot") version "3.2.2"
kotlin("plugin.spring") version "1.9.22"
id("org.openapi.generator") version "7.2.0"
id("org.jetbrains.kotlinx.kover") version "0.7.4"
// id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"
}
apply {
@ -91,8 +92,8 @@ tasks.withType<Test> {
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach {
compilerOptions.languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8)
compilerOptions.apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8)
compilerOptions.languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
compilerOptions.apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
}
tasks.withType<KotlinCompile> {
@ -156,7 +157,7 @@ repositories {
kotlin {
target {
compilations.all {
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
kotlinOptions.jvmTarget = JavaVersion.VERSION_21.toString()
}
}
}
@ -169,16 +170,18 @@ sourceSets.main {
)
}
val os = org.gradle.nativeplatform.platform.internal
.DefaultNativePlatform.getCurrentOperatingSystem()
dependencies {
implementation("io.ktor:ktor-serialization-jackson:$ktor_version")
implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
implementation("com.h2database:h2:$h2_version")
implementation("org.xerial:sqlite-jdbc:3.40.1.0")
implementation("org.xerial:sqlite-jdbc:3.45.1.0")
implementation("ch.qos.logback:logback-classic:$logback_version")
implementation("com.auth0:java-jwt:4.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version")
implementation("org.springframework.boot:spring-boot-starter-actuator")
@ -198,20 +201,35 @@ dependencies {
implementation("org.springframework.security:spring-security-oauth2-jose")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
implementation("org.jetbrains.exposed:exposed-spring-boot-starter:0.44.0")
implementation("org.jetbrains.exposed:exposed-spring-boot-starter:$exposed_version")
implementation("io.trbl:blurhash:1.0.0")
implementation("software.amazon.awssdk:s3:2.20.157")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.7.3")
implementation("software.amazon.awssdk:s3:2.23.17")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:$coroutines_version")
implementation("dev.usbharu:http-signature:1.0.0")
implementation("org.postgresql:postgresql:42.6.0")
implementation("com.twelvemonkeys.imageio:imageio-webp:3.10.0")
implementation("org.postgresql:postgresql:42.7.1")
implementation("com.twelvemonkeys.imageio:imageio-webp:3.10.1")
implementation("org.apache.tika:tika-core:2.9.1")
implementation("org.apache.tika:tika-parsers:2.9.1")
implementation("net.coobird:thumbnailator:0.4.20")
implementation("org.bytedeco:javacv-platform:1.5.9")
implementation("org.bytedeco:javacv:1.5.10"){
exclude(module = "opencv")
exclude(module = "flycapture")
exclude(module = "artoolkitplus")
exclude(module = "libdc1394")
exclude(module = "librealsense")
exclude(module = "librealsense2")
exclude(module = "tesseract")
exclude(module = "libfreenect")
exclude(module = "libfreenect2")
}
if (os.isWindows) {
implementation("org.bytedeco","ffmpeg","6.1.1-1.5.10", classifier = "windows-x86_64")
}else{
implementation("org.bytedeco","ffmpeg","6.1.1-1.5.10", classifier = "linux-x86_64")
}
implementation("org.flywaydb:flyway-core")
implementation("dev.usbharu:emoji-kt:2.0.0")
@ -221,28 +239,28 @@ dependencies {
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version")
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-cio:$ktor_version")
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
testImplementation("io.ktor:ktor-client-mock:$ktor_version")
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1")
testImplementation("org.mockito:mockito-inline:5.2.0")
testImplementation("nl.jqno.equalsverifier:equalsverifier:3.15.3")
testImplementation("nl.jqno.equalsverifier:equalsverifier:3.15.6")
testImplementation("com.jparams:to-string-verifier:1.4.8")
implementation("org.drewcarlson:kjob-core:0.6.0")
implementation("org.drewcarlson:kjob-mongo:0.6.0")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.5")
intTestImplementation("org.springframework.boot:spring-boot-starter-test")
intTestImplementation("org.springframework.security:spring-security-test")
intTestImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
intTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
intTestImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
intTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version")
intTestImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1")
e2eTestImplementation("org.springframework.boot:spring-boot-starter-test")
e2eTestImplementation("org.springframework.security:spring-security-test")
@ -283,7 +301,7 @@ tasks.withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configure
configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") {
useVersion("1.9.0")
useVersion("1.9.22")
}
}
}

View File

@ -1,10 +1,11 @@
ktor_version=2.3.0
kotlin_version=1.9.21
logback_version=1.4.6
ktor_version=2.3.8
kotlin_version=1.9.22
logback_version=1.4.14
coroutines_version=1.7.3
serialization_version=1.6.2
kotlin.code.style=official
exposed_version=0.44.0
h2_version=2.1.214
koin_version=3.4.3
exposed_version=0.47.0
h2_version=2.2.224
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,6 +1,5 @@
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import java.net.MalformedURLException
import java.net.URL
@ -23,6 +22,6 @@ object AssertionUtil {
selectAll.map { "@${it[Actors.name]}@${it[Actors.domain]}" }.forEach { println(it) }
return Actors.select { Actors.name eq username and (Actors.domain eq s) }.empty().not()
return Actors.selectAll().where { Actors.name eq username and (Actors.domain eq s) }.empty().not()
}
}

View File

@ -4,7 +4,7 @@ import dev.usbharu.hideout.SpringApplication
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient
import org.assertj.core.api.Assertions.assertThat
import org.flywaydb.core.Flyway
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
@ -55,7 +55,7 @@ class AppTest {
val app = RegisteredClient
.select { RegisteredClient.clientName eq "test-client" }
.selectAll().where { RegisteredClient.clientName eq "test-client" }
.single()
assertThat(app[RegisteredClient.clientName]).isEqualTo("test-client")
@ -80,7 +80,7 @@ class AppTest {
.andExpect { status { isOk() } }
val app = RegisteredClient
.select { RegisteredClient.clientName eq "test-client-2" }
.selectAll().where { RegisteredClient.clientName eq "test-client-2" }
.single()
assertThat(app[RegisteredClient.clientName]).isEqualTo("test-client-2")

View File

@ -9,7 +9,7 @@ import dev.usbharu.hideout.core.infrastructure.exposedrepository.toReaction
import org.assertj.core.api.Assertions.assertThat
import org.flywaydb.core.Flyway
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
@ -61,7 +61,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_JSON
content = """{"status":"hello"}"""
with(
SecurityMockMvcRequestPostProcessors.jwt()
jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write"))
)
}
@ -76,7 +76,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_JSON
content = """{"status":"hello"}"""
with(
SecurityMockMvcRequestPostProcessors.jwt()
jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write:statuses"))
)
}
@ -91,7 +91,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_JSON
content = """{"status":"hello"}"""
with(
SecurityMockMvcRequestPostProcessors.jwt()
jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_read"))
)
}
@ -128,7 +128,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_FORM_URLENCODED
param("status", "hello")
with(
SecurityMockMvcRequestPostProcessors.jwt()
jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write:statuses"))
)
}
@ -147,7 +147,7 @@ class StatusTest {
"in_reply_to_id": "1"
}"""
with(
SecurityMockMvcRequestPostProcessors.jwt()
jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write"))
)
}
@ -167,7 +167,8 @@ class StatusTest {
.asyncDispatch()
.andExpect { status { isOk() } }
val reaction = Reactions.select { Reactions.postId eq 1 and (Reactions.actorId eq 1) }.single().toReaction()
val reaction =
Reactions.selectAll().where { Reactions.postId eq 1 and (Reactions.actorId eq 1) }.single().toReaction()
assertThat(reaction.emoji).isEqualTo(UnicodeEmoji("😭"))
assertThat(reaction.postId).isEqualTo(1)
assertThat(reaction.actorId).isEqualTo(1)
@ -183,7 +184,8 @@ class StatusTest {
.asyncDispatch()
.andExpect { status { isOk() } }
val reaction = Reactions.select { Reactions.postId eq 1 and (Reactions.actorId eq 1) }.single().toReaction()
val reaction =
Reactions.selectAll().where { Reactions.postId eq 1 and (Reactions.actorId eq 1) }.single().toReaction()
assertThat(reaction.emoji).isEqualTo(UnicodeEmoji(""))
assertThat(reaction.postId).isEqualTo(1)
assertThat(reaction.actorId).isEqualTo(1)
@ -200,7 +202,8 @@ class StatusTest {
.andExpect { status { isOk() } }
val reaction =
Reactions.leftJoin(CustomEmojis).select { Reactions.postId eq 1 and (Reactions.actorId eq 1) }.single()
Reactions.leftJoin(CustomEmojis).selectAll().where { Reactions.postId eq 1 and (Reactions.actorId eq 1) }
.single()
.toReaction()
assertThat(reaction.emoji).isEqualTo(
CustomEmoji(

View File

@ -62,6 +62,7 @@ class ContextDeserializer : JsonDeserializer<String>() {
class ContextSerializer : JsonSerializer<List<String>>() {
@Deprecated("Deprecated in Java")
override fun isEmpty(value: List<String>?): Boolean = value.isNullOrEmpty()
override fun isEmpty(provider: SerializerProvider?, value: List<String>?): Boolean = value.isNullOrEmpty()

View File

@ -10,7 +10,7 @@ import dev.usbharu.hideout.core.domain.model.post.Visibility
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Posts
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.springframework.stereotype.Repository
import java.time.Instant
@ -22,7 +22,7 @@ class ExposedAnnounceQueryService(
override suspend fun findById(id: Long): Pair<Announce, Post>? {
return Posts
.leftJoin(Actors)
.select { Posts.id eq id }
.selectAll().where { Posts.id eq id }
.singleOrNull()
?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) }
}
@ -30,7 +30,7 @@ class ExposedAnnounceQueryService(
override suspend fun findByApId(apId: String): Pair<Announce, Post>? {
return Posts
.leftJoin(Actors)
.select { Posts.apId eq apId }
.selectAll().where { Posts.apId eq apId }
.singleOrNull()
?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) }
}
@ -40,7 +40,7 @@ class ExposedAnnounceQueryService(
val repost = postRepository.findById(repostId)?.url ?: return null
val (to, cc) = visibility(
Visibility.values().first { visibility -> visibility.ordinal == this[Posts.visibility] },
Visibility.entries.first { visibility -> visibility.ordinal == this[Posts.visibility] },
this[Actors.followers]
)

View File

@ -11,7 +11,7 @@ import dev.usbharu.hideout.core.domain.model.post.Visibility
import dev.usbharu.hideout.core.infrastructure.exposedrepository.*
import org.jetbrains.exposed.sql.Query
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Repository
import java.time.Instant
@ -24,12 +24,12 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
.leftJoin(Actors)
.leftJoin(PostsMedia)
.leftJoin(Media)
.select { Posts.id eq id }
.selectAll().where { Posts.id eq id }
.let {
(it.toNote() ?: return null) to (
postQueryMapper.map(it)
.singleOrNull() ?: return null
)
postQueryMapper.map(it)
.singleOrNull() ?: return null
)
}
}
@ -38,12 +38,12 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
.leftJoin(Actors)
.leftJoin(PostsMedia)
.leftJoin(Media)
.select { Posts.apId eq apId }
.selectAll().where { Posts.apId eq apId }
.let {
(it.toNote() ?: return null) to (
postQueryMapper.map(it)
.singleOrNull() ?: return null
)
postQueryMapper.map(it)
.singleOrNull() ?: return null
)
}
}

View File

@ -21,9 +21,8 @@ class ExposedNotificationRepository(private val idGenerateService: IdGenerateSer
override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(notification: Notification): Notification = query {
val singleOrNull = Notifications.select {
Notifications.id eq notification.id
}.forUpdate().singleOrNull()
val singleOrNull =
Notifications.selectAll().where { Notifications.id eq notification.id }.forUpdate().singleOrNull()
if (singleOrNull == null) {
Notifications.insert {
it[id] = notification.id
@ -50,7 +49,7 @@ class ExposedNotificationRepository(private val idGenerateService: IdGenerateSer
}
override suspend fun findById(id: Long): Notification? = query {
Notifications.select { Notifications.id eq id }.singleOrNull()?.toNotifications()
Notifications.selectAll().where { Notifications.id eq id }.singleOrNull()?.toNotifications()
}
override suspend fun deleteById(id: Long) {

View File

@ -18,7 +18,7 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
get() = Companion.logger
override suspend fun save(relationship: Relationship): Relationship = query {
val singleOrNull = Relationships.select {
val singleOrNull = Relationships.selectAll().where {
(Relationships.actorId eq relationship.actorId).and(
Relationships.targetActorId eq relationship.targetActorId
)
@ -52,16 +52,16 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
override suspend fun delete(relationship: Relationship): Unit = query {
Relationships.deleteWhere {
(Relationships.actorId eq relationship.actorId).and(
Relationships.targetActorId eq relationship.targetActorId
(actorId eq relationship.actorId).and(
targetActorId eq relationship.targetActorId
)
}
}
override suspend fun findByUserIdAndTargetUserId(actorId: Long, targetActorId: Long): Relationship? = query {
return@query Relationships.select {
(Relationships.actorId eq actorId).and(Relationships.targetActorId eq targetActorId)
}.singleOrNull()?.toRelationships()
return@query Relationships.selectAll()
.where { (Relationships.actorId eq actorId).and(Relationships.targetActorId eq targetActorId) }
.singleOrNull()?.toRelationships()
}
override suspend fun deleteByActorIdOrTargetActorId(actorId: Long, targetActorId: Long): Unit = query {
@ -72,7 +72,7 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
override suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List<Relationship> = query {
return@query Relationships
.select { Relationships.targetActorId eq targetId and (Relationships.following eq following) }
.selectAll().where { Relationships.targetActorId eq targetId and (Relationships.following eq following) }
.map { it.toRelationships() }
}
@ -82,7 +82,7 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
ignoreFollowRequest: Boolean,
page: Page.PageByMaxId
): PaginationList<Relationship, Long> = query {
val query = Relationships.select {
val query = Relationships.selectAll().where {
Relationships.targetActorId.eq(targetId).and(Relationships.followRequest.eq(followRequest))
.and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest))
}
@ -101,9 +101,8 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
muting: Boolean,
page: Page.PageByMaxId
): PaginationList<Relationship, Long> = query {
val query = Relationships.select {
Relationships.actorId.eq(actorId).and(Relationships.muting.eq(muting))
}
val query =
Relationships.selectAll().where { Relationships.actorId.eq(actorId).and(Relationships.muting.eq(muting)) }
val resultRowList = query.withPagination(page, Relationships.id)

View File

@ -22,7 +22,7 @@ class ActorRepositoryImpl(
get() = Companion.logger
override suspend fun save(actor: Actor): Actor = query {
val singleOrNull = Actors.select { Actors.id eq actor.id }.forUpdate().empty()
val singleOrNull = Actors.selectAll().where { Actors.id eq actor.id }.forUpdate().empty()
if (singleOrNull) {
Actors.insert {
it[id] = actor.id
@ -75,11 +75,12 @@ class ActorRepositoryImpl(
}
override suspend fun findById(id: Long): Actor? = query {
return@query Actors.select { Actors.id eq id }.singleOrNull()?.let(actorResultRowMapper::map)
return@query Actors.selectAll().where { Actors.id eq id }.singleOrNull()?.let(actorResultRowMapper::map)
}
override suspend fun findByIdWithLock(id: Long): Actor? = query {
return@query Actors.select { Actors.id eq id }.forUpdate().singleOrNull()?.let(actorResultRowMapper::map)
return@query Actors.selectAll().where { Actors.id eq id }.forUpdate().singleOrNull()
?.let(actorResultRowMapper::map)
}
override suspend fun findAll(limit: Int, offset: Long): List<Actor> = query {
@ -87,33 +88,35 @@ class ActorRepositoryImpl(
}
override suspend fun findByName(name: String): List<Actor> = query {
return@query Actors.select { Actors.name eq name }.let(actorQueryMapper::map)
return@query Actors.selectAll().where { Actors.name eq name }.let(actorQueryMapper::map)
}
override suspend fun findByNameAndDomain(name: String, domain: String): Actor? = query {
return@query Actors.select { Actors.name eq name and (Actors.domain eq domain) }.singleOrNull()
return@query Actors.selectAll().where { Actors.name eq name and (Actors.domain eq domain) }.singleOrNull()
?.let(actorResultRowMapper::map)
}
override suspend fun findByNameAndDomainWithLock(name: String, domain: String): Actor? = query {
return@query Actors.select { Actors.name eq name and (Actors.domain eq domain) }.forUpdate().singleOrNull()
return@query Actors.selectAll().where { Actors.name eq name and (Actors.domain eq domain) }.forUpdate()
.singleOrNull()
?.let(actorResultRowMapper::map)
}
override suspend fun findByUrl(url: String): Actor? = query {
return@query Actors.select { Actors.url eq url }.singleOrNull()?.let(actorResultRowMapper::map)
return@query Actors.selectAll().where { Actors.url eq url }.singleOrNull()?.let(actorResultRowMapper::map)
}
override suspend fun findByUrlWithLock(url: String): Actor? = query {
return@query Actors.select { Actors.url eq url }.forUpdate().singleOrNull()?.let(actorResultRowMapper::map)
return@query Actors.selectAll().where { Actors.url eq url }.forUpdate().singleOrNull()
?.let(actorResultRowMapper::map)
}
override suspend fun findByIds(ids: List<Long>): List<Actor> = query {
return@query Actors.select { Actors.id inList ids }.let(actorQueryMapper::map)
return@query Actors.selectAll().where { Actors.id inList ids }.let(actorQueryMapper::map)
}
override suspend fun findByKeyId(keyId: String): Actor? = query {
return@query Actors.select { Actors.keyId eq keyId }.singleOrNull()?.let(actorResultRowMapper::map)
return@query Actors.selectAll().where { Actors.keyId eq keyId }.singleOrNull()?.let(actorResultRowMapper::map)
}
override suspend fun delete(id: Long): Unit = query {

View File

@ -20,41 +20,42 @@ class CustomEmojiRepositoryImpl(private val idGenerateService: IdGenerateService
override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(customEmoji: CustomEmoji): CustomEmoji = query {
val singleOrNull = CustomEmojis.select { CustomEmojis.id eq customEmoji.id }.forUpdate().singleOrNull()
val singleOrNull =
CustomEmojis.selectAll().where { CustomEmojis.id eq customEmoji.id }.forUpdate().singleOrNull()
if (singleOrNull == null) {
CustomEmojis.insert {
it[CustomEmojis.id] = customEmoji.id
it[CustomEmojis.name] = customEmoji.name
it[CustomEmojis.domain] = customEmoji.domain
it[CustomEmojis.instanceId] = customEmoji.instanceId
it[CustomEmojis.url] = customEmoji.url
it[CustomEmojis.category] = customEmoji.category
it[CustomEmojis.createdAt] = customEmoji.createdAt
it[id] = customEmoji.id
it[name] = customEmoji.name
it[domain] = customEmoji.domain
it[instanceId] = customEmoji.instanceId
it[url] = customEmoji.url
it[category] = customEmoji.category
it[createdAt] = customEmoji.createdAt
}
} else {
CustomEmojis.update({ CustomEmojis.id eq customEmoji.id }) {
it[CustomEmojis.name] = customEmoji.name
it[CustomEmojis.domain] = customEmoji.domain
it[CustomEmojis.instanceId] = customEmoji.instanceId
it[CustomEmojis.url] = customEmoji.url
it[CustomEmojis.category] = customEmoji.category
it[CustomEmojis.createdAt] = customEmoji.createdAt
it[name] = customEmoji.name
it[domain] = customEmoji.domain
it[instanceId] = customEmoji.instanceId
it[url] = customEmoji.url
it[category] = customEmoji.category
it[createdAt] = customEmoji.createdAt
}
}
return@query customEmoji
}
override suspend fun findById(id: Long): CustomEmoji? = query {
return@query CustomEmojis.select { CustomEmojis.id eq id }.singleOrNull()?.toCustomEmoji()
return@query CustomEmojis.selectAll().where { CustomEmojis.id eq id }.singleOrNull()?.toCustomEmoji()
}
override suspend fun delete(customEmoji: CustomEmoji): Unit = query {
CustomEmojis.deleteWhere { CustomEmojis.id eq customEmoji.id }
CustomEmojis.deleteWhere { id eq customEmoji.id }
}
override suspend fun findByNameAndDomain(name: String, domain: String): CustomEmoji? = query {
return@query CustomEmojis
.select { CustomEmojis.name eq name and (CustomEmojis.domain eq domain) }
.selectAll().where { CustomEmojis.name eq name and (CustomEmojis.domain eq domain) }
.singleOrNull()
?.toCustomEmoji()
}

View File

@ -15,41 +15,42 @@ class DeletedActorRepositoryImpl : DeletedActorRepository, AbstractRepository()
get() = Companion.logger
override suspend fun save(deletedActor: DeletedActor): DeletedActor = query {
val singleOrNull = DeletedActors.select { DeletedActors.id eq deletedActor.id }.forUpdate().singleOrNull()
val singleOrNull =
DeletedActors.selectAll().where { DeletedActors.id eq deletedActor.id }.forUpdate().singleOrNull()
if (singleOrNull == null) {
DeletedActors.insert {
it[DeletedActors.id] = deletedActor.id
it[DeletedActors.name] = deletedActor.name
it[DeletedActors.domain] = deletedActor.domain
it[DeletedActors.publicKey] = deletedActor.publicKey
it[DeletedActors.deletedAt] = deletedActor.deletedAt
it[id] = deletedActor.id
it[name] = deletedActor.name
it[domain] = deletedActor.domain
it[publicKey] = deletedActor.publicKey
it[deletedAt] = deletedActor.deletedAt
}
} else {
DeletedActors.update({ DeletedActors.id eq deletedActor.id }) {
it[DeletedActors.name] = deletedActor.name
it[DeletedActors.domain] = deletedActor.domain
it[DeletedActors.publicKey] = deletedActor.publicKey
it[DeletedActors.deletedAt] = deletedActor.deletedAt
it[name] = deletedActor.name
it[domain] = deletedActor.domain
it[publicKey] = deletedActor.publicKey
it[deletedAt] = deletedActor.deletedAt
}
}
return@query deletedActor
}
override suspend fun delete(deletedActor: DeletedActor): Unit = query {
DeletedActors.deleteWhere { DeletedActors.id eq deletedActor.id }
DeletedActors.deleteWhere { id eq deletedActor.id }
}
override suspend fun findById(id: Long): DeletedActor? = query {
return@query DeletedActors
.select { DeletedActors.id eq id }
.selectAll().where { DeletedActors.id eq id }
.singleOrNull()
?.toDeletedActor()
}
override suspend fun findByNameAndDomain(name: String, domain: String): DeletedActor? = query {
return@query DeletedActors
.select { DeletedActors.name eq name and (DeletedActors.domain eq domain) }
.selectAll().where { DeletedActors.name eq name and (DeletedActors.domain eq domain) }
.singleOrNull()
?.toDeletedActor()
}

View File

@ -22,7 +22,7 @@ class ExposedTimelineRepository(private val idGenerateService: IdGenerateService
override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(timeline: Timeline): Timeline = query {
if (Timelines.select { Timelines.id eq timeline.id }.forUpdate().singleOrNull() == null) {
if (Timelines.selectAll().where { Timelines.id eq timeline.id }.forUpdate().singleOrNull() == null) {
Timelines.insert {
it[id] = timeline.id
it[userId] = timeline.userId
@ -80,11 +80,11 @@ class ExposedTimelineRepository(private val idGenerateService: IdGenerateService
}
override suspend fun findByUserId(id: Long): List<Timeline> = query {
return@query Timelines.select { Timelines.userId eq id }.map { it.toTimeline() }
return@query Timelines.selectAll().where { Timelines.userId eq id }.map { it.toTimeline() }
}
override suspend fun findByUserIdAndTimelineId(userId: Long, timelineId: Long): List<Timeline> = query {
return@query Timelines.select { Timelines.userId eq userId and (Timelines.timelineId eq timelineId) }
return@query Timelines.selectAll().where { Timelines.userId eq userId and (Timelines.timelineId eq timelineId) }
.map { it.toTimeline() }
}

View File

@ -19,7 +19,7 @@ class InstanceRepositoryImpl(private val idGenerateService: IdGenerateService) :
override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(instance: InstanceEntity): InstanceEntity = query {
if (Instance.select { Instance.id.eq(instance.id) }.forUpdate().empty()) {
if (Instance.selectAll().where { Instance.id.eq(instance.id) }.forUpdate().empty()) {
Instance.insert {
it[id] = instance.id
it[name] = instance.name
@ -53,7 +53,7 @@ class InstanceRepositoryImpl(private val idGenerateService: IdGenerateService) :
}
override suspend fun findById(id: Long): InstanceEntity? = query {
return@query Instance.select { Instance.id eq id }
return@query Instance.selectAll().where { Instance.id eq id }
.singleOrNull()?.toInstance()
}
@ -62,7 +62,7 @@ class InstanceRepositoryImpl(private val idGenerateService: IdGenerateService) :
}
override suspend fun findByUrl(url: String): dev.usbharu.hideout.core.domain.model.instance.Instance? = query {
return@query Instance.select { Instance.url eq url }.singleOrNull()?.toInstance()
return@query Instance.selectAll().where { Instance.url eq url }.singleOrNull()?.toInstance()
}
companion object {

View File

@ -20,9 +20,7 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(media: EntityMedia): EntityMedia = query {
if (Media.select {
Media.id eq media.id
}.forUpdate().singleOrNull() != null
if (Media.selectAll().where { Media.id eq media.id }.forUpdate().singleOrNull() != null
) {
Media.update({ Media.id eq media.id }) {
it[name] = media.name
@ -52,9 +50,7 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
override suspend fun findById(id: Long): EntityMedia? = query {
return@query Media
.select {
Media.id eq id
}
.selectAll().where { Media.id eq id }
.singleOrNull()
?.toMedia()
}
@ -67,7 +63,7 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
override suspend fun findByRemoteUrl(remoteUrl: String): dev.usbharu.hideout.core.domain.model.media.Media? =
query {
return@query Media.select { Media.remoteUrl eq remoteUrl }.singleOrNull()?.toMedia()
return@query Media.selectAll().where { Media.remoteUrl eq remoteUrl }.singleOrNull()?.toMedia()
}
companion object {

View File

@ -10,7 +10,7 @@ import java.util.*
class MetaRepositoryImpl : MetaRepository {
override suspend fun save(meta: dev.usbharu.hideout.core.domain.model.meta.Meta) {
if (Meta.select { Meta.id eq 1 }.empty()) {
if (Meta.selectAll().where { Meta.id eq 1 }.empty()) {
Meta.insert {
it[id] = 1
it[version] = meta.version
@ -29,7 +29,7 @@ class MetaRepositoryImpl : MetaRepository {
}
override suspend fun get(): dev.usbharu.hideout.core.domain.model.meta.Meta? {
return Meta.select { Meta.id eq 1 }.singleOrNull()?.let {
return Meta.selectAll().where { Meta.id eq 1 }.singleOrNull()?.let {
dev.usbharu.hideout.core.domain.model.meta.Meta(
it[Meta.version],
Jwt(UUID.fromString(it[Meta.kid]), it[Meta.jwtPrivateKey], it[Meta.jwtPublicKey])

View File

@ -21,7 +21,7 @@ class PostRepositoryImpl(
override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(post: Post): Post = query {
val singleOrNull = Posts.select { Posts.id eq post.id }.forUpdate().singleOrNull()
val singleOrNull = Posts.selectAll().where { Posts.id eq post.id }.forUpdate().singleOrNull()
if (singleOrNull == null) {
Posts.insert {
it[id] = post.id
@ -83,7 +83,7 @@ class PostRepositoryImpl(
return@query Posts
.leftJoin(PostsMedia)
.leftJoin(PostsEmojis)
.select { Posts.id eq id }
.selectAll().where { Posts.id eq id }
.let(postQueryMapper::map)
.singleOrNull()
}
@ -92,7 +92,7 @@ class PostRepositoryImpl(
return@query Posts
.leftJoin(PostsMedia)
.leftJoin(PostsEmojis)
.select { Posts.url eq url }
.selectAll().where { Posts.url eq url }
.let(postQueryMapper::map)
.singleOrNull()
}
@ -101,20 +101,20 @@ class PostRepositoryImpl(
return@query Posts
.leftJoin(PostsMedia)
.leftJoin(PostsEmojis)
.select { Posts.apId eq apId }
.selectAll().where { Posts.apId eq apId }
.let(postQueryMapper::map)
.singleOrNull()
}
override suspend fun existByApIdWithLock(apId: String): Boolean = query {
return@query Posts.select { Posts.apId eq apId }.forUpdate().empty().not()
return@query Posts.selectAll().where { Posts.apId eq apId }.forUpdate().empty().not()
}
override suspend fun findByActorId(actorId: Long): List<Post> = query {
return@query Posts
.leftJoin(PostsMedia)
.leftJoin(PostsEmojis)
.select { Posts.actorId eq actorId }.let(postQueryMapper::map)
.selectAll().where { Posts.actorId eq actorId }.let(postQueryMapper::map)
}
override suspend fun delete(id: Long): Unit = query {

View File

@ -23,7 +23,7 @@ class ReactionRepositoryImpl(
override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(reaction: Reaction): Reaction = query {
if (Reactions.select { Reactions.id eq reaction.id }.forUpdate().empty()) {
if (Reactions.selectAll().where { Reactions.id eq reaction.id }.forUpdate().empty()) {
Reactions.insert {
it[id] = reaction.id
if (reaction.emoji is CustomEmoji) {
@ -90,30 +90,32 @@ class ReactionRepositoryImpl(
Reactions.deleteWhere {
Reactions.postId.eq(postId)
.and(Reactions.actorId.eq(actorId))
.and(Reactions.customEmojiId.eq(emoji.id))
.and(customEmojiId.eq(emoji.id))
}
} else {
Reactions.deleteWhere {
Reactions.postId.eq(postId)
.and(Reactions.actorId.eq(actorId))
.and(Reactions.unicodeEmoji.eq(emoji.name))
.and(unicodeEmoji.eq(emoji.name))
}
}
}
override suspend fun findById(id: Long): Reaction? = query {
return@query Reactions.leftJoin(CustomEmojis).select { Reactions.id eq id }.singleOrNull()?.toReaction()
return@query Reactions.leftJoin(CustomEmojis).selectAll().where { Reactions.id eq id }.singleOrNull()
?.toReaction()
}
override suspend fun findByPostId(postId: Long): List<Reaction> = query {
return@query Reactions.leftJoin(CustomEmojis).select { Reactions.postId eq postId }.map { it.toReaction() }
return@query Reactions.leftJoin(CustomEmojis).selectAll().where { Reactions.postId eq postId }
.map { it.toReaction() }
}
override suspend fun findByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Reaction? =
query {
return@query Reactions.leftJoin(CustomEmojis).select {
return@query Reactions.leftJoin(CustomEmojis).selectAll().where {
Reactions.postId eq postId and (Reactions.actorId eq actorId).and(
Reactions.customEmojiId.eq(
Reactions.customEmojiId.eq<Long?>(
emojiId
)
)
@ -122,11 +124,11 @@ class ReactionRepositoryImpl(
override suspend fun existByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Boolean =
query {
return@query Reactions.select {
return@query Reactions.selectAll().where {
Reactions.postId
.eq(postId)
.and(Reactions.actorId.eq(actorId))
.and(Reactions.customEmojiId.eq(emojiId))
.eq<Long>(postId)
.and(Reactions.actorId.eq<Long>(actorId))
.and(Reactions.customEmojiId.eq<Long?>(emojiId))
}.empty().not()
}
@ -135,16 +137,16 @@ class ReactionRepositoryImpl(
actorId: Long,
unicodeEmoji: String
): Boolean = query {
return@query Reactions.select {
return@query Reactions.selectAll().where {
Reactions.postId
.eq(postId)
.and(Reactions.actorId.eq(actorId))
.and(Reactions.unicodeEmoji.eq(unicodeEmoji))
.eq<Long>(postId)
.and(Reactions.actorId.eq<Long>(actorId))
.and(Reactions.unicodeEmoji.eq<String?>(unicodeEmoji))
}.empty().not()
}
override suspend fun existByPostIdAndActorIdAndEmoji(postId: Long, actorId: Long, emoji: Emoji): Boolean = query {
val query = Reactions.select {
val query = Reactions.selectAll().where {
Reactions.postId
.eq(postId)
.and(Reactions.actorId.eq(actorId))
@ -161,14 +163,12 @@ class ReactionRepositoryImpl(
}
override suspend fun existByPostIdAndActor(postId: Long, actorId: Long): Boolean = query {
Reactions.select {
Reactions.postId.eq(postId).and(Reactions.actorId.eq(actorId))
}.empty().not()
Reactions.selectAll().where { Reactions.postId.eq(postId).and(Reactions.actorId.eq(actorId)) }.empty().not()
}
override suspend fun findByPostIdAndActorId(postId: Long, actorId: Long): List<Reaction> = query {
return@query Reactions.leftJoin(CustomEmojis)
.select { Reactions.postId eq postId and (Reactions.actorId eq actorId) }
.selectAll().where { Reactions.postId eq postId and (Reactions.actorId eq actorId) }
.map { it.toReaction() }
}

View File

@ -6,7 +6,7 @@ import org.jetbrains.exposed.dao.id.LongIdTable
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.update
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@ -18,7 +18,8 @@ class UserDetailRepositoryImpl : UserDetailRepository, AbstractRepository() {
get() = Companion.logger
override suspend fun save(userDetail: UserDetail): UserDetail = query {
val singleOrNull = UserDetails.select { UserDetails.actorId eq userDetail.actorId }.forUpdate().singleOrNull()
val singleOrNull =
UserDetails.selectAll().where { UserDetails.actorId eq userDetail.actorId }.forUpdate().singleOrNull()
if (singleOrNull == null) {
UserDetails.insert {
it[actorId] = userDetail.actorId
@ -35,12 +36,12 @@ class UserDetailRepositoryImpl : UserDetailRepository, AbstractRepository() {
}
override suspend fun delete(userDetail: UserDetail): Unit = query {
UserDetails.deleteWhere { UserDetails.actorId eq userDetail.actorId }
UserDetails.deleteWhere { actorId eq userDetail.actorId }
}
override suspend fun findByActorId(actorId: Long): UserDetail? = query {
return@query UserDetails
.select { UserDetails.actorId eq actorId }
.selectAll().where { UserDetails.actorId eq actorId }
.singleOrNull()
?.let {
UserDetail(

View File

@ -26,6 +26,7 @@ class KJobJobQueueParentService : JobQueueParentService {
override fun init(jobDefines: List<Job>) = Unit
@Deprecated("use type safe → scheduleTypeSafe")
override suspend fun <J : Job> schedule(job: J, block: ScheduleContext<J>.(J) -> Unit) {
logger.debug("schedule job={}", job.name)
kjob.schedule(job, block)

View File

@ -21,7 +21,7 @@ class ExposedOAuth2AuthorizationConsentService(
requireNotNull(authorizationConsent)
transaction.transaction {
val singleOrNull =
OAuth2AuthorizationConsent.select {
OAuth2AuthorizationConsent.selectAll().where {
OAuth2AuthorizationConsent.registeredClientId
.eq(authorizationConsent.registeredClientId)
.and(OAuth2AuthorizationConsent.principalName.eq(authorizationConsent.principalName))
@ -50,7 +50,7 @@ class ExposedOAuth2AuthorizationConsentService(
requireNotNull(registeredClientId)
requireNotNull(principalName)
transaction.transaction {
OAuth2AuthorizationConsent.select {
OAuth2AuthorizationConsent.selectAll().where {
(OAuth2AuthorizationConsent.registeredClientId eq registeredClientId)
.and(OAuth2AuthorizationConsent.principalName eq principalName)
}

View File

@ -34,7 +34,7 @@ class ExposedOAuth2AuthorizationService(
override fun save(authorization: OAuth2Authorization?): Unit = runBlocking {
requireNotNull(authorization)
transaction.transaction {
val singleOrNull = Authorization.select { Authorization.id eq authorization.id }.singleOrNull()
val singleOrNull = Authorization.selectAll().where { Authorization.id eq authorization.id }.singleOrNull()
if (singleOrNull == null) {
val authorizationCodeToken = authorization.getToken(OAuth2AuthorizationCode::class.java)
val accessToken = authorization.getToken(OAuth2AccessToken::class.java)
@ -139,7 +139,7 @@ class ExposedOAuth2AuthorizationService(
if (id == null) {
return null
}
return Authorization.select { Authorization.id eq id }.singleOrNull()?.toAuthorization()
return Authorization.selectAll().where { Authorization.id eq id }.singleOrNull()?.toAuthorization()
}
override fun findByToken(token: String?, tokenType: OAuth2TokenType?): OAuth2Authorization? = runBlocking {
@ -147,9 +147,7 @@ class ExposedOAuth2AuthorizationService(
transaction.transaction {
when (tokenType?.value) {
null -> {
Authorization.select {
Authorization.authorizationCodeValue eq token
}.orWhere {
Authorization.selectAll().where { Authorization.authorizationCodeValue eq token }.orWhere {
Authorization.accessTokenValue eq token
}.orWhere {
Authorization.oidcIdTokenValue eq token
@ -163,31 +161,31 @@ class ExposedOAuth2AuthorizationService(
}
OAuth2ParameterNames.STATE -> {
Authorization.select { Authorization.state eq token }
Authorization.selectAll().where { Authorization.state eq token }
}
OAuth2ParameterNames.CODE -> {
Authorization.select { Authorization.authorizationCodeValue eq token }
Authorization.selectAll().where { Authorization.authorizationCodeValue eq token }
}
OAuth2ParameterNames.ACCESS_TOKEN -> {
Authorization.select { Authorization.accessTokenValue eq token }
Authorization.selectAll().where { Authorization.accessTokenValue eq token }
}
OidcParameterNames.ID_TOKEN -> {
Authorization.select { Authorization.oidcIdTokenValue eq token }
Authorization.selectAll().where { Authorization.oidcIdTokenValue eq token }
}
OAuth2ParameterNames.REFRESH_TOKEN -> {
Authorization.select { Authorization.refreshTokenValue eq token }
Authorization.selectAll().where { Authorization.refreshTokenValue eq token }
}
OAuth2ParameterNames.USER_CODE -> {
Authorization.select { Authorization.userCodeValue eq token }
Authorization.selectAll().where { Authorization.userCodeValue eq token }
}
OAuth2ParameterNames.DEVICE_CODE -> {
Authorization.select { Authorization.deviceCodeValue eq token }
Authorization.selectAll().where { Authorization.deviceCodeValue eq token }
}
else -> {

View File

@ -7,6 +7,7 @@ import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.Registered
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient.clientSettings
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient.tokenSettings
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.javatime.CurrentTimestamp
import org.jetbrains.exposed.sql.javatime.timestamp
import org.slf4j.Logger
@ -30,7 +31,8 @@ class RegisteredClientRepositoryImpl : RegisteredClientRepository {
override fun save(registeredClient: SpringRegisteredClient?) {
requireNotNull(registeredClient)
val singleOrNull = RegisteredClient.select { RegisteredClient.id eq registeredClient.id }.singleOrNull()
val singleOrNull =
RegisteredClient.selectAll().where { RegisteredClient.id eq registeredClient.id }.singleOrNull()
if (singleOrNull == null) {
RegisteredClient.insert {
it[id] = registeredClient.id
@ -71,9 +73,7 @@ class RegisteredClientRepositoryImpl : RegisteredClientRepository {
if (id == null) {
return null
}
return RegisteredClient.select {
RegisteredClient.id eq id
}.singleOrNull()?.toRegisteredClient()
return RegisteredClient.selectAll().where { RegisteredClient.id eq id }.singleOrNull()?.toRegisteredClient()
}
@Transactional
@ -81,9 +81,9 @@ class RegisteredClientRepositoryImpl : RegisteredClientRepository {
if (clientId == null) {
return null
}
val toRegisteredClient = RegisteredClient.select {
RegisteredClient.clientId eq clientId
}.singleOrNull()?.toRegisteredClient()
val toRegisteredClient =
RegisteredClient.selectAll().where { RegisteredClient.clientId eq clientId }.singleOrNull()
?.toRegisteredClient()
LOGGER.trace("findByClientId: {}", toRegisteredClient)
return toRegisteredClient
}

View File

@ -5,14 +5,14 @@ import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
import dev.usbharu.hideout.domain.mastodon.model.generated.Account
import dev.usbharu.hideout.mastodon.query.AccountQueryService
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.springframework.stereotype.Repository
import java.time.Instant
@Repository
class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) : AccountQueryService {
override suspend fun findById(accountId: Long): Account? {
val query = Actors.select { Actors.id eq accountId }
val query = Actors.selectAll().where { Actors.id eq accountId }
return query
.singleOrNull()
@ -20,7 +20,7 @@ class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig)
}
override suspend fun findByIds(accountIds: List<Long>): List<Account> {
val query = Actors.select { Actors.id inList accountIds }
val query = Actors.selectAll().where { Actors.id inList accountIds }
return query
.map { toAccount(it) }

View File

@ -13,7 +13,7 @@ import dev.usbharu.hideout.mastodon.interfaces.api.status.StatusQuery
import dev.usbharu.hideout.mastodon.query.StatusQueryService
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.andWhere
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.springframework.stereotype.Repository
import java.time.Instant
import dev.usbharu.hideout.domain.mastodon.model.generated.CustomEmoji as MastodonEmoji
@ -34,14 +34,14 @@ class StatusQueryServiceImpl : StatusQueryService {
val postMap = Posts
.leftJoin(Actors)
.select { Posts.id inList postIdSet }
.selectAll().where { Posts.id inList postIdSet }
.associate { it[Posts.id] to toStatus(it) }
val mediaMap = Media.select { Media.id inList mediaIdSet }
val mediaMap = Media.selectAll().where { Media.id inList mediaIdSet }
.associate {
it[Media.id] to it.toMedia().toMediaAttachments()
}
val emojiMap = CustomEmojis.select { CustomEmojis.id inList emojiIdSet }.associate {
val emojiMap = CustomEmojis.selectAll().where { CustomEmojis.id inList emojiIdSet }.associate {
it[CustomEmojis.id] to it.toCustomEmoji().toMastodonEmoji()
}
return statusQueries.mapNotNull { statusQuery ->
@ -69,7 +69,7 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin(PostsMedia)
.leftJoin(Actors)
.leftJoin(Media)
.select { Posts.actorId eq accountId }
.selectAll().where { Posts.actorId eq accountId }
if (onlyMedia) {
query.andWhere { PostsMedia.mediaId.isNotNull() }
@ -111,7 +111,7 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin(PostsMedia)
.leftJoin(Actors)
.leftJoin(Media)
.select { Posts.id eq id }
.selectAll().where { Posts.id eq id }
.groupBy { it[Posts.id] }
.map { it.value }
.map {
@ -153,7 +153,7 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin(CustomEmojis)
.leftJoin(Actors)
.leftJoin(Media)
.select { Posts.id inList ids }
.selectAll().where { Posts.id inList ids }
.groupBy { it[Posts.id] }
.map { it.value }
.map {

View File

@ -25,26 +25,27 @@ class ExposedMastodonNotificationRepository : MastodonNotificationRepository, Ab
override suspend fun save(mastodonNotification: MastodonNotification): MastodonNotification = query {
val singleOrNull =
MastodonNotifications.select { MastodonNotifications.id eq mastodonNotification.id }.singleOrNull()
MastodonNotifications.selectAll().where { MastodonNotifications.id eq mastodonNotification.id }
.singleOrNull()
if (singleOrNull == null) {
MastodonNotifications.insert {
it[MastodonNotifications.id] = mastodonNotification.id
it[MastodonNotifications.type] = mastodonNotification.type.name
it[MastodonNotifications.createdAt] = mastodonNotification.createdAt
it[MastodonNotifications.accountId] = mastodonNotification.accountId
it[MastodonNotifications.statusId] = mastodonNotification.statusId
it[MastodonNotifications.reportId] = mastodonNotification.reportId
it[MastodonNotifications.relationshipServeranceEventId] =
it[id] = mastodonNotification.id
it[type] = mastodonNotification.type.name
it[createdAt] = mastodonNotification.createdAt
it[accountId] = mastodonNotification.accountId
it[statusId] = mastodonNotification.statusId
it[reportId] = mastodonNotification.reportId
it[relationshipServeranceEventId] =
mastodonNotification.relationshipServeranceEvent
}
} else {
MastodonNotifications.update({ MastodonNotifications.id eq mastodonNotification.id }) {
it[MastodonNotifications.type] = mastodonNotification.type.name
it[MastodonNotifications.createdAt] = mastodonNotification.createdAt
it[MastodonNotifications.accountId] = mastodonNotification.accountId
it[MastodonNotifications.statusId] = mastodonNotification.statusId
it[MastodonNotifications.reportId] = mastodonNotification.reportId
it[MastodonNotifications.relationshipServeranceEventId] =
it[type] = mastodonNotification.type.name
it[createdAt] = mastodonNotification.createdAt
it[accountId] = mastodonNotification.accountId
it[statusId] = mastodonNotification.statusId
it[reportId] = mastodonNotification.reportId
it[relationshipServeranceEventId] =
mastodonNotification.relationshipServeranceEvent
}
}
@ -58,7 +59,8 @@ class ExposedMastodonNotificationRepository : MastodonNotificationRepository, Ab
}
override suspend fun findById(id: Long): MastodonNotification? = query {
MastodonNotifications.select { MastodonNotifications.id eq id }.singleOrNull()?.toMastodonNotification()
MastodonNotifications.selectAll().where { MastodonNotifications.id eq id }.singleOrNull()
?.toMastodonNotification()
}
override suspend fun findByUserIdAndInTypesAndInSourceActorId(
@ -67,9 +69,7 @@ class ExposedMastodonNotificationRepository : MastodonNotificationRepository, Ab
accountId: List<Long>,
page: Page
): PaginationList<MastodonNotification, Long> = query {
val query = MastodonNotifications.select {
MastodonNotifications.userId eq loginUser
}
val query = MastodonNotifications.selectAll().where { MastodonNotifications.userId eq loginUser }
val result = query.withPagination(page, MastodonNotifications.id)
return@query PaginationList(result.map { it.toMastodonNotification() }, result.next, result.prev)

View File

@ -37,6 +37,9 @@ spring:
h2:
console:
enabled: true
threads:
virtual:
enabled: true
server:
tomcat:
basedir: tomcat

View File

@ -99,7 +99,7 @@ class ExposedPaginationExtensionKtTest {
@Test
fun 結果が0件の場合はprevとnextがnullになる():Unit = transaction {
val pagination = ExposePaginationTestTable.select { ExposePaginationTestTable.id.isNull() }
val pagination = ExposePaginationTestTable.selectAll().where { ExposePaginationTestTable.id.isNull() }
.withPagination(Page.of(), ExposePaginationTestTable.id)
assertThat(pagination).isEmpty()
@ -111,7 +111,7 @@ class ExposedPaginationExtensionKtTest {
val id = long("id")
val name = varchar("name",100)
override val primaryKey: PrimaryKey?
override val primaryKey: PrimaryKey
get() = PrimaryKey(id)
}