add clickable notification

This commit is contained in:
2026-04-10 10:14:19 +02:00
parent 0ce248b2f9
commit 8ae5dfc483
4 changed files with 18 additions and 5 deletions

View File

@@ -3,11 +3,12 @@ package notify
import (
"fmt"
"net/http"
"os"
"strings"
"time"
)
func Publish(ntfyURL, topic, title, message string) error {
func Publish(ntfyURL, topic, title, message string, clickUrl string) error {
ntfyURL = strings.TrimRight(ntfyURL, "/")
if ntfyURL == "" || topic == "" {
return nil // nothing configured
@@ -21,6 +22,8 @@ func Publish(ntfyURL, topic, title, message string) error {
req.Header.Set("Title", title)
}
req.Header.Set("Content-Type", "text/plain; charset=utf-8")
domain := os.Getenv("DOMAIN")
req.Header.Set("Click", fmt.Sprintf("%s%s", domain, clickUrl))
client := &http.Client{Timeout: 3 * time.Second}
res, err := client.Do(req)