upgrade kotlin, ktor, sendgrid
This commit is contained in:
@@ -26,7 +26,8 @@ plugins {
|
||||
maven
|
||||
|
||||
id("maven-publish")
|
||||
id("org.jetbrains.kotlin.jvm") version "1.3.50"
|
||||
kotlin("jvm") version "1.4.21"
|
||||
kotlin("plugin.serialization") version "1.4.21"
|
||||
|
||||
id("com.github.johnrengelman.shadow") version "5.2.0"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "8.2.0"
|
||||
@@ -123,6 +124,7 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$coroutinesVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
|
||||
implementation("io.ktor:ktor-server-jetty:$ktor_version")
|
||||
implementation("io.ktor:ktor-client-jetty:$ktor_version")
|
||||
implementation("ch.qos.logback:logback-classic:$logback_version")
|
||||
@@ -139,7 +141,7 @@ dependencies {
|
||||
implementation("com.auth0:java-jwt:3.12.0")
|
||||
implementation("com.github.jasync-sql:jasync-postgresql:1.1.6")
|
||||
implementation("com.github.flecomte:postgres-json:2.0.0")
|
||||
implementation("com.sendgrid:sendgrid-java:4.4.1")
|
||||
implementation("com.sendgrid:sendgrid-java:4.7.1")
|
||||
implementation("io.lettuce:lettuce-core:5.3.6.RELEASE") // TODO update to 6.0.2
|
||||
implementation("com.rabbitmq:amqp-client:5.10.0")
|
||||
implementation("org.elasticsearch.client:elasticsearch-rest-client:6.7.1")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
ktor_version=1.2.2
|
||||
ktor_version=1.5.0
|
||||
kotlin.code.style=official
|
||||
kotlin_version=1.3.40
|
||||
kotlin_version=1.4.21-2
|
||||
coroutinesVersion=1.4.2
|
||||
logback_version=1.2.3
|
||||
koinVersion=2.0.1
|
||||
|
||||
@@ -49,6 +49,7 @@ import io.ktor.client.*
|
||||
import io.ktor.client.engine.jetty.Jetty
|
||||
import io.ktor.features.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.http.cio.websocket.*
|
||||
import io.ktor.jackson.*
|
||||
import io.ktor.locations.*
|
||||
import io.ktor.response.*
|
||||
@@ -117,10 +118,12 @@ fun Application.module(env: Env = PROD) {
|
||||
disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
configure(SerializationFeature.INDENT_OUTPUT, true)
|
||||
setDefaultPrettyPrinter(DefaultPrettyPrinter().apply {
|
||||
setDefaultPrettyPrinter(
|
||||
DefaultPrettyPrinter().apply {
|
||||
indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance)
|
||||
indentObjectsWith(DefaultIndenter(" ", "\n"))
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package fr.dcproject.component.article
|
||||
|
||||
import fr.dcproject.component.citizen.*
|
||||
import fr.dcproject.component.workgroup.WorkgroupCart
|
||||
import fr.dcproject.component.workgroup.WorkgroupCartI
|
||||
import fr.dcproject.component.workgroup.WorkgroupRef
|
||||
import fr.dcproject.component.workgroup.WorkgroupSimple
|
||||
import fr.dcproject.component.citizen.*
|
||||
import fr.dcproject.entity.*
|
||||
import fr.postgresjson.entity.*
|
||||
import org.joda.time.DateTime
|
||||
|
||||
@@ -30,7 +30,8 @@ class ArticleRepository(override var requester: Requester) : RepositoryI {
|
||||
return requester
|
||||
.getFunction("find_articles")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"sort" to sort?.toSnakeCase(),
|
||||
"direction" to direction,
|
||||
"search" to search,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package fr.dcproject.component.article
|
||||
|
||||
import fr.dcproject.component.citizen.CitizenI
|
||||
import fr.dcproject.component.views.ViewManager
|
||||
import fr.dcproject.entity.ViewAggregation
|
||||
import fr.dcproject.utils.contentToString
|
||||
import fr.dcproject.utils.getJsonField
|
||||
import fr.dcproject.utils.toIso
|
||||
import fr.dcproject.component.views.ViewManager
|
||||
import org.elasticsearch.client.Request
|
||||
import org.elasticsearch.client.Response
|
||||
import org.elasticsearch.client.RestClient
|
||||
@@ -27,7 +27,8 @@ class ArticleViewManager(private val restClient: RestClient) : ViewManager<Artic
|
||||
"/views/_doc/"
|
||||
).apply {
|
||||
//language=JSON
|
||||
setJsonEntity("""
|
||||
setJsonEntity(
|
||||
"""
|
||||
{
|
||||
"logged": $isLogged,
|
||||
"type": "article",
|
||||
@@ -38,7 +39,8 @@ class ArticleViewManager(private val restClient: RestClient) : ViewManager<Artic
|
||||
"citizen_id": "${citizen?.id}",
|
||||
"view_at": "${dateTime.toIso()}"
|
||||
}
|
||||
""".trimIndent())
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
return restClient.performRequest(request)
|
||||
@@ -53,7 +55,8 @@ class ArticleViewManager(private val restClient: RestClient) : ViewManager<Artic
|
||||
"/views/_search"
|
||||
).apply {
|
||||
//language=JSON
|
||||
setJsonEntity("""
|
||||
setJsonEntity(
|
||||
"""
|
||||
{
|
||||
"size": 0,
|
||||
"query": {
|
||||
@@ -81,7 +84,8 @@ class ArticleViewManager(private val restClient: RestClient) : ViewManager<Artic
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
return restClient
|
||||
|
||||
@@ -12,7 +12,8 @@ class User(
|
||||
blockedAt: DateTime? = null,
|
||||
override var plainPassword: String? = null,
|
||||
override var roles: List<Roles> = emptyList()
|
||||
) : UserFull, UserBasic(id, username, blockedAt),
|
||||
) : UserFull,
|
||||
UserBasic(id, username, blockedAt),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityUpdatedAt by EntityUpdatedAtImp()
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ class CitizenRepository(override var requester: Requester) : RepositoryI {
|
||||
): Paginated<CitizenBasic> = requester
|
||||
.getFunction("find_citizens")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"sort" to sort?.toSnakeCase(),
|
||||
"direction" to direction,
|
||||
"search" to search
|
||||
|
||||
@@ -27,7 +27,8 @@ class CommentArticleRepository(requester: Requester) : CommentRepositoryAbs<Arti
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_citizen")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"created_by_id" to citizen.id,
|
||||
"reference" to TargetI.getReference(ArticleRef::class)
|
||||
)
|
||||
@@ -42,7 +43,8 @@ class CommentArticleRepository(requester: Requester) : CommentRepositoryAbs<Arti
|
||||
): Paginated<CommentForView<ArticleForView, CitizenRef>> = requester
|
||||
.getFunction("find_comments_by_target")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"target_id" to target.id,
|
||||
"sort" to sort.sql
|
||||
)
|
||||
|
||||
@@ -36,7 +36,8 @@ abstract class CommentRepositoryAbs<T : TargetI>(override var requester: Request
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_parent")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"parent_id" to parentId
|
||||
)
|
||||
}
|
||||
@@ -60,7 +61,8 @@ abstract class CommentRepositoryAbs<T : TargetI>(override var requester: Request
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_target")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"target_id" to targetId,
|
||||
"sort" to sort.sql
|
||||
)
|
||||
@@ -101,7 +103,8 @@ class CommentRepository(requester: Requester) : CommentRepositoryAbs<TargetRef>(
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_citizen")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"created_by_id" to citizen.id
|
||||
)
|
||||
}
|
||||
@@ -115,7 +118,8 @@ class CommentRepository(requester: Requester) : CommentRepositoryAbs<TargetRef>(
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_parent")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"parent_id" to parentId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ class WorkgroupRepository(override var requester: Requester) : RepositoryI {
|
||||
return requester
|
||||
.getFunction("find_workgroups")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"sort" to sort?.toSnakeCase(),
|
||||
"direction" to direction,
|
||||
"search" to search,
|
||||
|
||||
@@ -32,7 +32,12 @@ object GetWorkgroups {
|
||||
fun Route.getWorkgroups(repo: WorkgroupRepository, voter: WorkgroupVoter) {
|
||||
get<WorkgroupsRequest> {
|
||||
val workgroups =
|
||||
repo.find(it.page, it.limit, it.sort, it.direction, it.search,
|
||||
repo.find(
|
||||
it.page,
|
||||
it.limit,
|
||||
it.sort,
|
||||
it.direction,
|
||||
it.search,
|
||||
WorkgroupRepository.Filter(createdById = it.createdBy, members = it.members)
|
||||
)
|
||||
voter.assert { canView(workgroups.result, citizenOrNull) }
|
||||
|
||||
@@ -13,12 +13,12 @@ import fr.dcproject.repository.Follow
|
||||
import fr.postgresjson.serializer.deserialize
|
||||
import io.ktor.application.*
|
||||
import io.ktor.util.pipeline.*
|
||||
import io.ktor.utils.io.errors.*
|
||||
import io.lettuce.core.api.async.RedisAsyncCommands
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.io.errors.IOException
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import fr.dcproject.repository.FollowArticle as FollowArticleRepository
|
||||
|
||||
@@ -27,7 +27,8 @@ class CommentConstitutionRepository(requester: Requester) : CommentRepositoryAbs
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_citizen")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"created_by_id" to citizen.id,
|
||||
"reference" to TargetI.getReference(ConstitutionRef::class)
|
||||
)
|
||||
@@ -43,7 +44,8 @@ class CommentConstitutionRepository(requester: Requester) : CommentRepositoryAbs
|
||||
return requester.run {
|
||||
getFunction("find_comments_by_target")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"target_id" to target.id,
|
||||
"sort" to sort.sql
|
||||
)
|
||||
|
||||
@@ -27,7 +27,8 @@ class Constitution(override var requester: Requester) : RepositoryI {
|
||||
return requester
|
||||
.getFunction("find_constitutions")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"sort" to sort?.toSnakeCase(),
|
||||
"direction" to direction,
|
||||
"search" to search
|
||||
|
||||
@@ -34,7 +34,8 @@ sealed class Follow<IN : TargetRef, OUT : TargetRef>(override var requester: Req
|
||||
return requester
|
||||
.getFunction("find_follows_by_citizen")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
@@ -101,7 +102,8 @@ class FollowArticle(requester: Requester) : Follow<ArticleRef, ArticleForView>(r
|
||||
return requester.run {
|
||||
getFunction("find_follows_article_by_citizen")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
@@ -115,7 +117,8 @@ class FollowArticle(requester: Requester) : Follow<ArticleRef, ArticleForView>(r
|
||||
return requester
|
||||
.getFunction("find_follows_article_by_target")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"target_id" to target.id
|
||||
)
|
||||
}
|
||||
@@ -130,7 +133,8 @@ class FollowConstitution(requester: Requester) : Follow<ConstitutionRef, Constit
|
||||
return requester.run {
|
||||
getFunction("find_follows_constitution_by_citizen")
|
||||
.select(
|
||||
page, limit,
|
||||
page,
|
||||
limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,8 @@ abstract class Opinion<T : TargetRef>(requester: Requester) : OpinionChoice(requ
|
||||
return requester.run {
|
||||
getFunction("find_citizen_opinions_by_target_ids")
|
||||
.select(
|
||||
typeReference, mapOf(
|
||||
typeReference,
|
||||
mapOf(
|
||||
"citizen_id" to citizen.id,
|
||||
"ids" to targets
|
||||
)
|
||||
@@ -101,7 +102,8 @@ abstract class Opinion<T : TargetRef>(requester: Requester) : OpinionChoice(requ
|
||||
return requester
|
||||
.getFunction("find_citizen_opinions_by_target_id")
|
||||
.select(
|
||||
typeReference, mapOf(
|
||||
typeReference,
|
||||
mapOf(
|
||||
"citizen_id" to citizen.id,
|
||||
"id" to target
|
||||
)
|
||||
@@ -121,7 +123,9 @@ abstract class Opinion<T : TargetRef>(requester: Requester) : OpinionChoice(requ
|
||||
): Paginated<OpinionEntity<TargetRef>> {
|
||||
return requester
|
||||
.getFunction("find_citizen_opinions")
|
||||
.select(page, limit,
|
||||
.select(
|
||||
page,
|
||||
limit,
|
||||
"sort" to sort?.toSnakeCase(),
|
||||
"direction" to direction,
|
||||
"citizen_id" to citizen.id
|
||||
|
||||
@@ -37,7 +37,10 @@ open class Vote<T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
return requester.run {
|
||||
getFunction("find_votes_by_citizen")
|
||||
.select(
|
||||
page, limit, typeReference, mapOf(
|
||||
page,
|
||||
limit,
|
||||
typeReference,
|
||||
mapOf(
|
||||
"created_by_id" to citizenId,
|
||||
"reference" to target
|
||||
)
|
||||
@@ -53,7 +56,8 @@ open class Vote<T : TargetI>(override var requester: Requester) : RepositoryI {
|
||||
return requester.run {
|
||||
getFunction("find_citizen_votes_by_target_ids")
|
||||
.select(
|
||||
typeReference, mapOf(
|
||||
typeReference,
|
||||
mapOf(
|
||||
"citizen_id" to citizen.id,
|
||||
"ids" to targets
|
||||
)
|
||||
|
||||
@@ -60,7 +60,10 @@ object ConstitutionPaths {
|
||||
) : UuidEntity(id) {
|
||||
fun create(): TitleSimple<ArticleRef> =
|
||||
TitleSimple(
|
||||
id, name, rank, articles
|
||||
id,
|
||||
name,
|
||||
rank,
|
||||
articles
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package steps
|
||||
|
||||
import io.ktor.application.*
|
||||
import io.ktor.server.engine.*
|
||||
import io.ktor.server.testing.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.test.fail
|
||||
|
||||
@@ -6,11 +6,9 @@ import io.cucumber.java8.En
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.testing.*
|
||||
import io.ktor.util.*
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotEquals
|
||||
|
||||
@ImplicitReflectionSerializer
|
||||
@KtorExperimentalAPI
|
||||
class KtorServerRequestSteps : En {
|
||||
init {
|
||||
|
||||
@@ -2,17 +2,11 @@ package steps
|
||||
|
||||
import io.cucumber.datatable.DataTable
|
||||
import io.cucumber.java8.En
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
import kotlinx.serialization.parse
|
||||
import kotlinx.serialization.json.*
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
@ImplicitReflectionSerializer
|
||||
class KtorServerRestSteps : En {
|
||||
init {
|
||||
Then("the JSON should contain:") { dataTable: DataTable ->
|
||||
@@ -60,7 +54,7 @@ class KtorServerRestSteps : En {
|
||||
}
|
||||
|
||||
private val responseJsonElement: JsonElement
|
||||
get() = Json.parse(KtorServerContext.defaultServer.call?.response?.content ?: fail("The response isn't valid JSON"))
|
||||
get() = Json.parseToJsonElement(KtorServerContext.defaultServer.call?.response?.content ?: fail("The response isn't valid JSON"))
|
||||
|
||||
private val response: String
|
||||
get() = KtorServerContext.defaultServer.call?.response?.content ?: fail("The response isn't valid")
|
||||
|
||||
Reference in New Issue
Block a user