This commit is contained in:
Magnus Åhall 2024-12-03 13:56:38 +01:00
parent ac8b334eee
commit 04c101982f
6 changed files with 98 additions and 39 deletions

View file

@ -110,7 +110,7 @@ func main() { // {{{
http.HandleFunc("/user/authenticate", AuthManager.AuthenticationHandler)
http.HandleFunc("/node/tree/{timestamp}", authenticated(actionNodeTree))
http.HandleFunc("/node/tree/{timestamp}/{offset}", authenticated(actionNodeTree))
http.HandleFunc("/node/retrieve/{id}", authenticated(actionNodeRetrieve))
http.HandleFunc("/service_worker.js", pageServiceWorker)
@ -226,8 +226,9 @@ func pageSync(w http.ResponseWriter, r *http.Request) { // {{{
func actionNodeTree(w http.ResponseWriter, r *http.Request) { // {{{
user := getUser(r)
changedFrom, _ := strconv.Atoi(r.PathValue("timestamp"))
offset, _ := strconv.Atoi(r.PathValue("offset"))
nodes, maxSeq, err := NodeTree(user.ID, uint64(changedFrom))
nodes, maxSeq, moreRowsExist, err := NodeTree(user.ID, offset, uint64(changedFrom))
if err != nil {
Log.Error("/node/tree", "error", err)
httpError(w, err)
@ -238,7 +239,8 @@ func actionNodeTree(w http.ResponseWriter, r *http.Request) { // {{{
OK bool
Nodes []TreeNode
MaxSeq uint64
}{true, nodes, maxSeq})
Continue bool
}{true, nodes, maxSeq, moreRowsExist})
Log.Debug("tree", "nodes", nodes)
w.Write(j)
} // }}}