Skip to content

Commit

Permalink
#1410 Add waitingTask query
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 2, 2020
1 parent 002907f commit ee2cd7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.thp.scalligraph.steps.PagedResult
import org.thp.scalligraph.steps.StepsOps._
import org.thp.thehive.controllers.v1.Conversion._
import org.thp.thehive.dto.v1.InputTask
import org.thp.thehive.models.{Permissions, RichTask}
import org.thp.thehive.models.{Permissions, RichTask, TaskStatus}
import org.thp.thehive.services.{CaseSrv, CaseSteps, LogSteps, OrganisationSrv, OrganisationSteps, ShareSrv, TaskSrv, TaskSteps, UserSteps}
import play.api.libs.json.JsObject
import play.api.mvc.{Action, AnyContent, Results}
Expand Down Expand Up @@ -46,6 +46,10 @@ class TaskCtrl @Inject() (
)
override val outputQuery: Query = Query.output[RichTask, TaskSteps](_.richTask)
override val extraQueries: Seq[ParamQuery[_]] = Seq(
Query.init[TaskSteps](
"waitingTask",
(graph, authContext) => taskSrv.initSteps(graph).has("status", TaskStatus.Waiting).unassigned.visible(authContext)
),
Query[TaskSteps, UserSteps]("assignableUsers", (taskSteps, authContext) => taskSteps.assignableUsers(authContext)),
Query[TaskSteps, LogSteps]("logs", (taskSteps, _) => taskSteps.logs),
Query[TaskSteps, CaseSteps]("case", (taskSteps, _) => taskSteps.`case`),
Expand Down
8 changes: 5 additions & 3 deletions thehive/app/org/thp/thehive/services/TaskSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,19 @@ class TaskSteps(raw: GremlinScala[Vertex])(implicit db: Database, graph: Graph)
)
)

def `case` = new CaseSteps(raw.inTo[ShareTask].outTo[ShareCase].dedup)
def `case`: CaseSteps = new CaseSteps(raw.inTo[ShareTask].outTo[ShareCase].dedup)

def caseTemplate = new CaseTemplateSteps(raw.inTo[CaseTemplateTask])

def caseTasks: TaskSteps = this.filter(_.inToE[ShareTask])

def caseTemplateTasks: TaskSteps = this.filter(_.inToE[CaseTemplateTask])

def logs = new LogSteps(raw.outTo[TaskLog])
def logs: LogSteps = new LogSteps(raw.outTo[TaskLog])

def assignee = new UserSteps(raw.outTo[TaskUser])
def assignee: UserSteps = new UserSteps(raw.outTo[TaskUser])

def unassigned: TaskSteps = this.not(_.outToE[TaskUser])

def organisations = new OrganisationSteps(raw.inTo[ShareTask].inTo[OrganisationShare])
def organisations(permission: Permission) =
Expand Down

0 comments on commit ee2cd7d

Please sign in to comment.