From 8a6f3080e1cf7867653dfd3c06ae22d706966c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Samin?= Date: Wed, 25 Mar 2020 09:38:37 +0100 Subject: [PATCH] fix(api): getWorkflowJobQueueHandler filter by group for all hatcheries (#5079) Signed-off-by: francois samin --- engine/api/workflow_queue.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/api/workflow_queue.go b/engine/api/workflow_queue.go index 09b687c179..f743674bc0 100644 --- a/engine/api/workflow_queue.go +++ b/engine/api/workflow_queue.go @@ -741,12 +741,12 @@ func (api *API) getWorkflowJobQueueHandler() service.Handler { return errM } - permissions := sdk.PermissionReadExecute + permissions := sdk.PermissionRead isW := isWorker(ctx) isS := isService(ctx) - if !isW && !isS { - permissions = sdk.PermissionRead + if isW || isS { + permissions = sdk.PermissionReadExecute } filter := workflow.NewQueueFilter() @@ -759,8 +759,10 @@ func (api *API) getWorkflowJobQueueHandler() service.Handler { if modelType != "" { filter.ModelType = []string{modelType} } + var jobs []sdk.WorkflowNodeJobRun - if !isMaintainer(ctx) && !isAdmin(ctx) { + // If the consumer is a worker, a hatchery or a non maintainer user, filter the job by its groups + if isW || isS || !isMaintainer(ctx) { jobs, err = workflow.LoadNodeJobRunQueueByGroupIDs(ctx, api.mustDB(), api.Cache, filter, getAPIConsumer(ctx).GetGroupIDs()) } else { jobs, err = workflow.LoadNodeJobRunQueue(ctx, api.mustDB(), api.Cache, filter)