fix(notif): use markdown format if invalid

This commit is contained in:
yusing
2025-09-10 22:57:54 +08:00
parent 226ee2e5e5
commit c9c5677b35
2 changed files with 2 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ var (
// Validate implements the utils.CustomValidator interface.
func (base *ProviderBase) Validate() gperr.Error {
if base.Format == nil {
if base.Format == nil || base.Format.string == "" {
base.Format = LogFormatMarkdown
}
if !strings.HasPrefix(base.URL, "http://") && !strings.HasPrefix(base.URL, "https://") {

View File

@@ -3,7 +3,6 @@ package notif
import (
"bytes"
"encoding/json"
"fmt"
"strings"
"github.com/yusing/go-proxy/internal/gperr"
@@ -126,5 +125,5 @@ func (e ErrorBody) Format(format *LogFormat) ([]byte, error) {
case LogFormatMarkdown:
return gperr.Markdown(e.Error), nil
}
return nil, fmt.Errorf("unknown format: %v", format)
return gperr.Markdown(e.Error), nil
}