🐛 Fixes server requests
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user