Clean queue after sending

This commit is contained in:
Magnus Åhall 2025-01-12 16:54:21 +01:00
parent 1c3116d9dc
commit dfd6260a7a
3 changed files with 49 additions and 16 deletions

View file

@ -299,19 +299,18 @@ func actionNodeRetrieve(w http.ResponseWriter, r *http.Request) { // {{{
func actionSyncToServer(w http.ResponseWriter, r *http.Request) { // {{{
user := getUser(r)
body, _ := r.GetBody()
data, _ := io.ReadAll(body)
body, _ := io.ReadAll(r.Body)
var request struct {
ClientUUID string
NodeData string
}
err := json.Unmarshal(data, &request)
err := json.Unmarshal(body, &request)
if err != nil {
httpError(w, err)
return
}
db.Exec(`CALL add_nodes(%d, %s::jsonb)`, user.ID, request.ClientUUID, request.NodeData)
db.Exec(`CALL add_nodes($1, $2, $3::jsonb)`, user.ID, request.ClientUUID, request.NodeData)
responseData(w, map[string]interface{}{
"OK": true,