Feat/ntfy (#57)

* implement ntfy notification

* fix notification fields order

* fix schema for ntfy

---------

Co-authored-by: yusing <yusing@6uo.me>
This commit is contained in:
Yuzerion
2025-02-01 13:07:44 +08:00
committed by GitHub
parent c16a0444ca
commit 78900772bb
17 changed files with 171 additions and 44 deletions

View File

@@ -1,6 +1,7 @@
package notif
import (
"io"
"net/http"
"net/url"
"strings"
@@ -54,3 +55,15 @@ func (base *ProviderBase) GetMethod() string {
func (base *ProviderBase) GetMIMEType() string {
return "application/json"
}
func (base *ProviderBase) SetHeaders(logMsg *LogMessage, headers http.Header) {
// no-op by default
}
func (base *ProviderBase) makeRespError(resp *http.Response) error {
body, err := io.ReadAll(resp.Body)
if err == nil {
return E.Errorf("%s status %d: %s", base.Name, resp.StatusCode, body)
}
return E.Errorf("%s status %d", base.Name, resp.StatusCode)
}