From 7de9feea58e2c5808f838801615b598e520cf15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Fri, 29 Mar 2024 20:54:42 +0100 Subject: [PATCH] Restore minute-based schedule --- main.go | 6 ++---- notification/pkg.go | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index b331f2a..cb3afd6 100644 --- a/main.go +++ b/main.go @@ -175,10 +175,9 @@ func main() { // {{{ } // }}} func scheduleHandler() { // {{{ // Wait for the approximate minute. - //wait := 60000 - time.Now().Sub(time.Now().Truncate(time.Minute)).Milliseconds() - //time.Sleep(time.Millisecond * time.Duration(wait)) + wait := 60000 - time.Now().Sub(time.Now().Truncate(time.Minute)).Milliseconds() + time.Sleep(time.Millisecond * time.Duration(wait)) tick := time.NewTicker(time.Minute) - tick = time.NewTicker(time.Second*5) for { <-tick.C for _, event := range ExpiredSchedules() { @@ -761,7 +760,6 @@ func keyCounter(w http.ResponseWriter, r *http.Request, sess *session.T) { // {{ }) } // }}} - func notificationAcknowledge(w http.ResponseWriter, r *http.Request, sess *session.T) { // {{{ logger.Info("webserver", "request", "/notification/ack") var err error diff --git a/notification/pkg.go b/notification/pkg.go index 5732f31..b74a6b1 100644 --- a/notification/pkg.go +++ b/notification/pkg.go @@ -44,6 +44,7 @@ func (nm *Manager) AddService(userID int, service Service) { } func (nm *Manager) Send(userID int, uuid string, msg []byte) (err error) { + services, found := nm.services[userID] if !found { return werr.New("No notification services defined for user ID %d", userID).WithCode("002-0008")