mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Fix websocket frame to user mapping
This commit is contained in:
@ -7,11 +7,10 @@
|
||||
package docspell.restserver.conv
|
||||
|
||||
import cats.syntax.all._
|
||||
|
||||
import docspell.addons.AddonMeta
|
||||
import docspell.backend.ops.AddonValidationError
|
||||
import docspell.backend.ops.OAddons.AddonValidationResult
|
||||
import docspell.common.Ident
|
||||
import docspell.common.CollectiveId
|
||||
import docspell.restserver.ws.{OutputEvent, OutputEventEncoder}
|
||||
import docspell.store.records.RAddonArchive
|
||||
|
||||
@ -51,7 +50,7 @@ trait AddonValidationSupport {
|
||||
}
|
||||
|
||||
def addonResultOutputEventEncoder(
|
||||
collective: Ident
|
||||
collective: CollectiveId
|
||||
): OutputEventEncoder[AddonValidationResult[(RAddonArchive, AddonMeta)]] =
|
||||
OutputEventEncoder.instance {
|
||||
case Right((archive, _)) =>
|
||||
|
@ -34,7 +34,7 @@ object AddonArchiveRoutes extends AddonValidationSupport {
|
||||
): HttpRoutes[F] = {
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
implicit val wsOutputEnc = addonResultOutputEventEncoder(token.account.collective)
|
||||
implicit val wsOutputEnc = addonResultOutputEventEncoder(token.account.collectiveId)
|
||||
|
||||
HttpRoutes.of {
|
||||
case GET -> Root =>
|
||||
|
@ -34,7 +34,7 @@ object OutputEvent {
|
||||
|
||||
final case class JobSubmitted(group: Ident, task: Ident) extends OutputEvent {
|
||||
def forCollective(token: AuthToken): Boolean =
|
||||
token.account.collective == group
|
||||
token.account.collectiveId.valueAsIdent == group
|
||||
|
||||
def asJson: Json =
|
||||
Msg("job-submitted", task).asJson
|
||||
@ -47,7 +47,7 @@ object OutputEvent {
|
||||
result: Option[Json]
|
||||
) extends OutputEvent {
|
||||
def forCollective(token: AuthToken): Boolean =
|
||||
token.account.collective == group
|
||||
token.account.collectiveId.valueAsIdent == group
|
||||
|
||||
def asJson: Json =
|
||||
Msg(
|
||||
@ -56,23 +56,23 @@ object OutputEvent {
|
||||
).asJson
|
||||
}
|
||||
|
||||
final case class JobsWaiting(collective: Ident, count: Int) extends OutputEvent {
|
||||
final case class JobsWaiting(collective: CollectiveId, count: Int) extends OutputEvent {
|
||||
def forCollective(token: AuthToken): Boolean =
|
||||
token.account.collective == collective
|
||||
token.account.collectiveId == collective
|
||||
|
||||
def asJson: Json =
|
||||
Msg("jobs-waiting", count).asJson
|
||||
}
|
||||
|
||||
final case class AddonInstalled(
|
||||
collective: Ident,
|
||||
collective: CollectiveId,
|
||||
message: String,
|
||||
error: Option[AddonValidationError],
|
||||
addonId: Option[Ident],
|
||||
originalUrl: Option[LenientUri]
|
||||
) extends OutputEvent {
|
||||
def forCollective(token: AuthToken) =
|
||||
token.account.collective == collective
|
||||
token.account.collectiveId == collective
|
||||
|
||||
override def asJson =
|
||||
Msg(
|
||||
|
@ -34,7 +34,7 @@ object WebSocketRoutes {
|
||||
val init =
|
||||
for {
|
||||
jc <- backend.job.getUnfinishedJobCount(UserTaskScope(user.account))
|
||||
msg = OutputEvent.JobsWaiting(user.account.collective, jc)
|
||||
msg = OutputEvent.JobsWaiting(user.account.collectiveId, jc)
|
||||
} yield Text(msg.encode)
|
||||
|
||||
val toClient: Stream[F, WebSocketFrame.Text] =
|
||||
|
Reference in New Issue
Block a user