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) {
+1
View File
@@ -24,6 +24,7 @@ func (c *BarkChannel) Send(config ChannelConfig, msg *Message) (*Result, error)
URL: config.GetString("url"),
Key: config.GetString("key"),
IV: config.GetString("iv"),
Server: config.GetString("server"),
}
res, err := cli.Request(msg.Title, msg.Text)
+1
View File
@@ -49,6 +49,7 @@ const channelConfigFields: Record<string, { key: string; label: string; required
{ key: 'proxy_url', label: '代理地址', required: false, placeholder: 'http/https/socks5 代理' },
],
Bark: [
{ key: 'server', label: '服务地址', required: false, placeholder: '默认 https://api.day.app' },
{ key: 'push_key', label: 'Push Key', required: true, placeholder: 'Bark Push Key' },
{ key: 'sound', label: '推送声音', required: false, placeholder: '留空使用默认' },
{ key: 'group', label: '推送分组', required: false },