🐛 Fixes server requests
All checks were successful
Gitea Build Action / build-go (push) Successful in 27s
Gitea Build Action / build-nuxt (push) Successful in 10m40s

This commit is contained in:
Daniel Svitan
2025-06-07 15:49:34 +02:00
parent cf35326bf2
commit 53722bdf18
4 changed files with 25 additions and 18 deletions

View File

@@ -23,14 +23,14 @@ const TimeFormat = "2006-01-02 15:04:05"
var token string
// the condition is: distance >= threshold (is door open)
var opened bool
var opened = false
var openedChange = make(chan any)
// is door locked
var locked bool = false
var locked = false
// alerts the user when door locked and but open?
var alerts bool = false
var alerts = false
var gotifyToken string
var gotifyURL string

View File

@@ -79,7 +79,9 @@ func setOpened(c echo.Context) error {
go sendAlert(action)
}
openedChange <- 0
go func() {
openedChange <- 0
}()
mut.Unlock()
return c.NoContent(http.StatusOK)
}
@@ -126,6 +128,7 @@ func setAlerts(c echo.Context) error {
}
if data.For > 0 {
log.Infof("pausing alerts for %d seconds", data.For)
go func() {
time.Sleep(time.Duration(data.For) * time.Second)