mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Fix setting observer_can_run in query API (#823)
Previous work in #777 added the datastore and model layers, but didn't handle setting this value in the service and transport. Fixes #822
This commit is contained in:
parent
83b7f79699
commit
82fe7c0035
2 changed files with 12 additions and 3 deletions
|
|
@ -61,9 +61,10 @@ type QueryService interface {
|
|||
}
|
||||
|
||||
type QueryPayload struct {
|
||||
Name *string
|
||||
Description *string
|
||||
Query *string
|
||||
Name *string
|
||||
Description *string
|
||||
Query *string
|
||||
ObserverCanRun *bool `json:"observer_can_run"`
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,10 @@ func (svc service) NewQuery(ctx context.Context, p kolide.QueryPayload) (*kolide
|
|||
query.Query = *p.Query
|
||||
}
|
||||
|
||||
if p.ObserverCanRun != nil {
|
||||
query.ObserverCanRun = *p.ObserverCanRun
|
||||
}
|
||||
|
||||
vc, ok := viewer.FromContext(ctx)
|
||||
if ok {
|
||||
query.AuthorID = uintPtr(vc.UserID())
|
||||
|
|
@ -125,6 +129,10 @@ func (svc service) ModifyQuery(ctx context.Context, id uint, p kolide.QueryPaylo
|
|||
query.Query = *p.Query
|
||||
}
|
||||
|
||||
if p.ObserverCanRun != nil {
|
||||
query.ObserverCanRun = *p.ObserverCanRun
|
||||
}
|
||||
|
||||
if err := query.ValidateSQL(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue