chore: add bark custom server #83

This commit is contained in:
duorameng
2026-04-14 21:55:58 +08:00
parent 3521ca9d17
commit 8e12d15634
3 changed files with 14 additions and 2 deletions
+12 -2
View File
@@ -27,6 +27,7 @@ type Bark struct {
URL string
Key string
IV string
Server string
}
func (b *Bark) Request(title, content string) ([]byte, error) {
@@ -73,7 +74,11 @@ func (b *Bark) Request(title, content string) ([]byte, error) {
}
// When using encryption, use the push endpoint if PushKey is just a key
if !strings.HasPrefix(b.PushKey, "http") {
url = "https://api.day.app/push"
server := b.Server
if server == "" {
server = "https://api.day.app"
}
url = strings.TrimSuffix(server, "/") + "/push"
}
} else {
// Normal request
@@ -113,7 +118,12 @@ func (b *Bark) getURL() string {
if strings.HasPrefix(pushKey, "http") {
return pushKey
}
return fmt.Sprintf("https://api.day.app/%s", pushKey)
server := b.Server
if server == "" {
server = "https://api.day.app"
}
server = strings.TrimSuffix(server, "/")
return fmt.Sprintf("%s/%s", server, pushKey)
}
func (b *Bark) encryptPayload(payload string) (string, error) {