Move Notifications config from Application.kt to ConfigNotification.kt

This commit is contained in:
2020-03-03 12:23:42 +01:00
parent 0421f3cb55
commit 4a4e9651fd
7 changed files with 126 additions and 117 deletions

View File

@@ -2,7 +2,6 @@ package fr.dcproject.routes
import fr.dcproject.citizen
import fr.dcproject.event.ArticleUpdate
import fr.dcproject.event.EntityEvent
import fr.dcproject.repository.Article.Filter
import fr.dcproject.security.voter.ArticleVoter.Action.CREATE
import fr.dcproject.security.voter.ArticleVoter.Action.VIEW
@@ -86,7 +85,7 @@ fun Route.article(repo: ArticleRepository) {
assertCan(CREATE, article)
repo.upsert(article)
application.environment.monitor.raise(EntityEvent.Type.UPDATE_ARTICLE.event, ArticleUpdate(article))
application.environment.monitor.raise(ArticleUpdate.event, ArticleUpdate(article))
call.respond(article)
}

View File

@@ -1,7 +1,7 @@
package fr.dcproject.routes
import fr.dcproject.citizen
import fr.dcproject.event.Notification
import fr.dcproject.event.Event
import fr.postgresjson.serializer.deserialize
import io.ktor.client.HttpClient
import io.ktor.http.cio.websocket.Frame
@@ -26,7 +26,7 @@ fun Route.notificationArticle(redis: RedisAsyncCommands<String, String>, client:
launch {
incoming.consumeAsFlow().mapNotNull { it as? Frame.Text }.collect {
val notificationMessage = it.readText().deserialize<Notification>() ?: error("unable to deserialize message")
val notificationMessage = it.readText().deserialize<Event>() ?: error("unable to deserialize message")
redis.zremrangebyscore(
"notification:$citizenId",