upgrade kotlin, ktor, sendgrid

This commit is contained in:
2021-01-18 17:13:24 +01:00
parent 4b435b925e
commit a79e1ec086
69 changed files with 152 additions and 117 deletions

View File

@@ -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
@@ -128,4 +128,4 @@ interface ArticleAuthI<U : CitizenI> :
CreatedBy<U>,
EntityDeletedAt {
val draft: Boolean
}
}

View File

@@ -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,
@@ -48,4 +49,4 @@ class ArticleRepository(override var requester: Requester) : RepositoryI {
val createdById: String? = null,
val workgroupId: String? = null
) : Parameter
}
}

View File

@@ -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
@@ -92,4 +96,4 @@ class ArticleViewManager(private val restClient: RestClient) : ViewManager<Artic
)
}
}
}
}

View File

@@ -33,10 +33,10 @@ class ArticleVoter(private val articleRepo: ArticleRepository) : Voter() {
/* The new Article must by created by the same citizen of the connected citizen */
if (subject.createdBy.id == citizen.id) {
/* The creator must be the same of the creator of preview version of article */
val lastVersionId = articleRepo
.findVersionsByVersionId(1, 1, subject.versionId)
.result
.firstOrNull()?.createdBy?.id
val lastVersionId = articleRepo
.findVersionsByVersionId(1, 1, subject.versionId)
.result
.firstOrNull()?.createdBy?.id
return when (lastVersionId) {
null -> granted("You can create a new Article")
@@ -46,4 +46,4 @@ class ArticleVoter(private val articleRepo: ArticleRepository) : Voter() {
}
return denied("This article must be yours for update it", "article.update.notYours")
}
}
}

View File

@@ -65,4 +65,4 @@ fun Route.getOneArticle(viewManager: ArticleViewManager, voter: ArticleVoter) {
viewManager.addView(call.request.local.remoteHost, it.article, citizenOrNull)
}
}
}
}