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

View File

@ -7,16 +7,17 @@ val logback_version: String by project
val exposed_version: String by project val exposed_version: String by project
val h2_version: String by project val h2_version: String by project
val koin_version: String by project val koin_version: String by project
val coroutines_version: String by project
val serialization_version: String by project
plugins { plugins {
kotlin("jvm") version "1.8.21" kotlin("jvm") version "1.9.22"
id("org.graalvm.buildtools.native") version "0.9.21" id("org.graalvm.buildtools.native") version "0.10.0"
id("io.gitlab.arturbosch.detekt") version "1.23.1" id("io.gitlab.arturbosch.detekt") version "1.23.5"
id("org.springframework.boot") version "3.2.0" id("org.springframework.boot") version "3.2.2"
kotlin("plugin.spring") version "1.8.21" kotlin("plugin.spring") version "1.9.22"
id("org.openapi.generator") version "7.0.1" id("org.openapi.generator") version "7.2.0"
id("org.jetbrains.kotlinx.kover") version "0.7.4" id("org.jetbrains.kotlinx.kover") version "0.7.4"
// id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"
} }
apply { apply {
@ -91,8 +92,8 @@ tasks.withType<Test> {
} }
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach { tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach {
compilerOptions.languageVersion.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_8) compilerOptions.apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
@ -156,7 +157,7 @@ repositories {
kotlin { kotlin {
target { target {
compilations.all { 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 { dependencies {
implementation("io.ktor:ktor-serialization-jackson:$ktor_version") implementation("io.ktor:ktor-serialization-jackson:$ktor_version")
implementation("org.jetbrains.exposed:exposed-core:$exposed_version") implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version") implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
implementation("com.h2database:h2:$h2_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("ch.qos.logback:logback-classic:$logback_version")
implementation("com.auth0:java-jwt:4.4.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.boot:spring-boot-starter-actuator")
@ -198,20 +201,35 @@ dependencies {
implementation("org.springframework.security:spring-security-oauth2-jose") 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")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive") 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("io.trbl:blurhash:1.0.0")
implementation("software.amazon.awssdk:s3:2.20.157") implementation("software.amazon.awssdk:s3:2.23.17")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.7.3") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.7.3") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:$coroutines_version")
implementation("dev.usbharu:http-signature:1.0.0") implementation("dev.usbharu:http-signature:1.0.0")
implementation("org.postgresql:postgresql:42.6.0") implementation("org.postgresql:postgresql:42.7.1")
implementation("com.twelvemonkeys.imageio:imageio-webp:3.10.0") implementation("com.twelvemonkeys.imageio:imageio-webp:3.10.1")
implementation("org.apache.tika:tika-core:2.9.1") implementation("org.apache.tika:tika-core:2.9.1")
implementation("org.apache.tika:tika-parsers:2.9.1") implementation("org.apache.tika:tika-parsers:2.9.1")
implementation("net.coobird:thumbnailator:0.4.20") 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("org.flywaydb:flyway-core")
implementation("dev.usbharu:emoji-kt:2.0.0") implementation("dev.usbharu:emoji-kt:2.0.0")
@ -221,28 +239,28 @@ dependencies {
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version") implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_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-core:$ktor_version")
implementation("io.ktor:ktor-client-cio:$ktor_version") implementation("io.ktor:ktor-client-cio:$ktor_version")
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version") implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
testImplementation("io.ktor:ktor-client-mock:$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("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") testImplementation("com.jparams:to-string-verifier:1.4.8")
implementation("org.drewcarlson:kjob-core:0.6.0") implementation("org.drewcarlson:kjob-core:0.6.0")
implementation("org.drewcarlson:kjob-mongo: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.boot:spring-boot-starter-test")
intTestImplementation("org.springframework.security:spring-security-test") intTestImplementation("org.springframework.security:spring-security-test")
intTestImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") intTestImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
intTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4") intTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version")
intTestImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") intTestImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1")
e2eTestImplementation("org.springframework.boot:spring-boot-starter-test") e2eTestImplementation("org.springframework.boot:spring-boot-starter-test")
e2eTestImplementation("org.springframework.security:spring-security-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 { configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency { resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") { 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 ktor_version=2.3.8
kotlin_version=1.9.21 kotlin_version=1.9.22
logback_version=1.4.6 logback_version=1.4.14
coroutines_version=1.7.3
serialization_version=1.6.2
kotlin.code.style=official kotlin.code.style=official
exposed_version=0.44.0 exposed_version=0.47.0
h2_version=2.1.214 h2_version=2.2.224
koin_version=3.4.3
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
org.gradle.caching=true org.gradle.caching=true

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -1,6 +1,5 @@
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.selectAll
import java.net.MalformedURLException import java.net.MalformedURLException
import java.net.URL import java.net.URL
@ -23,6 +22,6 @@ object AssertionUtil {
selectAll.map { "@${it[Actors.name]}@${it[Actors.domain]}" }.forEach { println(it) } 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 dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.flywaydb.core.Flyway 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.AfterAll
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -55,7 +55,7 @@ class AppTest {
val app = RegisteredClient val app = RegisteredClient
.select { RegisteredClient.clientName eq "test-client" } .selectAll().where { RegisteredClient.clientName eq "test-client" }
.single() .single()
assertThat(app[RegisteredClient.clientName]).isEqualTo("test-client") assertThat(app[RegisteredClient.clientName]).isEqualTo("test-client")
@ -80,7 +80,7 @@ class AppTest {
.andExpect { status { isOk() } } .andExpect { status { isOk() } }
val app = RegisteredClient val app = RegisteredClient
.select { RegisteredClient.clientName eq "test-client-2" } .selectAll().where { RegisteredClient.clientName eq "test-client-2" }
.single() .single()
assertThat(app[RegisteredClient.clientName]).isEqualTo("test-client-2") 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.assertj.core.api.Assertions.assertThat
import org.flywaydb.core.Flyway import org.flywaydb.core.Flyway
import org.jetbrains.exposed.sql.and 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.AfterAll
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -61,7 +61,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_JSON contentType = MediaType.APPLICATION_JSON
content = """{"status":"hello"}""" content = """{"status":"hello"}"""
with( with(
SecurityMockMvcRequestPostProcessors.jwt() jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write")) .jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write"))
) )
} }
@ -76,7 +76,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_JSON contentType = MediaType.APPLICATION_JSON
content = """{"status":"hello"}""" content = """{"status":"hello"}"""
with( with(
SecurityMockMvcRequestPostProcessors.jwt() jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write:statuses")) .jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write:statuses"))
) )
} }
@ -91,7 +91,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_JSON contentType = MediaType.APPLICATION_JSON
content = """{"status":"hello"}""" content = """{"status":"hello"}"""
with( with(
SecurityMockMvcRequestPostProcessors.jwt() jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_read")) .jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_read"))
) )
} }
@ -128,7 +128,7 @@ class StatusTest {
contentType = MediaType.APPLICATION_FORM_URLENCODED contentType = MediaType.APPLICATION_FORM_URLENCODED
param("status", "hello") param("status", "hello")
with( with(
SecurityMockMvcRequestPostProcessors.jwt() jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write:statuses")) .jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write:statuses"))
) )
} }
@ -147,7 +147,7 @@ class StatusTest {
"in_reply_to_id": "1" "in_reply_to_id": "1"
}""" }"""
with( with(
SecurityMockMvcRequestPostProcessors.jwt() jwt()
.jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write")) .jwt { it.claim("uid", "1") }.authorities(SimpleGrantedAuthority("SCOPE_write"))
) )
} }
@ -167,7 +167,8 @@ class StatusTest {
.asyncDispatch() .asyncDispatch()
.andExpect { status { isOk() } } .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.emoji).isEqualTo(UnicodeEmoji("😭"))
assertThat(reaction.postId).isEqualTo(1) assertThat(reaction.postId).isEqualTo(1)
assertThat(reaction.actorId).isEqualTo(1) assertThat(reaction.actorId).isEqualTo(1)
@ -183,7 +184,8 @@ class StatusTest {
.asyncDispatch() .asyncDispatch()
.andExpect { status { isOk() } } .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.emoji).isEqualTo(UnicodeEmoji(""))
assertThat(reaction.postId).isEqualTo(1) assertThat(reaction.postId).isEqualTo(1)
assertThat(reaction.actorId).isEqualTo(1) assertThat(reaction.actorId).isEqualTo(1)
@ -200,7 +202,8 @@ class StatusTest {
.andExpect { status { isOk() } } .andExpect { status { isOk() } }
val reaction = 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() .toReaction()
assertThat(reaction.emoji).isEqualTo( assertThat(reaction.emoji).isEqualTo(
CustomEmoji( CustomEmoji(

View File

@ -62,6 +62,7 @@ class ContextDeserializer : JsonDeserializer<String>() {
class ContextSerializer : JsonSerializer<List<String>>() { class ContextSerializer : JsonSerializer<List<String>>() {
@Deprecated("Deprecated in Java")
override fun isEmpty(value: List<String>?): Boolean = value.isNullOrEmpty() override fun isEmpty(value: List<String>?): Boolean = value.isNullOrEmpty()
override fun isEmpty(provider: SerializerProvider?, 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.Actors
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Posts import dev.usbharu.hideout.core.infrastructure.exposedrepository.Posts
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.springframework.stereotype.Repository import org.springframework.stereotype.Repository
import java.time.Instant import java.time.Instant
@ -22,7 +22,7 @@ class ExposedAnnounceQueryService(
override suspend fun findById(id: Long): Pair<Announce, Post>? { override suspend fun findById(id: Long): Pair<Announce, Post>? {
return Posts return Posts
.leftJoin(Actors) .leftJoin(Actors)
.select { Posts.id eq id } .selectAll().where { Posts.id eq id }
.singleOrNull() .singleOrNull()
?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) } ?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) }
} }
@ -30,7 +30,7 @@ class ExposedAnnounceQueryService(
override suspend fun findByApId(apId: String): Pair<Announce, Post>? { override suspend fun findByApId(apId: String): Pair<Announce, Post>? {
return Posts return Posts
.leftJoin(Actors) .leftJoin(Actors)
.select { Posts.apId eq apId } .selectAll().where { Posts.apId eq apId }
.singleOrNull() .singleOrNull()
?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) } ?.let { (it.toAnnounce() ?: return null) to (postResultRowMapper.map(it)) }
} }
@ -40,7 +40,7 @@ class ExposedAnnounceQueryService(
val repost = postRepository.findById(repostId)?.url ?: return null val repost = postRepository.findById(repostId)?.url ?: return null
val (to, cc) = visibility( 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] 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 dev.usbharu.hideout.core.infrastructure.exposedrepository.*
import org.jetbrains.exposed.sql.Query import org.jetbrains.exposed.sql.Query
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.springframework.stereotype.Repository import org.springframework.stereotype.Repository
import java.time.Instant import java.time.Instant
@ -24,12 +24,12 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
.leftJoin(Actors) .leftJoin(Actors)
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(Media) .leftJoin(Media)
.select { Posts.id eq id } .selectAll().where { Posts.id eq id }
.let { .let {
(it.toNote() ?: return null) to ( (it.toNote() ?: return null) to (
postQueryMapper.map(it) postQueryMapper.map(it)
.singleOrNull() ?: return null .singleOrNull() ?: return null
) )
} }
} }
@ -38,12 +38,12 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
.leftJoin(Actors) .leftJoin(Actors)
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(Media) .leftJoin(Media)
.select { Posts.apId eq apId } .selectAll().where { Posts.apId eq apId }
.let { .let {
(it.toNote() ?: return null) to ( (it.toNote() ?: return null) to (
postQueryMapper.map(it) postQueryMapper.map(it)
.singleOrNull() ?: return null .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 generateId(): Long = idGenerateService.generateId()
override suspend fun save(notification: Notification): Notification = query { override suspend fun save(notification: Notification): Notification = query {
val singleOrNull = Notifications.select { val singleOrNull =
Notifications.id eq notification.id Notifications.selectAll().where { Notifications.id eq notification.id }.forUpdate().singleOrNull()
}.forUpdate().singleOrNull()
if (singleOrNull == null) { if (singleOrNull == null) {
Notifications.insert { Notifications.insert {
it[id] = notification.id it[id] = notification.id
@ -50,7 +49,7 @@ class ExposedNotificationRepository(private val idGenerateService: IdGenerateSer
} }
override suspend fun findById(id: Long): Notification? = query { 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) { override suspend fun deleteById(id: Long) {

View File

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

View File

@ -22,7 +22,7 @@ class ActorRepositoryImpl(
get() = Companion.logger get() = Companion.logger
override suspend fun save(actor: Actor): Actor = query { 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) { if (singleOrNull) {
Actors.insert { Actors.insert {
it[id] = actor.id it[id] = actor.id
@ -75,11 +75,12 @@ class ActorRepositoryImpl(
} }
override suspend fun findById(id: Long): Actor? = query { 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 { 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 { 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 { 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 { 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) ?.let(actorResultRowMapper::map)
} }
override suspend fun findByNameAndDomainWithLock(name: String, domain: String): Actor? = query { 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) ?.let(actorResultRowMapper::map)
} }
override suspend fun findByUrl(url: String): Actor? = query { 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 { 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 { 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 { 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 { 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 generateId(): Long = idGenerateService.generateId()
override suspend fun save(customEmoji: CustomEmoji): CustomEmoji = query { 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) { if (singleOrNull == null) {
CustomEmojis.insert { CustomEmojis.insert {
it[CustomEmojis.id] = customEmoji.id it[id] = customEmoji.id
it[CustomEmojis.name] = customEmoji.name it[name] = customEmoji.name
it[CustomEmojis.domain] = customEmoji.domain it[domain] = customEmoji.domain
it[CustomEmojis.instanceId] = customEmoji.instanceId it[instanceId] = customEmoji.instanceId
it[CustomEmojis.url] = customEmoji.url it[url] = customEmoji.url
it[CustomEmojis.category] = customEmoji.category it[category] = customEmoji.category
it[CustomEmojis.createdAt] = customEmoji.createdAt it[createdAt] = customEmoji.createdAt
} }
} else { } else {
CustomEmojis.update({ CustomEmojis.id eq customEmoji.id }) { CustomEmojis.update({ CustomEmojis.id eq customEmoji.id }) {
it[CustomEmojis.name] = customEmoji.name it[name] = customEmoji.name
it[CustomEmojis.domain] = customEmoji.domain it[domain] = customEmoji.domain
it[CustomEmojis.instanceId] = customEmoji.instanceId it[instanceId] = customEmoji.instanceId
it[CustomEmojis.url] = customEmoji.url it[url] = customEmoji.url
it[CustomEmojis.category] = customEmoji.category it[category] = customEmoji.category
it[CustomEmojis.createdAt] = customEmoji.createdAt it[createdAt] = customEmoji.createdAt
} }
} }
return@query customEmoji return@query customEmoji
} }
override suspend fun findById(id: Long): CustomEmoji? = query { 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 { 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 { override suspend fun findByNameAndDomain(name: String, domain: String): CustomEmoji? = query {
return@query CustomEmojis 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() .singleOrNull()
?.toCustomEmoji() ?.toCustomEmoji()
} }

View File

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

View File

@ -22,7 +22,7 @@ class ExposedTimelineRepository(private val idGenerateService: IdGenerateService
override suspend fun generateId(): Long = idGenerateService.generateId() override suspend fun generateId(): Long = idGenerateService.generateId()
override suspend fun save(timeline: Timeline): Timeline = query { 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 { Timelines.insert {
it[id] = timeline.id it[id] = timeline.id
it[userId] = timeline.userId it[userId] = timeline.userId
@ -80,11 +80,11 @@ class ExposedTimelineRepository(private val idGenerateService: IdGenerateService
} }
override suspend fun findByUserId(id: Long): List<Timeline> = query { 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 { 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() } .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 generateId(): Long = idGenerateService.generateId()
override suspend fun save(instance: InstanceEntity): InstanceEntity = query { 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 { Instance.insert {
it[id] = instance.id it[id] = instance.id
it[name] = instance.name it[name] = instance.name
@ -53,7 +53,7 @@ class InstanceRepositoryImpl(private val idGenerateService: IdGenerateService) :
} }
override suspend fun findById(id: Long): InstanceEntity? = query { 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() .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 { 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 { 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 generateId(): Long = idGenerateService.generateId()
override suspend fun save(media: EntityMedia): EntityMedia = query { override suspend fun save(media: EntityMedia): EntityMedia = query {
if (Media.select { if (Media.selectAll().where { Media.id eq media.id }.forUpdate().singleOrNull() != null
Media.id eq media.id
}.forUpdate().singleOrNull() != null
) { ) {
Media.update({ Media.id eq media.id }) { Media.update({ Media.id eq media.id }) {
it[name] = media.name it[name] = media.name
@ -52,9 +50,7 @@ class MediaRepositoryImpl(private val idGenerateService: IdGenerateService) : Me
override suspend fun findById(id: Long): EntityMedia? = query { override suspend fun findById(id: Long): EntityMedia? = query {
return@query Media return@query Media
.select { .selectAll().where { Media.id eq id }
Media.id eq id
}
.singleOrNull() .singleOrNull()
?.toMedia() ?.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? = override suspend fun findByRemoteUrl(remoteUrl: String): dev.usbharu.hideout.core.domain.model.media.Media? =
query { query {
return@query Media.select { Media.remoteUrl eq remoteUrl }.singleOrNull()?.toMedia() return@query Media.selectAll().where { Media.remoteUrl eq remoteUrl }.singleOrNull()?.toMedia()
} }
companion object { companion object {

View File

@ -10,7 +10,7 @@ import java.util.*
class MetaRepositoryImpl : MetaRepository { class MetaRepositoryImpl : MetaRepository {
override suspend fun save(meta: dev.usbharu.hideout.core.domain.model.meta.Meta) { 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 { Meta.insert {
it[id] = 1 it[id] = 1
it[version] = meta.version it[version] = meta.version
@ -29,7 +29,7 @@ class MetaRepositoryImpl : MetaRepository {
} }
override suspend fun get(): dev.usbharu.hideout.core.domain.model.meta.Meta? { 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( dev.usbharu.hideout.core.domain.model.meta.Meta(
it[Meta.version], it[Meta.version],
Jwt(UUID.fromString(it[Meta.kid]), it[Meta.jwtPrivateKey], it[Meta.jwtPublicKey]) 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 generateId(): Long = idGenerateService.generateId()
override suspend fun save(post: Post): Post = query { 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) { if (singleOrNull == null) {
Posts.insert { Posts.insert {
it[id] = post.id it[id] = post.id
@ -83,7 +83,7 @@ class PostRepositoryImpl(
return@query Posts return@query Posts
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(PostsEmojis) .leftJoin(PostsEmojis)
.select { Posts.id eq id } .selectAll().where { Posts.id eq id }
.let(postQueryMapper::map) .let(postQueryMapper::map)
.singleOrNull() .singleOrNull()
} }
@ -92,7 +92,7 @@ class PostRepositoryImpl(
return@query Posts return@query Posts
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(PostsEmojis) .leftJoin(PostsEmojis)
.select { Posts.url eq url } .selectAll().where { Posts.url eq url }
.let(postQueryMapper::map) .let(postQueryMapper::map)
.singleOrNull() .singleOrNull()
} }
@ -101,20 +101,20 @@ class PostRepositoryImpl(
return@query Posts return@query Posts
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(PostsEmojis) .leftJoin(PostsEmojis)
.select { Posts.apId eq apId } .selectAll().where { Posts.apId eq apId }
.let(postQueryMapper::map) .let(postQueryMapper::map)
.singleOrNull() .singleOrNull()
} }
override suspend fun existByApIdWithLock(apId: String): Boolean = query { 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 { override suspend fun findByActorId(actorId: Long): List<Post> = query {
return@query Posts return@query Posts
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(PostsEmojis) .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 { 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 generateId(): Long = idGenerateService.generateId()
override suspend fun save(reaction: Reaction): Reaction = query { 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 { Reactions.insert {
it[id] = reaction.id it[id] = reaction.id
if (reaction.emoji is CustomEmoji) { if (reaction.emoji is CustomEmoji) {
@ -90,30 +90,32 @@ class ReactionRepositoryImpl(
Reactions.deleteWhere { Reactions.deleteWhere {
Reactions.postId.eq(postId) Reactions.postId.eq(postId)
.and(Reactions.actorId.eq(actorId)) .and(Reactions.actorId.eq(actorId))
.and(Reactions.customEmojiId.eq(emoji.id)) .and(customEmojiId.eq(emoji.id))
} }
} else { } else {
Reactions.deleteWhere { Reactions.deleteWhere {
Reactions.postId.eq(postId) Reactions.postId.eq(postId)
.and(Reactions.actorId.eq(actorId)) .and(Reactions.actorId.eq(actorId))
.and(Reactions.unicodeEmoji.eq(emoji.name)) .and(unicodeEmoji.eq(emoji.name))
} }
} }
} }
override suspend fun findById(id: Long): Reaction? = query { 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 { 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? = override suspend fun findByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Reaction? =
query { 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.postId eq postId and (Reactions.actorId eq actorId).and(
Reactions.customEmojiId.eq( Reactions.customEmojiId.eq<Long?>(
emojiId emojiId
) )
) )
@ -122,11 +124,11 @@ class ReactionRepositoryImpl(
override suspend fun existByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Boolean = override suspend fun existByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Boolean =
query { query {
return@query Reactions.select { return@query Reactions.selectAll().where {
Reactions.postId Reactions.postId
.eq(postId) .eq<Long>(postId)
.and(Reactions.actorId.eq(actorId)) .and(Reactions.actorId.eq<Long>(actorId))
.and(Reactions.customEmojiId.eq(emojiId)) .and(Reactions.customEmojiId.eq<Long?>(emojiId))
}.empty().not() }.empty().not()
} }
@ -135,16 +137,16 @@ class ReactionRepositoryImpl(
actorId: Long, actorId: Long,
unicodeEmoji: String unicodeEmoji: String
): Boolean = query { ): Boolean = query {
return@query Reactions.select { return@query Reactions.selectAll().where {
Reactions.postId Reactions.postId
.eq(postId) .eq<Long>(postId)
.and(Reactions.actorId.eq(actorId)) .and(Reactions.actorId.eq<Long>(actorId))
.and(Reactions.unicodeEmoji.eq(unicodeEmoji)) .and(Reactions.unicodeEmoji.eq<String?>(unicodeEmoji))
}.empty().not() }.empty().not()
} }
override suspend fun existByPostIdAndActorIdAndEmoji(postId: Long, actorId: Long, emoji: Emoji): Boolean = query { override suspend fun existByPostIdAndActorIdAndEmoji(postId: Long, actorId: Long, emoji: Emoji): Boolean = query {
val query = Reactions.select { val query = Reactions.selectAll().where {
Reactions.postId Reactions.postId
.eq(postId) .eq(postId)
.and(Reactions.actorId.eq(actorId)) .and(Reactions.actorId.eq(actorId))
@ -161,14 +163,12 @@ class ReactionRepositoryImpl(
} }
override suspend fun existByPostIdAndActor(postId: Long, actorId: Long): Boolean = query { override suspend fun existByPostIdAndActor(postId: Long, actorId: Long): Boolean = query {
Reactions.select { Reactions.selectAll().where { Reactions.postId.eq(postId).and(Reactions.actorId.eq(actorId)) }.empty().not()
Reactions.postId.eq(postId).and(Reactions.actorId.eq(actorId))
}.empty().not()
} }
override suspend fun findByPostIdAndActorId(postId: Long, actorId: Long): List<Reaction> = query { override suspend fun findByPostIdAndActorId(postId: Long, actorId: Long): List<Reaction> = query {
return@query Reactions.leftJoin(CustomEmojis) 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() } .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.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert 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.jetbrains.exposed.sql.update
import org.slf4j.Logger import org.slf4j.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
@ -18,7 +18,8 @@ class UserDetailRepositoryImpl : UserDetailRepository, AbstractRepository() {
get() = Companion.logger get() = Companion.logger
override suspend fun save(userDetail: UserDetail): UserDetail = query { 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) { if (singleOrNull == null) {
UserDetails.insert { UserDetails.insert {
it[actorId] = userDetail.actorId it[actorId] = userDetail.actorId
@ -35,12 +36,12 @@ class UserDetailRepositoryImpl : UserDetailRepository, AbstractRepository() {
} }
override suspend fun delete(userDetail: UserDetail): Unit = query { 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 { override suspend fun findByActorId(actorId: Long): UserDetail? = query {
return@query UserDetails return@query UserDetails
.select { UserDetails.actorId eq actorId } .selectAll().where { UserDetails.actorId eq actorId }
.singleOrNull() .singleOrNull()
?.let { ?.let {
UserDetail( UserDetail(

View File

@ -26,6 +26,7 @@ class KJobJobQueueParentService : JobQueueParentService {
override fun init(jobDefines: List<Job>) = Unit 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) { override suspend fun <J : Job> schedule(job: J, block: ScheduleContext<J>.(J) -> Unit) {
logger.debug("schedule job={}", job.name) logger.debug("schedule job={}", job.name)
kjob.schedule(job, block) kjob.schedule(job, block)

View File

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

View File

@ -34,7 +34,7 @@ class ExposedOAuth2AuthorizationService(
override fun save(authorization: OAuth2Authorization?): Unit = runBlocking { override fun save(authorization: OAuth2Authorization?): Unit = runBlocking {
requireNotNull(authorization) requireNotNull(authorization)
transaction.transaction { 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) { if (singleOrNull == null) {
val authorizationCodeToken = authorization.getToken(OAuth2AuthorizationCode::class.java) val authorizationCodeToken = authorization.getToken(OAuth2AuthorizationCode::class.java)
val accessToken = authorization.getToken(OAuth2AccessToken::class.java) val accessToken = authorization.getToken(OAuth2AccessToken::class.java)
@ -139,7 +139,7 @@ class ExposedOAuth2AuthorizationService(
if (id == null) { if (id == null) {
return 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 { override fun findByToken(token: String?, tokenType: OAuth2TokenType?): OAuth2Authorization? = runBlocking {
@ -147,9 +147,7 @@ class ExposedOAuth2AuthorizationService(
transaction.transaction { transaction.transaction {
when (tokenType?.value) { when (tokenType?.value) {
null -> { null -> {
Authorization.select { Authorization.selectAll().where { Authorization.authorizationCodeValue eq token }.orWhere {
Authorization.authorizationCodeValue eq token
}.orWhere {
Authorization.accessTokenValue eq token Authorization.accessTokenValue eq token
}.orWhere { }.orWhere {
Authorization.oidcIdTokenValue eq token Authorization.oidcIdTokenValue eq token
@ -163,31 +161,31 @@ class ExposedOAuth2AuthorizationService(
} }
OAuth2ParameterNames.STATE -> { OAuth2ParameterNames.STATE -> {
Authorization.select { Authorization.state eq token } Authorization.selectAll().where { Authorization.state eq token }
} }
OAuth2ParameterNames.CODE -> { OAuth2ParameterNames.CODE -> {
Authorization.select { Authorization.authorizationCodeValue eq token } Authorization.selectAll().where { Authorization.authorizationCodeValue eq token }
} }
OAuth2ParameterNames.ACCESS_TOKEN -> { OAuth2ParameterNames.ACCESS_TOKEN -> {
Authorization.select { Authorization.accessTokenValue eq token } Authorization.selectAll().where { Authorization.accessTokenValue eq token }
} }
OidcParameterNames.ID_TOKEN -> { OidcParameterNames.ID_TOKEN -> {
Authorization.select { Authorization.oidcIdTokenValue eq token } Authorization.selectAll().where { Authorization.oidcIdTokenValue eq token }
} }
OAuth2ParameterNames.REFRESH_TOKEN -> { OAuth2ParameterNames.REFRESH_TOKEN -> {
Authorization.select { Authorization.refreshTokenValue eq token } Authorization.selectAll().where { Authorization.refreshTokenValue eq token }
} }
OAuth2ParameterNames.USER_CODE -> { OAuth2ParameterNames.USER_CODE -> {
Authorization.select { Authorization.userCodeValue eq token } Authorization.selectAll().where { Authorization.userCodeValue eq token }
} }
OAuth2ParameterNames.DEVICE_CODE -> { OAuth2ParameterNames.DEVICE_CODE -> {
Authorization.select { Authorization.deviceCodeValue eq token } Authorization.selectAll().where { Authorization.deviceCodeValue eq token }
} }
else -> { 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.clientSettings
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient.tokenSettings import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient.tokenSettings
import org.jetbrains.exposed.sql.* 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.CurrentTimestamp
import org.jetbrains.exposed.sql.javatime.timestamp import org.jetbrains.exposed.sql.javatime.timestamp
import org.slf4j.Logger import org.slf4j.Logger
@ -30,7 +31,8 @@ class RegisteredClientRepositoryImpl : RegisteredClientRepository {
override fun save(registeredClient: SpringRegisteredClient?) { override fun save(registeredClient: SpringRegisteredClient?) {
requireNotNull(registeredClient) 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) { if (singleOrNull == null) {
RegisteredClient.insert { RegisteredClient.insert {
it[id] = registeredClient.id it[id] = registeredClient.id
@ -71,9 +73,7 @@ class RegisteredClientRepositoryImpl : RegisteredClientRepository {
if (id == null) { if (id == null) {
return null return null
} }
return RegisteredClient.select { return RegisteredClient.selectAll().where { RegisteredClient.id eq id }.singleOrNull()?.toRegisteredClient()
RegisteredClient.id eq id
}.singleOrNull()?.toRegisteredClient()
} }
@Transactional @Transactional
@ -81,9 +81,9 @@ class RegisteredClientRepositoryImpl : RegisteredClientRepository {
if (clientId == null) { if (clientId == null) {
return null return null
} }
val toRegisteredClient = RegisteredClient.select { val toRegisteredClient =
RegisteredClient.clientId eq clientId RegisteredClient.selectAll().where { RegisteredClient.clientId eq clientId }.singleOrNull()
}.singleOrNull()?.toRegisteredClient() ?.toRegisteredClient()
LOGGER.trace("findByClientId: {}", toRegisteredClient) LOGGER.trace("findByClientId: {}", toRegisteredClient)
return 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.domain.mastodon.model.generated.Account
import dev.usbharu.hideout.mastodon.query.AccountQueryService import dev.usbharu.hideout.mastodon.query.AccountQueryService
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.springframework.stereotype.Repository import org.springframework.stereotype.Repository
import java.time.Instant import java.time.Instant
@Repository @Repository
class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) : AccountQueryService { class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) : AccountQueryService {
override suspend fun findById(accountId: Long): Account? { 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 return query
.singleOrNull() .singleOrNull()
@ -20,7 +20,7 @@ class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig)
} }
override suspend fun findByIds(accountIds: List<Long>): List<Account> { 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 return query
.map { toAccount(it) } .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 dev.usbharu.hideout.mastodon.query.StatusQueryService
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.andWhere import org.jetbrains.exposed.sql.andWhere
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.springframework.stereotype.Repository import org.springframework.stereotype.Repository
import java.time.Instant import java.time.Instant
import dev.usbharu.hideout.domain.mastodon.model.generated.CustomEmoji as MastodonEmoji import dev.usbharu.hideout.domain.mastodon.model.generated.CustomEmoji as MastodonEmoji
@ -34,14 +34,14 @@ class StatusQueryServiceImpl : StatusQueryService {
val postMap = Posts val postMap = Posts
.leftJoin(Actors) .leftJoin(Actors)
.select { Posts.id inList postIdSet } .selectAll().where { Posts.id inList postIdSet }
.associate { it[Posts.id] to toStatus(it) } .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 { .associate {
it[Media.id] to it.toMedia().toMediaAttachments() 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() it[CustomEmojis.id] to it.toCustomEmoji().toMastodonEmoji()
} }
return statusQueries.mapNotNull { statusQuery -> return statusQueries.mapNotNull { statusQuery ->
@ -69,7 +69,7 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(Actors) .leftJoin(Actors)
.leftJoin(Media) .leftJoin(Media)
.select { Posts.actorId eq accountId } .selectAll().where { Posts.actorId eq accountId }
if (onlyMedia) { if (onlyMedia) {
query.andWhere { PostsMedia.mediaId.isNotNull() } query.andWhere { PostsMedia.mediaId.isNotNull() }
@ -111,7 +111,7 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin(PostsMedia) .leftJoin(PostsMedia)
.leftJoin(Actors) .leftJoin(Actors)
.leftJoin(Media) .leftJoin(Media)
.select { Posts.id eq id } .selectAll().where { Posts.id eq id }
.groupBy { it[Posts.id] } .groupBy { it[Posts.id] }
.map { it.value } .map { it.value }
.map { .map {
@ -153,7 +153,7 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin(CustomEmojis) .leftJoin(CustomEmojis)
.leftJoin(Actors) .leftJoin(Actors)
.leftJoin(Media) .leftJoin(Media)
.select { Posts.id inList ids } .selectAll().where { Posts.id inList ids }
.groupBy { it[Posts.id] } .groupBy { it[Posts.id] }
.map { it.value } .map { it.value }
.map { .map {

View File

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

View File

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

View File

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