From c2555a1d3544c363b7a1015da7bcee9c3d5540e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Fri, 29 Mar 2024 08:06:23 +0100 Subject: [PATCH] Added files --- notification/ntfy.go | 26 ++++++++++++++++++++++++++ notification/pkg.go | 5 +++++ schedule.go | 2 ++ 3 files changed, 33 insertions(+) create mode 100644 notification/ntfy.go create mode 100644 notification/pkg.go diff --git a/notification/ntfy.go b/notification/ntfy.go new file mode 100644 index 0000000..d6fd2f2 --- /dev/null +++ b/notification/ntfy.go @@ -0,0 +1,26 @@ +package notification + +import ( + // Standard + "bytes" + "encoding/json" + "net/http" +) + +type NTFY struct { + URL string +} + +func NewNTFY(config []byte) (instance NTFY, err error) { + err = json.Unmarshal(config, &instance) + if err != nil { + return + } + return instance, nil +} + +func (ntfy NTFY) Send(msg []byte) (err error) { + http.NewRequest("POST", ntfy.URL, bytes.NewReader(msg)) + + return +} diff --git a/notification/pkg.go b/notification/pkg.go new file mode 100644 index 0000000..194d88a --- /dev/null +++ b/notification/pkg.go @@ -0,0 +1,5 @@ +package notification + +type Notification interface { + Send([]byte) error +} diff --git a/schedule.go b/schedule.go index d2c7aec..cfb0406 100644 --- a/schedule.go +++ b/schedule.go @@ -126,6 +126,7 @@ func RetrieveSchedules(userID int, nodeID int) (schedules []Schedule, err error) func ExpiredSchedules() []Schedule { schedules := []Schedule{} + /* res, err := service.Db.Conn.Query(` SELECT * @@ -136,5 +137,6 @@ func ExpiredSchedules() []Schedule { ORDER BY time ASC `) + */ return schedules }