Fix linter warnings

This commit is contained in:
Thorben Günther 2024-11-06 15:09:49 +01:00
parent dbe860e429
commit 9b9d71d648
No known key found for this signature in database
GPG key ID: 415CD778D8C5AFED

10
main.go
View file

@ -33,7 +33,7 @@ import (
var version = "dev"
var MAX_NTFY_ACTIONS = 3
var maxNTFYActions = 3
type bridge struct {
cfg *config.Config
@ -362,18 +362,18 @@ func (br *bridge) publish(n *notification) error {
}
nActions := len(actions)
if nActions > MAX_NTFY_ACTIONS {
br.logger.Warn(fmt.Sprintf("Publish: Too many actions (%d), ntfy only supports up to %d - removing surplus actions.", nActions, MAX_NTFY_ACTIONS))
if nActions > maxNTFYActions {
br.logger.Warn(fmt.Sprintf("Publish: Too many actions (%d), ntfy only supports up to %d - removing surplus actions.", nActions, maxNTFYActions))
br.logger.Debug("Action list",
slog.Any("actions", actions))
actions = actions[:MAX_NTFY_ACTIONS]
actions = actions[:maxNTFYActions]
}
req.Header.Set("Actions", strings.Join(actions, ";"))
configFingerprint := br.cfg.Ntfy.CertFingerprint
if configFingerprint != "" {
tlsCfg := &tls.Config{}
tlsCfg.VerifyPeerCertificate = func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
tlsCfg.VerifyPeerCertificate = func(rawCerts [][]byte, _ [][]*x509.Certificate) error {
for _, rawCert := range rawCerts {
hash := sha512.Sum512(rawCert)
if hex.EncodeToString(hash[:]) == configFingerprint {