refactor: minor styling fixes; deadcode cleanup and correct log level

This commit is contained in:
yusing
2026-02-15 20:01:36 +08:00
parent 35b8a60edb
commit 154149b06d
29 changed files with 88 additions and 67 deletions

View File

@@ -2,6 +2,7 @@ package notif
import (
"errors"
"fmt"
"io"
"net/http"
"net/url"
@@ -49,7 +50,7 @@ func (base *ProviderBase) Validate() error {
}
u, err := url.Parse(base.URL)
if err != nil {
return err
return fmt.Errorf("invalid url: %w", err)
}
base.URL = u.String()
return nil

View File

@@ -44,14 +44,13 @@ func (webhook *Webhook) Validate() error {
switch webhook.Template {
case "":
if webhook.MIMEType == MimeTypeJSON {
if webhook.Payload == "" {
errs.Adds("invalid payload, expect non-empty")
} else if webhook.MIMEType == MimeTypeJSON {
if !validateJSONPayload(webhook.Payload) {
errs.Adds("invalid payload, expect valid JSON")
}
}
if webhook.Payload == "" {
errs.Adds("invalid payload, expect non-empty")
}
case "discord":
webhook.ColorMode = "dec"
webhook.Method = http.MethodPost