Fixed CORS

This commit is contained in:
Magnus Åhall 2024-03-30 17:58:51 +01:00
parent 6782362af1
commit 90b73edc34

View File

@ -176,10 +176,10 @@ func main() { // {{{
func scheduleHandler() { // {{{
// Wait for the approximate minute.
wait := 60000 - time.Now().Sub(time.Now().Truncate(time.Minute)).Milliseconds()
logger.Info("schedule", "wait", wait/1000)
time.Sleep(time.Millisecond * time.Duration(wait))
tick := time.NewTicker(time.Minute)
for {
<-tick.C
for _, event := range ExpiredSchedules() {
notificationManager.Send(
event.UserID,
@ -193,6 +193,7 @@ func scheduleHandler() { // {{{
),
)
}
<-tick.C
}
} // }}}
@ -764,7 +765,7 @@ 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
w.Header().Add("Access-Control-Allow-Origin", "*")
err = AcknowledgeNotification(r.URL.Query().Get("uuid"))
if err != nil {
@ -776,4 +777,5 @@ func notificationAcknowledge(w http.ResponseWriter, r *http.Request, sess *sessi
"OK": true,
})
} // }}}
// vim: foldmethod=marker