mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
event rules: allow filtering based on group names
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -930,6 +930,8 @@ func (p *ConditionPattern) validate() error {
|
||||
type ConditionOptions struct {
|
||||
// Usernames or folder names
|
||||
Names []ConditionPattern `json:"names,omitempty"`
|
||||
// Group names
|
||||
GroupNames []ConditionPattern `json:"group_names,omitempty"`
|
||||
// Virtual paths
|
||||
FsPaths []ConditionPattern `json:"fs_paths,omitempty"`
|
||||
Protocols []string `json:"protocols,omitempty"`
|
||||
@@ -948,6 +950,7 @@ func (f *ConditionOptions) getACopy() ConditionOptions {
|
||||
|
||||
return ConditionOptions{
|
||||
Names: cloneConditionPatterns(f.Names),
|
||||
GroupNames: cloneConditionPatterns(f.GroupNames),
|
||||
FsPaths: cloneConditionPatterns(f.FsPaths),
|
||||
Protocols: protocols,
|
||||
ProviderObjects: providerObjects,
|
||||
@@ -963,6 +966,11 @@ func (f *ConditionOptions) validate() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for _, name := range f.GroupNames {
|
||||
if err := name.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for _, fsPath := range f.FsPaths {
|
||||
if err := fsPath.validate(); err != nil {
|
||||
return err
|
||||
@@ -1061,6 +1069,7 @@ func (c *EventConditions) validate(trigger int) error {
|
||||
case EventTriggerProviderEvent:
|
||||
c.FsEvents = nil
|
||||
c.Schedules = nil
|
||||
c.Options.GroupNames = nil
|
||||
c.Options.FsPaths = nil
|
||||
c.Options.Protocols = nil
|
||||
c.Options.MinFileSize = 0
|
||||
@@ -1093,6 +1102,7 @@ func (c *EventConditions) validate(trigger int) error {
|
||||
c.FsEvents = nil
|
||||
c.ProviderEvents = nil
|
||||
c.Options.Names = nil
|
||||
c.Options.GroupNames = nil
|
||||
c.Options.FsPaths = nil
|
||||
c.Options.Protocols = nil
|
||||
c.Options.MinFileSize = 0
|
||||
@@ -1101,6 +1111,7 @@ func (c *EventConditions) validate(trigger int) error {
|
||||
default:
|
||||
c.FsEvents = nil
|
||||
c.ProviderEvents = nil
|
||||
c.Options.GroupNames = nil
|
||||
c.Options.FsPaths = nil
|
||||
c.Options.Protocols = nil
|
||||
c.Options.MinFileSize = 0
|
||||
|
||||
Reference in New Issue
Block a user