diff --git a/internal/sdk/message/bark.go b/internal/sdk/message/bark.go index 221ae2e..3f835c2 100644 --- a/internal/sdk/message/bark.go +++ b/internal/sdk/message/bark.go @@ -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) { diff --git a/internal/sdk/messenger/channels/bark.go b/internal/sdk/messenger/channels/bark.go index b1b0887..e5c9100 100644 --- a/internal/sdk/messenger/channels/bark.go +++ b/internal/sdk/messenger/channels/bark.go @@ -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) diff --git a/web/src/views/notify/Notify.vue b/web/src/views/notify/Notify.vue index 849031c..3b68822 100644 --- a/web/src/views/notify/Notify.vue +++ b/web/src/views/notify/Notify.vue @@ -49,6 +49,7 @@ const channelConfigFields: Record