Append custom args when executing corredor scripts via Compose REST handlers
This commit is contained in:
@@ -2,6 +2,7 @@ package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/api"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/rest/request"
|
||||
@@ -47,5 +48,5 @@ func (ctrl *Automation) Bundle(ctx context.Context, r *request.AutomationBundle)
|
||||
}
|
||||
|
||||
func (ctrl *Automation) TriggerScript(ctx context.Context, r *request.AutomationTriggerScript) (interface{}, error) {
|
||||
return api.OK(), corredor.Service().Exec(ctx, r.Script, event.ComposeOnManual())
|
||||
return api.OK(), corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.ComposeOnManual(), r.Args))
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ func (ctrl *Module) TriggerScript(ctx context.Context, r *request.ModuleTriggerS
|
||||
}
|
||||
|
||||
// @todo implement same behaviour as we have on record - module+oldModule
|
||||
err = corredor.Service().Exec(ctx, r.Script, event.ModuleOnManual(module, module, namespace))
|
||||
err = corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.ModuleOnManual(module, module, namespace), r.Args))
|
||||
return ctrl.makePayload(ctx, module, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ func (ctrl *Namespace) TriggerScript(ctx context.Context, r *request.NamespaceTr
|
||||
return
|
||||
}
|
||||
|
||||
err = corredor.Service().Exec(ctx, r.Script, event.NamespaceOnManual(namespace, nil))
|
||||
err = corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.NamespaceOnManual(namespace, nil), r.Args))
|
||||
return ctrl.makePayload(ctx, namespace, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ func (ctrl *Page) TriggerScript(ctx context.Context, r *request.PageTriggerScrip
|
||||
}
|
||||
|
||||
// @todo implement same behaviour as we have on record - page+oldPage
|
||||
err = corredor.Service().Exec(ctx, r.Script, event.PageOnManual(page, page, namespace, nil))
|
||||
err = corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.PageOnManual(page, page, namespace, nil), r.Args))
|
||||
return ctrl.makePayload(ctx, page, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user