History fetching from server

This commit is contained in:
Magnus Åhall 2026-06-06 20:21:11 +02:00
parent 9506b89453
commit aeca9d8559
4 changed files with 149 additions and 65 deletions

20
main.go
View file

@ -25,7 +25,7 @@ import (
const VERSION = "v11"
const CONTEXT_USER = 1
const SYNC_PAGINATION = 20
const SYNC_PAGINATION = 200
var (
FlagGenerate bool
@ -141,6 +141,7 @@ func main() { // {{{
http.HandleFunc("/node/retrieve/{uuid}", authenticated(actionNodeRetrieve))
http.HandleFunc("/node/history/retrieve/{uuid}/{offset}", authenticated(actionNodeHistoryRetrieve))
http.HandleFunc("/node/history/count/{uuid}", authenticated(actionNodeHistoryCount))
http.HandleFunc("/service_worker.js", pageServiceWorker)
@ -352,6 +353,23 @@ func actionNodeHistoryRetrieve(w http.ResponseWriter, r *http.Request) { // {{{
"HasMore": hasMore,
})
} // }}}
func actionNodeHistoryCount(w http.ResponseWriter, r *http.Request) { // {{{
user := getUser(r)
var err error
uuid := r.PathValue("uuid")
count, err := RetrieveNodeHistoryCount(user.UserID, uuid)
if err != nil {
responseError(w, err)
return
}
responseData(w, map[string]any{
"OK": true,
"Count": count,
})
} // }}}
func actionSyncToServer(w http.ResponseWriter, r *http.Request) { // {{{
user := getUser(r)