Read push endpoint from config

This commit is contained in:
Jarno Rankinen 2024-03-27 04:13:04 +00:00
parent 1f0f33ee50
commit 6c18227d0d
1 changed files with 11 additions and 5 deletions

View File

@ -5,15 +5,16 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/0ranki/hydroxide-push/auth"
"github.com/0ranki/hydroxide-push/config"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/backend"
"log" "log"
"net" "net"
"net/http" "net/http"
"os" "os"
"strings" "strings"
"github.com/0ranki/hydroxide-push/auth"
"github.com/0ranki/hydroxide-push/config"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/backend"
) )
type NtfyConfig struct { type NtfyConfig struct {
@ -43,7 +44,12 @@ func ntfyConfigFile() (string, error) {
} }
func Notify() { func Notify() {
req, _ := http.NewRequest("POST", "https://push.oranki.net/testing20240325", strings.NewReader("New message received")) cfg := NtfyConfig{}
if err := cfg.Read(); err != nil {
log.Printf("error reading notification: %v", err)
return
}
req, _ := http.NewRequest("POST", cfg.String(), strings.NewReader("New message received"))
req.Header.Set("Title", "ProtoMail") req.Header.Set("Title", "ProtoMail")
req.Header.Set("Click", "dismiss") req.Header.Set("Click", "dismiss")
req.Header.Set("Tags", "envelope") req.Header.Set("Tags", "envelope")