Lint project
This commit is contained in:
@@ -143,7 +143,7 @@ fun Application.module(env: Env = PROD) {
|
||||
|
||||
registerModule(JodaModule())
|
||||
disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
configure(SerializationFeature.INDENT_OUTPUT, true)
|
||||
setDefaultPrettyPrinter(DefaultPrettyPrinter().apply {
|
||||
indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance)
|
||||
|
||||
@@ -50,5 +50,4 @@ object JwtConfig {
|
||||
* Calculate the expiration Date based on current time + the given validity
|
||||
*/
|
||||
private fun getExpiration() = Date(System.currentTimeMillis() + validityInMs)
|
||||
|
||||
}
|
||||
@@ -50,6 +50,6 @@ val Module = module {
|
||||
|
||||
single { Migrations(connection = get(), directory = config.sqlFiles) }
|
||||
|
||||
single { Mailer(config.sendGridKey) }
|
||||
single { SsoManager(get<Mailer>(), config.domain, get()) }
|
||||
single { Mailer(config.sendGridKey) }
|
||||
single { SsoManager(get<Mailer>(), config.domain, get()) }
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class Article(
|
||||
var draft: Boolean = false,
|
||||
var lastVersion: Boolean = false,
|
||||
createdBy: Citizen?
|
||||
):
|
||||
) :
|
||||
UuidEntity(id),
|
||||
EntityVersioning<UUID, Int> by UuidEntityVersioning(),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package fr.dcproject.entity
|
||||
|
||||
import fr.postgresjson.entity.*
|
||||
import fr.postgresjson.entity.*
|
||||
import java.util.*
|
||||
|
||||
open class Comment <T: UuidEntity> (
|
||||
open class Comment <T : UuidEntity> (
|
||||
id: UUID = UUID.randomUUID(),
|
||||
createdBy: Citizen,
|
||||
target: T,
|
||||
@@ -12,7 +12,7 @@ open class Comment <T: UuidEntity> (
|
||||
var parent: Comment<T>? = null,
|
||||
var parentsIds: List<UUID>? = null,
|
||||
val childrenCount: Int? = null
|
||||
): Extra<T>(id, createdBy, target),
|
||||
) : Extra<T>(id, createdBy, target),
|
||||
EntityUpdatedAt by EntityUpdatedAtImp(),
|
||||
EntityDeletedAt by EntityDeletedAtImp(),
|
||||
Votable by VotableImp()
|
||||
|
||||
@@ -11,13 +11,13 @@ class Constitution(
|
||||
var draft: Boolean = false,
|
||||
var lastVersion: Boolean = false,
|
||||
createdBy: Citizen?
|
||||
): UuidEntity(id),
|
||||
) : UuidEntity(id),
|
||||
EntityVersioning<UUID, Int> by UuidEntityVersioning(),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityCreatedBy<Citizen> by EntityCreatedByImp(createdBy),
|
||||
EntityDeletedAt by EntityDeletedAtImp() {
|
||||
|
||||
init{
|
||||
init {
|
||||
titles.forEachIndexed { index, title ->
|
||||
title.createdBy = this.createdBy
|
||||
title.rank = index
|
||||
@@ -30,7 +30,7 @@ class Constitution(
|
||||
var rank: Int? = null,
|
||||
var articles: List<Article> = listOf(),
|
||||
createdBy: Citizen? = null
|
||||
): UuidEntity(id),
|
||||
) : UuidEntity(id),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityCreatedBy<Citizen> by EntityCreatedByImp(createdBy)
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@ package fr.dcproject.entity
|
||||
import fr.postgresjson.entity.*
|
||||
import java.util.*
|
||||
|
||||
interface ExtraI <T: EntityI>:
|
||||
interface ExtraI <T : EntityI> :
|
||||
EntityI,
|
||||
EntityCreatedAt,
|
||||
EntityCreatedBy<Citizen>{
|
||||
EntityCreatedBy<Citizen> {
|
||||
var target: T
|
||||
var targetReference: String
|
||||
}
|
||||
|
||||
abstract class Extra<T: UuidEntity>(
|
||||
abstract class Extra<T : UuidEntity>(
|
||||
id: UUID? = UUID.randomUUID(),
|
||||
createdBy: Citizen,
|
||||
override var target: T,
|
||||
override var targetReference: String = target::class.simpleName!!.toLowerCase()
|
||||
):
|
||||
) :
|
||||
ExtraI<T>,
|
||||
UuidEntity(id),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
|
||||
@@ -2,8 +2,8 @@ package fr.dcproject.entity
|
||||
import fr.postgresjson.entity.UuidEntity
|
||||
import java.util.*
|
||||
|
||||
class Follow <T: UuidEntity> (
|
||||
class Follow <T : UuidEntity> (
|
||||
id: UUID = UUID.randomUUID(),
|
||||
createdBy: Citizen,
|
||||
target: T
|
||||
): Extra<T>(id, createdBy, target)
|
||||
) : Extra<T>(id, createdBy, target)
|
||||
|
||||
@@ -14,7 +14,6 @@ class User(
|
||||
) : UuidEntity(id),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityUpdatedAt by EntityUpdatedAtImp(),
|
||||
Principal
|
||||
{
|
||||
Principal {
|
||||
enum class Roles { ROLE_USER, ROLE_ADMIN }
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ interface Votable {
|
||||
var votes: VoteAggregation
|
||||
}
|
||||
|
||||
class VotableImp: Votable {
|
||||
override var votes: VoteAggregation = VoteAggregation(0,0,0)
|
||||
class VotableImp : Votable {
|
||||
override var votes: VoteAggregation = VoteAggregation(0, 0, 0)
|
||||
}
|
||||
@@ -5,13 +5,13 @@ import fr.postgresjson.entity.EntityUpdatedAtImp
|
||||
import fr.postgresjson.entity.UuidEntity
|
||||
import java.util.*
|
||||
|
||||
open class Vote <T: UuidEntity> (
|
||||
open class Vote <T : UuidEntity> (
|
||||
id: UUID = UUID.randomUUID(),
|
||||
createdBy: Citizen,
|
||||
target: T,
|
||||
var note: Int,
|
||||
var anonymous: Boolean = true
|
||||
): Extra<T>(id, createdBy, target),
|
||||
) : Extra<T>(id, createdBy, target),
|
||||
EntityUpdatedAt by EntityUpdatedAtImp() {
|
||||
init {
|
||||
if (note > 1 && note < -1) {
|
||||
|
||||
@@ -4,9 +4,9 @@ import fr.postgresjson.entity.EntityI
|
||||
import fr.postgresjson.entity.EntityUpdatedAt
|
||||
import fr.postgresjson.entity.EntityUpdatedAtImp
|
||||
|
||||
open class VoteAggregation (
|
||||
open class VoteAggregation(
|
||||
val up: Int,
|
||||
val neutral: Int,
|
||||
val down: Int
|
||||
): EntityI,
|
||||
EntityUpdatedAt by EntityUpdatedAtImp()
|
||||
) : EntityI,
|
||||
EntityUpdatedAt by EntityUpdatedAtImp()
|
||||
|
||||
@@ -13,7 +13,7 @@ class Article(
|
||||
val tags: List<String> = emptyList(),
|
||||
val draft: Boolean = false,
|
||||
val versionId: UUID?
|
||||
):
|
||||
) :
|
||||
Request {
|
||||
|
||||
fun merge(article: ArticleEntity) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package fr.dcproject.entity.request
|
||||
|
||||
class Comment (
|
||||
class Comment(
|
||||
val content: String
|
||||
): Request
|
||||
) : Request
|
||||
@@ -6,7 +6,7 @@ import com.sendgrid.SendGrid
|
||||
import com.sendgrid.helpers.mail.Mail
|
||||
import java.io.IOException
|
||||
|
||||
class Mailer (
|
||||
class Mailer(
|
||||
private val key: String
|
||||
) {
|
||||
fun sendEmail(action: () -> Mail): Boolean {
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.ktor.http.URLBuilder
|
||||
import fr.dcproject.entity.Citizen as CitizenEntity
|
||||
import fr.dcproject.repository.Citizen as CitizenRepository
|
||||
|
||||
class SsoManager (
|
||||
class SsoManager(
|
||||
private val mailer: Mailer,
|
||||
private val domain: String,
|
||||
private val citizenRepo: CitizenRepository
|
||||
|
||||
@@ -10,7 +10,7 @@ import fr.dcproject.entity.Citizen as CitizenEntity
|
||||
import fr.dcproject.entity.Comment as CommentEntity
|
||||
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
||||
|
||||
abstract class Comment <T: UuidEntity>(override var requester: Requester): RepositoryI {
|
||||
abstract class Comment <T : UuidEntity>(override var requester: Requester) : RepositoryI {
|
||||
abstract fun findById(id: UUID): CommentEntity<T>?
|
||||
|
||||
abstract fun findByCitizen(
|
||||
@@ -81,7 +81,7 @@ abstract class Comment <T: UuidEntity>(override var requester: Requester): Repos
|
||||
}
|
||||
}
|
||||
|
||||
class CommentGeneric (requester: Requester): Comment<UuidEntity>(requester) {
|
||||
class CommentGeneric(requester: Requester) : Comment<UuidEntity>(requester) {
|
||||
override fun findById(id: UUID): CommentEntity<UuidEntity>? {
|
||||
return requester
|
||||
.getFunction("find_comment_by_id")
|
||||
@@ -102,7 +102,7 @@ class CommentGeneric (requester: Requester): Comment<UuidEntity>(requester) {
|
||||
}
|
||||
}
|
||||
|
||||
class CommentArticle (requester: Requester): Comment<ArticleEntity>(requester) {
|
||||
class CommentArticle(requester: Requester) : Comment<ArticleEntity>(requester) {
|
||||
override fun findById(id: UUID): CommentEntity<ArticleEntity>? {
|
||||
return requester
|
||||
.getFunction("find_comment_by_id")
|
||||
@@ -125,7 +125,7 @@ class CommentArticle (requester: Requester): Comment<ArticleEntity>(requester) {
|
||||
}
|
||||
}
|
||||
|
||||
class CommentConstitution (requester: Requester): Comment<ConstitutionEntity>(requester) {
|
||||
class CommentConstitution(requester: Requester) : Comment<ConstitutionEntity>(requester) {
|
||||
override fun findById(id: UUID): CommentEntity<ConstitutionEntity>? {
|
||||
return requester
|
||||
.getFunction("find_comment_by_id")
|
||||
|
||||
@@ -10,7 +10,7 @@ import fr.dcproject.entity.Citizen as CitizenEntity
|
||||
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
||||
import fr.dcproject.entity.Follow as FollowEntity
|
||||
|
||||
open class Follow <T: UuidEntity>(override var requester: Requester): RepositoryI {
|
||||
open class Follow <T : UuidEntity>(override var requester: Requester) : RepositoryI {
|
||||
open fun findByCitizen(
|
||||
citizen: CitizenEntity,
|
||||
page: Int = 1,
|
||||
@@ -54,7 +54,7 @@ open class Follow <T: UuidEntity>(override var requester: Requester): Repository
|
||||
}
|
||||
}
|
||||
|
||||
class FollowArticle (requester: Requester): Follow<ArticleEntity>(requester) {
|
||||
class FollowArticle(requester: Requester) : Follow<ArticleEntity>(requester) {
|
||||
override fun findByCitizen(
|
||||
citizenId: UUID,
|
||||
page: Int,
|
||||
@@ -69,7 +69,7 @@ class FollowArticle (requester: Requester): Follow<ArticleEntity>(requester) {
|
||||
}
|
||||
}
|
||||
|
||||
class FollowConstitution (requester: Requester): Follow<ConstitutionEntity>(requester) {
|
||||
class FollowConstitution(requester: Requester) : Follow<ConstitutionEntity>(requester) {
|
||||
override fun findByCitizen(
|
||||
citizenId: UUID,
|
||||
page: Int,
|
||||
|
||||
@@ -36,7 +36,7 @@ class User(override var requester: Requester) : RepositoryI {
|
||||
.sendQuery("resource" to user)
|
||||
}
|
||||
|
||||
class UserNotFound(override val message: String?, override val cause: Throwable?): Throwable(message, cause) {
|
||||
constructor(id: UUID): this("No User with ID $id", null)
|
||||
class UserNotFound(override val message: String?, override val cause: Throwable?) : Throwable(message, cause) {
|
||||
constructor(id: UUID) : this("No User with ID $id", null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.*
|
||||
import fr.dcproject.entity.Citizen as CitizenEntity
|
||||
import fr.dcproject.entity.Vote as VoteEntity
|
||||
|
||||
open class Vote <T: UuidEntity>(override var requester: Requester): RepositoryI {
|
||||
open class Vote <T : UuidEntity>(override var requester: Requester) : RepositoryI {
|
||||
fun vote(vote: VoteEntity<T>): VoteAggregation {
|
||||
val target = vote.target
|
||||
val reference = if (target is Comment<*>) {
|
||||
@@ -56,7 +56,7 @@ open class Vote <T: UuidEntity>(override var requester: Requester): RepositoryI
|
||||
citizen: CitizenEntity,
|
||||
targets: List<UUID>
|
||||
): List<VoteEntity<*>> {
|
||||
val typeReference = object: TypeReference<List<VoteEntity<UuidEntity>>>() {}
|
||||
val typeReference = object : TypeReference<List<VoteEntity<UuidEntity>>>() {}
|
||||
return requester.run {
|
||||
val citizenId = citizen.id ?: error("The citizen must have an id")
|
||||
getFunction("find_citizen_votes_by_target_ids")
|
||||
@@ -68,7 +68,7 @@ open class Vote <T: UuidEntity>(override var requester: Requester): RepositoryI
|
||||
}
|
||||
}
|
||||
|
||||
class VoteArticle (requester: Requester): Vote<Article>(requester) {
|
||||
class VoteArticle(requester: Requester) : Vote<Article>(requester) {
|
||||
fun findByCitizen(
|
||||
citizen: CitizenEntity,
|
||||
page: Int = 1,
|
||||
@@ -77,13 +77,13 @@ class VoteArticle (requester: Requester): Vote<Article>(requester) {
|
||||
findByCitizen(
|
||||
citizen.id ?: error("The citizen must have an id"),
|
||||
"article",
|
||||
object: TypeReference<List<VoteEntity<Article>>>() {},
|
||||
object : TypeReference<List<VoteEntity<Article>>>() {},
|
||||
page,
|
||||
limit
|
||||
)
|
||||
}
|
||||
|
||||
class VoteArticleComment (requester: Requester): Vote<Comment<Article>>(requester) {
|
||||
class VoteArticleComment(requester: Requester) : Vote<Comment<Article>>(requester) {
|
||||
fun findByCitizen(
|
||||
citizen: CitizenEntity,
|
||||
page: Int = 1,
|
||||
@@ -92,13 +92,13 @@ class VoteArticleComment (requester: Requester): Vote<Comment<Article>>(requeste
|
||||
findByCitizen(
|
||||
citizen.id ?: error("The citizen must have an id"),
|
||||
"article",
|
||||
object: TypeReference<List<VoteEntity<Comment<Article>>>>() {},
|
||||
object : TypeReference<List<VoteEntity<Comment<Article>>>>() {},
|
||||
page,
|
||||
limit
|
||||
)
|
||||
}
|
||||
|
||||
class VoteComment (requester: Requester): Vote<Comment<UuidEntity>>(requester) {
|
||||
class VoteComment(requester: Requester) : Vote<Comment<UuidEntity>>(requester) {
|
||||
fun findByCitizen(
|
||||
citizen: CitizenEntity,
|
||||
page: Int = 1,
|
||||
@@ -107,13 +107,13 @@ class VoteComment (requester: Requester): Vote<Comment<UuidEntity>>(requester) {
|
||||
findByCitizen(
|
||||
citizen.id ?: error("The citizen must have an id"),
|
||||
"article",
|
||||
object: TypeReference<List<VoteEntity<Comment<UuidEntity>>>>() {},
|
||||
object : TypeReference<List<VoteEntity<Comment<UuidEntity>>>>() {},
|
||||
page,
|
||||
limit
|
||||
)
|
||||
}
|
||||
|
||||
class VoteConstitution (requester: Requester): Vote<Constitution>(requester) {
|
||||
class VoteConstitution(requester: Requester) : Vote<Constitution>(requester) {
|
||||
fun findByCitizen(
|
||||
citizen: CitizenEntity,
|
||||
page: Int = 1,
|
||||
@@ -122,7 +122,7 @@ class VoteConstitution (requester: Requester): Vote<Constitution>(requester) {
|
||||
findByCitizen(
|
||||
citizen.id ?: error("The citizen must have an id"),
|
||||
"constitution",
|
||||
object: TypeReference<List<VoteEntity<Constitution>>>() {},
|
||||
object : TypeReference<List<VoteEntity<Constitution>>>() {},
|
||||
page,
|
||||
limit
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ fun Route.comment(repo: CommentRepository) {
|
||||
|
||||
put<CommentPaths.CommentRequest> {
|
||||
val comment = repo.findById(it.comment)!!
|
||||
assertCan(UPDATE,comment)
|
||||
assertCan(UPDATE, comment)
|
||||
|
||||
comment.content = call.receiveText()
|
||||
repo.edit(comment)
|
||||
|
||||
@@ -8,7 +8,7 @@ interface PaginatedRequestI {
|
||||
open class PaginatedRequest(
|
||||
page: Int = 1,
|
||||
limit: Int = 50
|
||||
): PaginatedRequestI {
|
||||
) : PaginatedRequestI {
|
||||
override val page: Int = if (page < 1) 1 else page
|
||||
override val limit: Int = if (limit > 50) 50 else if (limit < 1) 1 else limit
|
||||
}
|
||||
@@ -41,7 +41,7 @@ object VoteArticlePaths {
|
||||
page: Int = 1,
|
||||
limit: Int = 50,
|
||||
val search: String? = null
|
||||
): PaginatedRequestI by PaginatedRequest(page, limit)
|
||||
) : PaginatedRequestI by PaginatedRequest(page, limit)
|
||||
|
||||
@Location("/citizens/{citizen}/votes")
|
||||
class CitizenVotesByIdsRequest(val citizen: Citizen, id: List<String>) {
|
||||
|
||||
@@ -6,8 +6,8 @@ import fr.dcproject.entity.Article as ArticleEntity
|
||||
import fr.dcproject.entity.Comment as CommentEntity
|
||||
import fr.dcproject.entity.Vote as VoteEntity
|
||||
|
||||
class ArticleVoter: Voter {
|
||||
enum class Action: ActionI {
|
||||
class ArticleVoter : Voter {
|
||||
enum class Action : ActionI {
|
||||
CREATE,
|
||||
UPDATE,
|
||||
VIEW,
|
||||
@@ -16,8 +16,7 @@ class ArticleVoter: Voter {
|
||||
|
||||
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
|
||||
return (action is Action || action is CommentVoter.Action || action is VoteVoter.Action)
|
||||
&&
|
||||
(subject is List<*> || subject is ArticleEntity? || subject is VoteEntity<*> || subject is CommentEntity<*>)
|
||||
.and(subject is List<*> || subject is ArticleEntity? || subject is VoteEntity<*> || subject is CommentEntity<*>)
|
||||
}
|
||||
|
||||
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
|
||||
|
||||
@@ -6,8 +6,8 @@ import io.ktor.application.ApplicationCall
|
||||
import io.ktor.locations.KtorExperimentalLocationsAPI
|
||||
|
||||
@KtorExperimentalLocationsAPI
|
||||
class CitizenVoter: Voter {
|
||||
enum class Action: ActionI {
|
||||
class CitizenVoter : Voter {
|
||||
enum class Action : ActionI {
|
||||
CREATE,
|
||||
UPDATE,
|
||||
VIEW,
|
||||
@@ -17,10 +17,7 @@ class CitizenVoter: Voter {
|
||||
|
||||
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
|
||||
return (action is Action)
|
||||
&& (
|
||||
subject is List<*> ||
|
||||
subject is Citizen?
|
||||
)
|
||||
.and(subject is List<*> || subject is Citizen?)
|
||||
}
|
||||
|
||||
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
|
||||
|
||||
@@ -3,8 +3,8 @@ package fr.dcproject.security.voter
|
||||
import fr.dcproject.entity.Comment
|
||||
import io.ktor.application.ApplicationCall
|
||||
|
||||
class CommentVoter: Voter {
|
||||
enum class Action: ActionI {
|
||||
class CommentVoter : Voter {
|
||||
enum class Action : ActionI {
|
||||
CREATE,
|
||||
UPDATE,
|
||||
VIEW,
|
||||
@@ -12,8 +12,8 @@ class CommentVoter: Voter {
|
||||
}
|
||||
|
||||
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
|
||||
return (action is Action) &&
|
||||
(subject is Comment<*>? || subject is List<*>)
|
||||
return (action is Action)
|
||||
.and(subject is Comment<*>? || subject is List<*>)
|
||||
}
|
||||
|
||||
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
|
||||
|
||||
@@ -6,8 +6,8 @@ import io.ktor.application.ApplicationCall
|
||||
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
||||
import fr.dcproject.entity.Vote as VoteEntity
|
||||
|
||||
class ConstitutionVoter: Voter {
|
||||
enum class Action: ActionI {
|
||||
class ConstitutionVoter : Voter {
|
||||
enum class Action : ActionI {
|
||||
CREATE,
|
||||
UPDATE,
|
||||
VIEW,
|
||||
@@ -16,8 +16,7 @@ class ConstitutionVoter: Voter {
|
||||
|
||||
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
|
||||
return (action is Action || action is CommentVoter.Action || action is VoteVoter.Action)
|
||||
&&
|
||||
(subject is List<*> || subject is ConstitutionEntity? || subject is VoteEntity<*> || subject is Comment<*>)
|
||||
.and(subject is List<*> || subject is ConstitutionEntity? || subject is VoteEntity<*> || subject is Comment<*>)
|
||||
}
|
||||
|
||||
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
|
||||
|
||||
@@ -4,16 +4,16 @@ import io.ktor.application.ApplicationCall
|
||||
import fr.dcproject.entity.Follow as FollowEntity
|
||||
import fr.dcproject.entity.User as UserEntity
|
||||
|
||||
class FollowVoter: Voter {
|
||||
enum class Action: ActionI {
|
||||
class FollowVoter : Voter {
|
||||
enum class Action : ActionI {
|
||||
CREATE,
|
||||
DELETE,
|
||||
VIEW
|
||||
}
|
||||
|
||||
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
|
||||
return (action is Action) &&
|
||||
(subject is List<*> || subject is FollowEntity<*>?)
|
||||
return (action is Action)
|
||||
.and(subject is List<*> || subject is FollowEntity<*>?)
|
||||
}
|
||||
|
||||
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
|
||||
|
||||
@@ -3,16 +3,16 @@ package fr.dcproject.security.voter
|
||||
import io.ktor.application.ApplicationCall
|
||||
import fr.dcproject.entity.Vote as VoteEntity
|
||||
|
||||
class VoteVoter: Voter {
|
||||
enum class Action: ActionI {
|
||||
class VoteVoter : Voter {
|
||||
enum class Action : ActionI {
|
||||
CREATE,
|
||||
VIEW
|
||||
}
|
||||
|
||||
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
|
||||
return action is Action && (
|
||||
subject is VoteEntity<*>?
|
||||
|| subject is List<*>
|
||||
subject is VoteEntity<*>? ||
|
||||
subject is List<*>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ import org.slf4j.LoggerFactory
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
internal class LoggerDelegate<in R: Any>: ReadOnlyProperty<R, Logger> {
|
||||
internal class LoggerDelegate<in R : Any> : ReadOnlyProperty<R, Logger> {
|
||||
override fun getValue(thisRef: R, property: KProperty<*>) = LoggerFactory.getLogger(thisRef.javaClass.packageName)
|
||||
}
|
||||
Reference in New Issue
Block a user