mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(actions): simplify macro parsing (#560)
* refactor(action): parse macros * feat(action): add ctx to arr clients and test
This commit is contained in:
parent
f6e68fae2b
commit
839eb9f3f3
31 changed files with 323 additions and 334 deletions
|
@ -1,6 +1,9 @@
|
|||
package domain
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"github.com/autobrr/autobrr/pkg/errors"
|
||||
)
|
||||
|
||||
type ActionRepo interface {
|
||||
Store(ctx context.Context, action Action) (*Action, error)
|
||||
|
@ -46,6 +49,27 @@ type Action struct {
|
|||
Client DownloadClient `json:"client,omitempty"`
|
||||
}
|
||||
|
||||
// ParseMacros parse all macros on action
|
||||
func (a *Action) ParseMacros(release Release) error {
|
||||
var err error
|
||||
|
||||
m := NewMacro(release)
|
||||
|
||||
a.ExecArgs, err = m.Parse(a.ExecArgs)
|
||||
a.WatchFolder, err = m.Parse(a.WatchFolder)
|
||||
a.Category, err = m.Parse(a.Category)
|
||||
a.Tags, err = m.Parse(a.Tags)
|
||||
a.Label, err = m.Parse(a.Label)
|
||||
a.SavePath, err = m.Parse(a.SavePath)
|
||||
a.WebhookData, err = m.Parse(a.WebhookData)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not parse macros for action: %v", a.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type ActionType string
|
||||
|
||||
const (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue