mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Refresh item after addon is done
This commit is contained in:
@ -14,6 +14,8 @@ import docspell.pubsub.api.PubSubT
|
||||
import docspell.restserver.ws.OutputEvent
|
||||
import docspell.scheduler.msg.{JobDone, JobSubmitted}
|
||||
|
||||
import io.circe.parser
|
||||
|
||||
/** Subscribes to those events from docspell that are forwarded to the websocket endpoints
|
||||
*/
|
||||
object Subscriptions {
|
||||
@ -27,7 +29,14 @@ object Subscriptions {
|
||||
def jobDone[F[_]](pubSub: PubSubT[F]): Stream[F, OutputEvent] =
|
||||
pubSub
|
||||
.subscribe(JobDone.topic)
|
||||
.map(m => OutputEvent.JobDone(m.body.group, m.body.task))
|
||||
.map(m =>
|
||||
OutputEvent.JobDone(
|
||||
m.body.group,
|
||||
m.body.task,
|
||||
parser.parse(m.body.args).toOption,
|
||||
m.body.result
|
||||
)
|
||||
)
|
||||
|
||||
def jobSubmitted[F[_]](pubSub: PubSubT[F]): Stream[F, OutputEvent] =
|
||||
pubSub
|
||||
|
@ -40,12 +40,20 @@ object OutputEvent {
|
||||
Msg("job-submitted", task).asJson
|
||||
}
|
||||
|
||||
final case class JobDone(group: Ident, task: Ident) extends OutputEvent {
|
||||
final case class JobDone(
|
||||
group: Ident,
|
||||
task: Ident,
|
||||
args: Option[Json],
|
||||
result: Option[Json]
|
||||
) extends OutputEvent {
|
||||
def forCollective(token: AuthToken): Boolean =
|
||||
token.account.collective == group
|
||||
|
||||
def asJson: Json =
|
||||
Msg("job-done", task).asJson
|
||||
Msg(
|
||||
"job-done",
|
||||
Map("task" -> task.asJson, "args" -> args.asJson, "result" -> result.asJson)
|
||||
).asJson
|
||||
}
|
||||
|
||||
final case class JobsWaiting(collective: Ident, count: Int) extends OutputEvent {
|
||||
|
Reference in New Issue
Block a user