feat(filters): show enabled and disabled actions in list view (#1304)

* feat(filters): reflect enabled actions

* dont store release unless enabled action found

* store the release after the delay

* add new parameter to FindByFilterID method
This commit is contained in:
soup 2023-12-17 21:18:26 +01:00 committed by GitHub
parent 95cd053db5
commit 6e12654f6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 59 additions and 45 deletions

View file

@ -162,6 +162,27 @@ func (s *service) processFilters(ctx context.Context, filters []*domain.Filter,
l.Info().Msgf("Matched '%s' (%s) for %s", release.TorrentName, release.FilterName, release.Indexer)
// found matching filter, lets find the filter actions and attach
active := true
actions, err := s.actionSvc.FindByFilterID(ctx, f.ID, &active)
if err != nil {
s.log.Error().Err(err).Msgf("release.Process: error finding actions for filter: %s", f.Name)
return err
}
// if no actions, continue to next filter
if len(actions) == 0 {
s.log.Warn().Msgf("release.Process: no active actions found for filter '%s', trying next one..", f.Name)
continue
}
// sleep for the delay period specified in the filter before running actions
delay := release.Filter.Delay
if delay > 0 {
l.Debug().Msgf("release.Process: delaying processing of '%s' (%s) for %s by %d seconds as specified in the filter", release.TorrentName, release.FilterName, release.Indexer, delay)
time.Sleep(time.Duration(delay) * time.Second)
}
// save release here to only save those with rejections from actions instead of all releases
if release.ID == 0 {
release.FilterStatus = domain.ReleaseStatusFilterApproved
@ -172,26 +193,6 @@ func (s *service) processFilters(ctx context.Context, filters []*domain.Filter,
}
}
// found matching filter, lets find the filter actions and attach
actions, err := s.actionSvc.FindByFilterID(ctx, f.ID)
if err != nil {
s.log.Error().Err(err).Msgf("release.Process: error finding actions for filter: %s", f.Name)
return err
}
// if no actions, continue to next filter
if len(actions) == 0 {
s.log.Warn().Msgf("release.Process: no actions found for filter '%s', trying next one..", f.Name)
return nil
}
// sleep for the delay period specified in the filter before running actions
delay := release.Filter.Delay
if delay > 0 {
l.Debug().Msgf("release.Process: delaying processing of '%s' (%s) for %s by %d seconds as specified in the filter", release.TorrentName, release.FilterName, release.Indexer, delay)
time.Sleep(time.Duration(delay) * time.Second)
}
var rejections []string
// run actions (watchFolder, test, exec, qBittorrent, Deluge, arr etc.)