Add support for notification dry run feature
- Introduced NOTIFICATION_DRY_RUN configuration option in .env.example and k8s/secret.example.yaml. - Updated README.md to include usage instructions for the new dry run feature. - Implemented logic in app.go to preview notifications without sending them when the dry run option is enabled. - Enhanced config.go to load the new configuration option and validate notification types accordingly. - Added a new function in notify.go to generate manual-needed notification messages for preview.
This commit is contained in:
@@ -7,11 +7,14 @@ import (
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"ncore-hnr/internal/model"
|
||||
)
|
||||
|
||||
var releaseSeparator = regexp.MustCompile(`[._\-\[\]()+]+`)
|
||||
|
||||
type Client struct {
|
||||
baseURL string
|
||||
httpClient *http.Client
|
||||
@@ -87,7 +90,8 @@ func MatchByName(ncoreName string, torrents []model.QBitTorrent) (model.QBitTorr
|
||||
|
||||
normalized := normalizeName(ncoreName)
|
||||
for _, torrent := range torrents {
|
||||
if normalizeName(torrent.Name) == normalized {
|
||||
torrentName := normalizeName(torrent.Name)
|
||||
if torrentName == normalized || strings.HasPrefix(torrentName, normalized+" ") {
|
||||
return torrent, true
|
||||
}
|
||||
}
|
||||
@@ -112,5 +116,6 @@ func (c *Client) endpoint(path string) string {
|
||||
}
|
||||
|
||||
func normalizeName(value string) string {
|
||||
value = releaseSeparator.ReplaceAllString(value, " ")
|
||||
return strings.ToLower(strings.Join(strings.Fields(value), " "))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user