diff --git a/internal/pkg/core/notifier/providers/gotify/gotify.go b/internal/pkg/core/notifier/providers/gotify/gotify.go index 1ae7af76..ad0c515e 100644 --- a/internal/pkg/core/notifier/providers/gotify/gotify.go +++ b/internal/pkg/core/notifier/providers/gotify/gotify.go @@ -24,13 +24,6 @@ type NotifierConfig struct { Priority int64 `json:"priority"` } -// Message Gotify 消息体 -type Message struct { - Title string `json:"title"` - Message string `json:"message"` - Priority int64 `json:"priority"` -} - type NotifierProvider struct { config *NotifierConfig logger *slog.Logger @@ -62,7 +55,11 @@ func (n *NotifierProvider) WithLogger(logger *slog.Logger) notifier.Notifier { func (n *NotifierProvider) Notify(ctx context.Context, subject string, message string) (res *notifier.NotifyResult, err error) { // Gotify 原生实现, notify 库没有实现, 等待合并 - reqBody := &Message{ + reqBody := &struct { + Title string `json:"title"` + Message string `json:"message"` + Priority int64 `json:"priority"` + }{ Title: subject, Message: message, Priority: n.config.Priority, @@ -92,6 +89,7 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s if err != nil { return nil, errors.Wrapf(err, "send request to gotify server") } + defer resp.Body.Close() // Read response and verify success result, err := io.ReadAll(resp.Body)