Skip to content
Snippets Groups Projects
Commit e3c8f885 authored by Réthelyi Bálint's avatar Réthelyi Bálint :no_mouth:
Browse files

Merge branch 'fix-notification' into 'main'

Fix notification daemon

See merge request !1
parents 49a03d92 75cd451d
Branches
No related tags found
1 merge request!1Fix notification daemon
Pipeline #18211 passed
......@@ -83,6 +83,8 @@ dockerhub:
changes:
- notifications/**/*
- .gitlab-ci.yml
refs:
- main
k8s:
stage: deploy
......
......@@ -15,10 +15,8 @@ var oldLaundry []model.LaundryRoom
func main() {
url := "https://mosogep.sch.bme.hu/api/v1/laundry-room/"
state := 0
for {
sendMsg(url)
state = testMsg(state)
time.Sleep(time.Second * 30)
}
......@@ -47,6 +45,7 @@ func sendMsg(url string) {
old := findOldMachine(machine.Id)
if old.Status != machine.Status {
machine.LastQueryTime = room.LastQueryTime
machine.FloorId = fmt.Sprintf("%d", room.Id)
marshal, err := json.Marshal(machine)
if err != nil {
log.Fatal(err)
......@@ -66,35 +65,3 @@ func sendMsg(url string) {
}
oldLaundry = laundryRooms
}
func testMsg(oldState int) int {
//fmt.Println("test sending...")
var state int
if oldState == 0 {
state = 1
} else {
state = 0
}
machine := model.Machine{
Id: 420,
KindOf: "DR",
Status: state,
Message: "",
LastQueryTime: time.Now(),
}
marshal, err := json.Marshal(machine)
if err != nil {
log.Fatal(err)
}
data := map[string]string{
"floor": "69",
"old_state": fmt.Sprintf("%d", oldState),
"machine": string(marshal),
}
err = firebase.Send("test", data)
if err != nil {
fmt.Println(err)
}
//fmt.Println("test sent...")
return state
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment