add clickable notification
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user