MCPcopy
hub / github.com/dnote/dnote / GetSyncState

Method GetSyncState

pkg/server/controllers/sync.go:293–313  ·  view source on GitHub ↗

GetSyncState responds with a sync fragment

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

291
292// GetSyncState responds with a sync fragment
293func (s *Sync) GetSyncState(w http.ResponseWriter, r *http.Request) {
294 user := context.User(r.Context())
295 if user == nil {
296 middleware.DoError(w, "No authenticated user found", nil, http.StatusInternalServerError)
297 return
298 }
299
300 response := GetSyncStateResp{
301 FullSyncBefore: int(user.FullSyncBefore),
302 MaxUSN: user.MaxUSN,
303 // TODO: exposing server time means we probably shouldn't seed random generator with time?
304 CurrentTime: s.app.Clock.Now().Unix(),
305 }
306
307 log.WithFields(log.Fields{
308 "user_id": user.ID,
309 "resp": response,
310 }).Info("getting sync state")
311
312 respondJSON(w, http.StatusOK, response)
313}

Callers

nothing calls this directly

Calls 6

UserFunction · 0.92
DoErrorFunction · 0.92
WithFieldsFunction · 0.92
respondJSONFunction · 0.85
InfoMethod · 0.80
NowMethod · 0.65

Tested by

no test coverage detected