diff --git a/internal/database/filter.go b/internal/database/filter.go
index fe77e2b..35d927c 100644
--- a/internal/database/filter.go
+++ b/internal/database/filter.go
@@ -250,7 +250,6 @@ func (r *FilterRepo) FindByID(ctx context.Context, filterID int) (*domain.Filter
"fe.webhook_retry_status",
"fe.webhook_retry_attempts",
"fe.webhook_retry_delay_seconds",
- "fe.webhook_retry_max_jitter_seconds",
).
From("filter f").
LeftJoin("filter_external fe ON f.id = fe.filter_id").
@@ -404,23 +403,22 @@ func (r *FilterRepo) FindByID(ctx context.Context, filterID int) (*domain.Filter
if extId.Valid {
external := domain.FilterExternal{
- ID: int(extId.Int32),
- Name: extName.String,
- Index: int(extIndex.Int32),
- Type: domain.FilterExternalType(extType.String),
- Enabled: extEnabled.Bool,
- ExecCmd: extExecCmd.String,
- ExecArgs: extExecArgs.String,
- ExecExpectStatus: int(extExecStatus.Int32),
- WebhookHost: extWebhookHost.String,
- WebhookMethod: extWebhookMethod.String,
- WebhookData: extWebhookData.String,
- WebhookHeaders: extWebhookHeaders.String,
- WebhookExpectStatus: int(extWebhookStatus.Int32),
- WebhookRetryStatus: extWebhookRetryStatus.String,
- WebhookRetryAttempts: int(extWebhookRetryAttempts.Int32),
- WebhookRetryDelaySeconds: int(extWebhookDelaySeconds.Int32),
- WebhookRetryMaxJitterSeconds: int(extWebhookRetryJitterSeconds.Int32),
+ ID: int(extId.Int32),
+ Name: extName.String,
+ Index: int(extIndex.Int32),
+ Type: domain.FilterExternalType(extType.String),
+ Enabled: extEnabled.Bool,
+ ExecCmd: extExecCmd.String,
+ ExecArgs: extExecArgs.String,
+ ExecExpectStatus: int(extExecStatus.Int32),
+ WebhookHost: extWebhookHost.String,
+ WebhookMethod: extWebhookMethod.String,
+ WebhookData: extWebhookData.String,
+ WebhookHeaders: extWebhookHeaders.String,
+ WebhookExpectStatus: int(extWebhookStatus.Int32),
+ WebhookRetryStatus: extWebhookRetryStatus.String,
+ WebhookRetryAttempts: int(extWebhookRetryAttempts.Int32),
+ WebhookRetryDelaySeconds: int(extWebhookDelaySeconds.Int32),
}
externalMap[external.ID] = external
}
@@ -517,7 +515,6 @@ func (r *FilterRepo) findByIndexerIdentifier(ctx context.Context, indexer string
"fe.webhook_retry_status",
"fe.webhook_retry_attempts",
"fe.webhook_retry_delay_seconds",
- "fe.webhook_retry_max_jitter_seconds",
"fe.filter_id",
).
From("filter f").
@@ -678,24 +675,23 @@ func (r *FilterRepo) findByIndexerIdentifier(ctx context.Context, indexer string
if extId.Valid {
external := domain.FilterExternal{
- ID: int(extId.Int32),
- Name: extName.String,
- Index: int(extIndex.Int32),
- Type: domain.FilterExternalType(extType.String),
- Enabled: extEnabled.Bool,
- ExecCmd: extExecCmd.String,
- ExecArgs: extExecArgs.String,
- ExecExpectStatus: int(extExecStatus.Int32),
- WebhookHost: extWebhookHost.String,
- WebhookMethod: extWebhookMethod.String,
- WebhookData: extWebhookData.String,
- WebhookHeaders: extWebhookHeaders.String,
- WebhookExpectStatus: int(extWebhookStatus.Int32),
- WebhookRetryStatus: extWebhookRetryStatus.String,
- WebhookRetryAttempts: int(extWebhookRetryAttempts.Int32),
- WebhookRetryDelaySeconds: int(extWebhookDelaySeconds.Int32),
- WebhookRetryMaxJitterSeconds: int(extWebhookRetryJitterSeconds.Int32),
- FilterId: int(extFilterId.Int32),
+ ID: int(extId.Int32),
+ Name: extName.String,
+ Index: int(extIndex.Int32),
+ Type: domain.FilterExternalType(extType.String),
+ Enabled: extEnabled.Bool,
+ ExecCmd: extExecCmd.String,
+ ExecArgs: extExecArgs.String,
+ ExecExpectStatus: int(extExecStatus.Int32),
+ WebhookHost: extWebhookHost.String,
+ WebhookMethod: extWebhookMethod.String,
+ WebhookData: extWebhookData.String,
+ WebhookHeaders: extWebhookHeaders.String,
+ WebhookExpectStatus: int(extWebhookStatus.Int32),
+ WebhookRetryStatus: extWebhookRetryStatus.String,
+ WebhookRetryAttempts: int(extWebhookRetryAttempts.Int32),
+ WebhookRetryDelaySeconds: int(extWebhookDelaySeconds.Int32),
+ FilterId: int(extFilterId.Int32),
}
externalMap[external.FilterId] = append(externalMap[external.FilterId], external)
}
@@ -736,7 +732,6 @@ func (r *FilterRepo) FindExternalFiltersByID(ctx context.Context, filterId int)
"fe.webhook_retry_status",
"fe.webhook_retry_attempts",
"fe.webhook_retry_delay_seconds",
- "fe.webhook_retry_max_jitter_seconds",
).
From("filter_external fe").
Where(sq.Eq{"fe.filter_id": filterId})
@@ -797,7 +792,6 @@ func (r *FilterRepo) FindExternalFiltersByID(ctx context.Context, filterId int)
external.WebhookRetryStatus = extWebhookRetryStatus.String
external.WebhookRetryAttempts = int(extWebhookRetryAttempts.Int32)
external.WebhookRetryDelaySeconds = int(extWebhookDelaySeconds.Int32)
- external.WebhookRetryMaxJitterSeconds = int(extWebhookRetryJitterSeconds.Int32)
externalFilters = append(externalFilters, external)
}
@@ -1227,9 +1221,6 @@ func (r *FilterRepo) UpdatePartial(ctx context.Context, filter domain.FilterUpda
if filter.ExternalWebhookRetryDelaySeconds != nil {
q = q.Set("external_webhook_retry_delay_seconds", filter.ExternalWebhookRetryDelaySeconds)
}
- if filter.ExternalWebhookRetryMaxJitterSeconds != nil {
- q = q.Set("external_webhook_retry_max_jitter_seconds", filter.ExternalWebhookRetryMaxJitterSeconds)
- }
q = q.Where(sq.Eq{"id": filter.ID})
@@ -1513,7 +1504,6 @@ func (r *FilterRepo) StoreFilterExternal(ctx context.Context, filterID int, exte
"webhook_retry_status",
"webhook_retry_attempts",
"webhook_retry_delay_seconds",
- "webhook_retry_max_jitter_seconds",
"filter_id",
)
@@ -1534,7 +1524,6 @@ func (r *FilterRepo) StoreFilterExternal(ctx context.Context, filterID int, exte
toNullString(external.WebhookRetryStatus),
toNullInt32(int32(external.WebhookRetryAttempts)),
toNullInt32(int32(external.WebhookRetryDelaySeconds)),
- toNullInt32(int32(external.WebhookRetryMaxJitterSeconds)),
filterID,
)
}
diff --git a/internal/database/postgres_migrate.go b/internal/database/postgres_migrate.go
index 11a7f13..9ef44bb 100644
--- a/internal/database/postgres_migrate.go
+++ b/internal/database/postgres_migrate.go
@@ -149,7 +149,6 @@ CREATE TABLE filter_external
webhook_retry_status TEXT,
webhook_retry_attempts INTEGER,
webhook_retry_delay_seconds INTEGER,
- webhook_retry_max_jitter_seconds INTEGER,
filter_id INTEGER NOT NULL,
FOREIGN KEY (filter_id) REFERENCES filter(id) ON DELETE CASCADE
);
@@ -825,5 +824,8 @@ ALTER TABLE filter_external
ALTER TABLE filter_external
RENAME COLUMN external_webhook_retry_max_jitter_seconds TO webhook_retry_max_jitter_seconds;
+`,
+ `ALTER TABLE filter_external
+ DROP COLUMN IF EXISTS external_webhook_retry_max_jitter_seconds;
`,
}
diff --git a/internal/database/sqlite_migrate.go b/internal/database/sqlite_migrate.go
index feedd6f..c947df3 100644
--- a/internal/database/sqlite_migrate.go
+++ b/internal/database/sqlite_migrate.go
@@ -149,7 +149,6 @@ CREATE TABLE filter_external
webhook_retry_status TEXT,
webhook_retry_attempts INTEGER,
webhook_retry_delay_seconds INTEGER,
- webhook_retry_max_jitter_seconds INTEGER,
filter_id INTEGER NOT NULL,
FOREIGN KEY (filter_id) REFERENCES filter(id) ON DELETE CASCADE
);
@@ -1418,5 +1417,8 @@ DROP TABLE filter_external;
ALTER TABLE filter_external_dg_tmp
RENAME TO filter_external;
+`,
+ `ALTER TABLE filter_external
+ DROP COLUMN external_webhook_retry_max_jitter_seconds;
`,
}
diff --git a/internal/domain/filter.go b/internal/domain/filter.go
index 2451610..de7718c 100644
--- a/internal/domain/filter.go
+++ b/internal/domain/filter.go
@@ -138,24 +138,23 @@ type Filter struct {
}
type FilterExternal struct {
- ID int `json:"id"`
- Name string `json:"name"`
- Index int `json:"index"`
- Type FilterExternalType `json:"type"`
- Enabled bool `json:"enabled"`
- ExecCmd string `json:"exec_cmd,omitempty"`
- ExecArgs string `json:"exec_args,omitempty"`
- ExecExpectStatus int `json:"exec_expect_status,omitempty"`
- WebhookHost string `json:"webhook_host,omitempty"`
- WebhookMethod string `json:"webhook_method,omitempty"`
- WebhookData string `json:"webhook_data,omitempty"`
- WebhookHeaders string `json:"webhook_headers,omitempty"`
- WebhookExpectStatus int `json:"webhook_expect_status,omitempty"`
- WebhookRetryStatus string `json:"webhook_retry_status,omitempty"`
- WebhookRetryAttempts int `json:"webhook_retry_attempts,omitempty"`
- WebhookRetryDelaySeconds int `json:"webhook_retry_delay_seconds,omitempty"`
- WebhookRetryMaxJitterSeconds int `json:"webhook_retry_max_jitter_seconds,omitempty"`
- FilterId int `json:"-"`
+ ID int `json:"id"`
+ Name string `json:"name"`
+ Index int `json:"index"`
+ Type FilterExternalType `json:"type"`
+ Enabled bool `json:"enabled"`
+ ExecCmd string `json:"exec_cmd,omitempty"`
+ ExecArgs string `json:"exec_args,omitempty"`
+ ExecExpectStatus int `json:"exec_expect_status,omitempty"`
+ WebhookHost string `json:"webhook_host,omitempty"`
+ WebhookMethod string `json:"webhook_method,omitempty"`
+ WebhookData string `json:"webhook_data,omitempty"`
+ WebhookHeaders string `json:"webhook_headers,omitempty"`
+ WebhookExpectStatus int `json:"webhook_expect_status,omitempty"`
+ WebhookRetryStatus string `json:"webhook_retry_status,omitempty"`
+ WebhookRetryAttempts int `json:"webhook_retry_attempts,omitempty"`
+ WebhookRetryDelaySeconds int `json:"webhook_retry_delay_seconds,omitempty"`
+ FilterId int `json:"-"`
}
type FilterExternalType string
@@ -166,83 +165,82 @@ const (
)
type FilterUpdate struct {
- ID int `json:"id"`
- Name *string `json:"name,omitempty"`
- Enabled *bool `json:"enabled,omitempty"`
- MinSize *string `json:"min_size,omitempty"`
- MaxSize *string `json:"max_size,omitempty"`
- Delay *int `json:"delay,omitempty"`
- Priority *int32 `json:"priority,omitempty"`
- MaxDownloads *int `json:"max_downloads,omitempty"`
- MaxDownloadsUnit *FilterMaxDownloadsUnit `json:"max_downloads_unit,omitempty"`
- MatchReleases *string `json:"match_releases,omitempty"`
- ExceptReleases *string `json:"except_releases,omitempty"`
- UseRegex *bool `json:"use_regex,omitempty"`
- MatchReleaseGroups *string `json:"match_release_groups,omitempty"`
- ExceptReleaseGroups *string `json:"except_release_groups,omitempty"`
- MatchReleaseTags *string `json:"match_release_tags,omitempty"`
- ExceptReleaseTags *string `json:"except_release_tags,omitempty"`
- UseRegexReleaseTags *bool `json:"use_regex_release_tags,omitempty"`
- MatchDescription *string `json:"match_description,omitempty"`
- ExceptDescription *string `json:"except_description,omitempty"`
- UseRegexDescription *bool `json:"use_regex_description,omitempty"`
- Scene *bool `json:"scene,omitempty"`
- Origins *[]string `json:"origins,omitempty"`
- ExceptOrigins *[]string `json:"except_origins,omitempty"`
- Bonus *[]string `json:"bonus,omitempty"`
- Freeleech *bool `json:"freeleech,omitempty"`
- FreeleechPercent *string `json:"freeleech_percent,omitempty"`
- SmartEpisode *bool `json:"smart_episode,omitempty"`
- Shows *string `json:"shows,omitempty"`
- Seasons *string `json:"seasons,omitempty"`
- Episodes *string `json:"episodes,omitempty"`
- Resolutions *[]string `json:"resolutions,omitempty"` // SD, 480i, 480p, 576p, 720p, 810p, 1080i, 1080p.
- Codecs *[]string `json:"codecs,omitempty"` // XviD, DivX, x264, h.264 (or h264), mpeg2 (or mpeg-2), VC-1 (or VC1), WMV, Remux, h.264 Remux (or h264 Remux), VC-1 Remux (or VC1 Remux).
- Sources *[]string `json:"sources,omitempty"` // DSR, PDTV, HDTV, HR.PDTV, HR.HDTV, DVDRip, DVDScr, BDr, BD5, BD9, BDRip, BRRip, DVDR, MDVDR, HDDVD, HDDVDRip, BluRay, WEB-DL, TVRip, CAM, R5, TELESYNC, TS, TELECINE, TC. TELESYNC and TS are synonyms (you don't need both). Same for TELECINE and TC
- Containers *[]string `json:"containers,omitempty"`
- MatchHDR *[]string `json:"match_hdr,omitempty"`
- ExceptHDR *[]string `json:"except_hdr,omitempty"`
- MatchOther *[]string `json:"match_other,omitempty"`
- ExceptOther *[]string `json:"except_other,omitempty"`
- Years *string `json:"years,omitempty"`
- Artists *string `json:"artists,omitempty"`
- Albums *string `json:"albums,omitempty"`
- MatchReleaseTypes *[]string `json:"match_release_types,omitempty"` // Album,Single,EP
- ExceptReleaseTypes *string `json:"except_release_types,omitempty"`
- Formats *[]string `json:"formats,omitempty"` // MP3, FLAC, Ogg, AAC, AC3, DTS
- Quality *[]string `json:"quality,omitempty"` // 192, 320, APS (VBR), V2 (VBR), V1 (VBR), APX (VBR), V0 (VBR), q8.x (VBR), Lossless, 24bit Lossless, Other
- Media *[]string `json:"media,omitempty"` // CD, DVD, Vinyl, Soundboard, SACD, DAT, Cassette, WEB, Other
- PerfectFlac *bool `json:"perfect_flac,omitempty"`
- Cue *bool `json:"cue,omitempty"`
- Log *bool `json:"log,omitempty"`
- LogScore *int `json:"log_score,omitempty"`
- MatchCategories *string `json:"match_categories,omitempty"`
- ExceptCategories *string `json:"except_categories,omitempty"`
- MatchUploaders *string `json:"match_uploaders,omitempty"`
- ExceptUploaders *string `json:"except_uploaders,omitempty"`
- MatchLanguage *[]string `json:"match_language,omitempty"`
- ExceptLanguage *[]string `json:"except_language,omitempty"`
- Tags *string `json:"tags,omitempty"`
- ExceptTags *string `json:"except_tags,omitempty"`
- TagsAny *string `json:"tags_any,omitempty"`
- ExceptTagsAny *string `json:"except_tags_any,omitempty"`
- TagsMatchLogic *string `json:"tags_match_logic,omitempty"`
- ExceptTagsMatchLogic *string `json:"except_tags_match_logic,omitempty"`
- ExternalScriptEnabled *bool `json:"external_script_enabled,omitempty"`
- ExternalScriptCmd *string `json:"external_script_cmd,omitempty"`
- ExternalScriptArgs *string `json:"external_script_args,omitempty"`
- ExternalScriptExpectStatus *int `json:"external_script_expect_status,omitempty"`
- ExternalWebhookEnabled *bool `json:"external_webhook_enabled,omitempty"`
- ExternalWebhookHost *string `json:"external_webhook_host,omitempty"`
- ExternalWebhookData *string `json:"external_webhook_data,omitempty"`
- ExternalWebhookExpectStatus *int `json:"external_webhook_expect_status,omitempty"`
- ExternalWebhookRetryStatus *string `json:"external_webhook_retry_status,omitempty"`
- ExternalWebhookRetryAttempts *int `json:"external_webhook_retry_attempts,omitempty"`
- ExternalWebhookRetryDelaySeconds *int `json:"external_webhook_retry_delay_seconds,omitempty"`
- ExternalWebhookRetryMaxJitterSeconds *int `json:"external_webhook_retry_max_jitter_seconds,omitempty"`
- Actions []*Action `json:"actions,omitempty"`
- External []FilterExternal `json:"external,omitempty"`
- Indexers []Indexer `json:"indexers,omitempty"`
+ ID int `json:"id"`
+ Name *string `json:"name,omitempty"`
+ Enabled *bool `json:"enabled,omitempty"`
+ MinSize *string `json:"min_size,omitempty"`
+ MaxSize *string `json:"max_size,omitempty"`
+ Delay *int `json:"delay,omitempty"`
+ Priority *int32 `json:"priority,omitempty"`
+ MaxDownloads *int `json:"max_downloads,omitempty"`
+ MaxDownloadsUnit *FilterMaxDownloadsUnit `json:"max_downloads_unit,omitempty"`
+ MatchReleases *string `json:"match_releases,omitempty"`
+ ExceptReleases *string `json:"except_releases,omitempty"`
+ UseRegex *bool `json:"use_regex,omitempty"`
+ MatchReleaseGroups *string `json:"match_release_groups,omitempty"`
+ ExceptReleaseGroups *string `json:"except_release_groups,omitempty"`
+ MatchReleaseTags *string `json:"match_release_tags,omitempty"`
+ ExceptReleaseTags *string `json:"except_release_tags,omitempty"`
+ UseRegexReleaseTags *bool `json:"use_regex_release_tags,omitempty"`
+ MatchDescription *string `json:"match_description,omitempty"`
+ ExceptDescription *string `json:"except_description,omitempty"`
+ UseRegexDescription *bool `json:"use_regex_description,omitempty"`
+ Scene *bool `json:"scene,omitempty"`
+ Origins *[]string `json:"origins,omitempty"`
+ ExceptOrigins *[]string `json:"except_origins,omitempty"`
+ Bonus *[]string `json:"bonus,omitempty"`
+ Freeleech *bool `json:"freeleech,omitempty"`
+ FreeleechPercent *string `json:"freeleech_percent,omitempty"`
+ SmartEpisode *bool `json:"smart_episode,omitempty"`
+ Shows *string `json:"shows,omitempty"`
+ Seasons *string `json:"seasons,omitempty"`
+ Episodes *string `json:"episodes,omitempty"`
+ Resolutions *[]string `json:"resolutions,omitempty"` // SD, 480i, 480p, 576p, 720p, 810p, 1080i, 1080p.
+ Codecs *[]string `json:"codecs,omitempty"` // XviD, DivX, x264, h.264 (or h264), mpeg2 (or mpeg-2), VC-1 (or VC1), WMV, Remux, h.264 Remux (or h264 Remux), VC-1 Remux (or VC1 Remux).
+ Sources *[]string `json:"sources,omitempty"` // DSR, PDTV, HDTV, HR.PDTV, HR.HDTV, DVDRip, DVDScr, BDr, BD5, BD9, BDRip, BRRip, DVDR, MDVDR, HDDVD, HDDVDRip, BluRay, WEB-DL, TVRip, CAM, R5, TELESYNC, TS, TELECINE, TC. TELESYNC and TS are synonyms (you don't need both). Same for TELECINE and TC
+ Containers *[]string `json:"containers,omitempty"`
+ MatchHDR *[]string `json:"match_hdr,omitempty"`
+ ExceptHDR *[]string `json:"except_hdr,omitempty"`
+ MatchOther *[]string `json:"match_other,omitempty"`
+ ExceptOther *[]string `json:"except_other,omitempty"`
+ Years *string `json:"years,omitempty"`
+ Artists *string `json:"artists,omitempty"`
+ Albums *string `json:"albums,omitempty"`
+ MatchReleaseTypes *[]string `json:"match_release_types,omitempty"` // Album,Single,EP
+ ExceptReleaseTypes *string `json:"except_release_types,omitempty"`
+ Formats *[]string `json:"formats,omitempty"` // MP3, FLAC, Ogg, AAC, AC3, DTS
+ Quality *[]string `json:"quality,omitempty"` // 192, 320, APS (VBR), V2 (VBR), V1 (VBR), APX (VBR), V0 (VBR), q8.x (VBR), Lossless, 24bit Lossless, Other
+ Media *[]string `json:"media,omitempty"` // CD, DVD, Vinyl, Soundboard, SACD, DAT, Cassette, WEB, Other
+ PerfectFlac *bool `json:"perfect_flac,omitempty"`
+ Cue *bool `json:"cue,omitempty"`
+ Log *bool `json:"log,omitempty"`
+ LogScore *int `json:"log_score,omitempty"`
+ MatchCategories *string `json:"match_categories,omitempty"`
+ ExceptCategories *string `json:"except_categories,omitempty"`
+ MatchUploaders *string `json:"match_uploaders,omitempty"`
+ ExceptUploaders *string `json:"except_uploaders,omitempty"`
+ MatchLanguage *[]string `json:"match_language,omitempty"`
+ ExceptLanguage *[]string `json:"except_language,omitempty"`
+ Tags *string `json:"tags,omitempty"`
+ ExceptTags *string `json:"except_tags,omitempty"`
+ TagsAny *string `json:"tags_any,omitempty"`
+ ExceptTagsAny *string `json:"except_tags_any,omitempty"`
+ TagsMatchLogic *string `json:"tags_match_logic,omitempty"`
+ ExceptTagsMatchLogic *string `json:"except_tags_match_logic,omitempty"`
+ ExternalScriptEnabled *bool `json:"external_script_enabled,omitempty"`
+ ExternalScriptCmd *string `json:"external_script_cmd,omitempty"`
+ ExternalScriptArgs *string `json:"external_script_args,omitempty"`
+ ExternalScriptExpectStatus *int `json:"external_script_expect_status,omitempty"`
+ ExternalWebhookEnabled *bool `json:"external_webhook_enabled,omitempty"`
+ ExternalWebhookHost *string `json:"external_webhook_host,omitempty"`
+ ExternalWebhookData *string `json:"external_webhook_data,omitempty"`
+ ExternalWebhookExpectStatus *int `json:"external_webhook_expect_status,omitempty"`
+ ExternalWebhookRetryStatus *string `json:"external_webhook_retry_status,omitempty"`
+ ExternalWebhookRetryAttempts *int `json:"external_webhook_retry_attempts,omitempty"`
+ ExternalWebhookRetryDelaySeconds *int `json:"external_webhook_retry_delay_seconds,omitempty"`
+ Actions []*Action `json:"actions,omitempty"`
+ External []FilterExternal `json:"external,omitempty"`
+ Indexers []Indexer `json:"indexers,omitempty"`
}
func (f Filter) CheckFilter(r *Release) ([]string, bool) {
diff --git a/internal/filter/service.go b/internal/filter/service.go
index c8eaba8..d8510a6 100644
--- a/internal/filter/service.go
+++ b/internal/filter/service.go
@@ -4,7 +4,6 @@
package filter
import (
- "bufio"
"bytes"
"context"
"crypto/tls"
@@ -704,19 +703,9 @@ func (s *service) webhook(ctx context.Context, external domain.FilterExternal, r
method = external.WebhookMethod
}
- var req *http.Request
- if external.WebhookData != "" && dataArgs != "" {
- req, err = http.NewRequestWithContext(ctx, method, external.WebhookHost, bytes.NewBufferString(dataArgs))
- if err != nil {
- return 0, errors.Wrap(err, "could not build request for webhook")
- }
-
- defer req.Body.Close()
- } else {
- req, err = http.NewRequestWithContext(ctx, method, external.WebhookHost, nil)
- if err != nil {
- return 0, errors.Wrap(err, "could not build request for webhook")
- }
+ req, err := http.NewRequestWithContext(ctx, method, external.WebhookHost, nil)
+ if err != nil {
+ return 0, errors.Wrap(err, "could not build request for webhook")
}
req.Header.Set("Content-Type", "application/json")
@@ -739,30 +728,29 @@ func (s *service) webhook(ctx context.Context, external domain.FilterExternal, r
var opts []retry.Option
+ opts = append(opts, retry.DelayType(retry.FixedDelay))
+ opts = append(opts, retry.LastErrorOnly(true))
+
if external.WebhookRetryAttempts > 0 {
- option := retry.Attempts(uint(external.WebhookRetryAttempts))
- opts = append(opts, option)
+ opts = append(opts, retry.Attempts(uint(external.WebhookRetryAttempts)))
}
if external.WebhookRetryDelaySeconds > 0 {
- option := retry.Delay(time.Duration(external.WebhookRetryDelaySeconds) * time.Second)
- opts = append(opts, option)
+ opts = append(opts, retry.Delay(time.Duration(external.WebhookRetryDelaySeconds)*time.Second))
}
- if external.WebhookRetryMaxJitterSeconds > 0 {
- option := retry.MaxJitter(time.Duration(external.WebhookRetryMaxJitterSeconds) * time.Second)
- opts = append(opts, option)
- }
-
- start := time.Now()
var retryStatusCodes []string
if external.WebhookRetryStatus != "" {
retryStatusCodes = strings.Split(strings.ReplaceAll(external.WebhookRetryStatus, " ", ""), ",")
}
+ start := time.Now()
+
statusCode, err := retry.DoWithData(
func() (int, error) {
clonereq := req.Clone(ctx)
- clonereq.Body = io.NopCloser(bufio.NewReader(req.Body))
+ if external.WebhookData != "" && dataArgs != "" {
+ clonereq.Body = io.NopCloser(bytes.NewBufferString(dataArgs))
+ }
res, err := client.Do(clonereq)
if err != nil {
return 0, errors.Wrap(err, "could not make request for webhook")
@@ -770,6 +758,8 @@ func (s *service) webhook(ctx context.Context, external domain.FilterExternal, r
defer res.Body.Close()
+ s.log.Debug().Msgf("filter external webhook response status: %d", res.StatusCode)
+
body, err := io.ReadAll(res.Body)
if err != nil {
return res.StatusCode, errors.Wrap(err, "could not read request body")
@@ -780,7 +770,7 @@ func (s *service) webhook(ctx context.Context, external domain.FilterExternal, r
}
if utils.StrSliceContains(retryStatusCodes, strconv.Itoa(res.StatusCode)) {
- return 0, errors.New("retrying webhook request, got status code: %d", res.StatusCode)
+ return 0, errors.New("webhook got unwanted status code: %d", res.StatusCode)
}
return res.StatusCode, nil
diff --git a/web/src/screens/filters/Details.tsx b/web/src/screens/filters/Details.tsx
index e314b06..de7d9c8 100644
--- a/web/src/screens/filters/Details.tsx
+++ b/web/src/screens/filters/Details.tsx
@@ -221,7 +221,6 @@ const externalFilterSchema = z.object({
webhook_retry_status: z.string().optional(),
webhook_retry_attempts: z.number().optional(),
webhook_retry_delay_seconds: z.number().optional(),
- webhook_retry_max_jitter_seconds: z.number().optional(),
});
const indexerSchema = z.object({
@@ -1344,4 +1343,3 @@ export function CollapsableSection({ title, subtitle, children, defaultOpen }: C
);
}
-
diff --git a/web/src/screens/filters/External.tsx b/web/src/screens/filters/External.tsx
index 5a9f9bb..b4efe48 100644
--- a/web/src/screens/filters/External.tsx
+++ b/web/src/screens/filters/External.tsx
@@ -332,11 +332,6 @@ const TypeForm = ({ external, idx }: TypeFormProps) => {
label="Retry delay in seconds"
placeholder="1"
/>
-
);
diff --git a/web/src/screens/filters/List.tsx b/web/src/screens/filters/List.tsx
index dc0bbd7..40ee8c5 100644
--- a/web/src/screens/filters/List.tsx
+++ b/web/src/screens/filters/List.tsx
@@ -295,7 +295,6 @@ const FilterItemDropdown = ({ filter, onToggle }: FilterItemDropdownProps) => {
external_webhook_retry_status: any;
external_webhook_retry_attempts: any;
external_webhook_retry_delay_seconds: any;
- external_webhook_retry_max_jitter_seconds: any;
};
const completeFilter = await APIClient.filters.getByID(filter.id) as Partial;
@@ -320,7 +319,6 @@ const FilterItemDropdown = ({ filter, onToggle }: FilterItemDropdownProps) => {
delete completeFilter.external_webhook_retry_status;
delete completeFilter.external_webhook_retry_attempts;
delete completeFilter.external_webhook_retry_delay_seconds;
- delete completeFilter.external_webhook_retry_max_jitter_seconds;
// Remove properties with default values from the exported filter to minimize the size of the JSON string
["enabled", "priority", "smart_episode", "resolutions", "sources", "codecs", "containers", "tags_match_logic", "except_tags_match_logic"].forEach((key) => {
diff --git a/web/src/types/Filter.d.ts b/web/src/types/Filter.d.ts
index 55b4a72..4831308 100644
--- a/web/src/types/Filter.d.ts
+++ b/web/src/types/Filter.d.ts
@@ -133,6 +133,5 @@ interface ExternalFilter {
webhook_retry_status?: string,
webhook_retry_attempts?: number;
webhook_retry_delay_seconds?: number;
- webhook_retry_max_jitter_seconds?: number;
filter_id?: number;
}