aboutsummaryrefslogtreecommitdiff
path: root/syncapi/sync/request.go
diff options
context:
space:
mode:
Diffstat (limited to 'syncapi/sync/request.go')
-rw-r--r--syncapi/sync/request.go26
1 files changed, 9 insertions, 17 deletions
diff --git a/syncapi/sync/request.go b/syncapi/sync/request.go
index f2e199d2..66663cf0 100644
--- a/syncapi/sync/request.go
+++ b/syncapi/sync/request.go
@@ -36,7 +36,7 @@ type syncRequest struct {
device authtypes.Device
limit int
timeout time.Duration
- since *types.PaginationToken // nil means that no since token was supplied
+ since *types.StreamingToken // nil means that no since token was supplied
wantFullState bool
log *log.Entry
}
@@ -45,9 +45,14 @@ func newSyncRequest(req *http.Request, device authtypes.Device) (*syncRequest, e
timeout := getTimeout(req.URL.Query().Get("timeout"))
fullState := req.URL.Query().Get("full_state")
wantFullState := fullState != "" && fullState != "false"
- since, err := getPaginationToken(req.URL.Query().Get("since"))
- if err != nil {
- return nil, err
+ var since *types.StreamingToken
+ sinceStr := req.URL.Query().Get("since")
+ if sinceStr != "" {
+ tok, err := types.NewStreamTokenFromString(sinceStr)
+ if err != nil {
+ return nil, err
+ }
+ since = &tok
}
// TODO: Additional query params: set_presence, filter
return &syncRequest{
@@ -71,16 +76,3 @@ func getTimeout(timeoutMS string) time.Duration {
}
return time.Duration(i) * time.Millisecond
}
-
-// getSyncStreamPosition tries to parse a 'since' token taken from the API to a
-// types.PaginationToken. If the string is empty then (nil, nil) is returned.
-// There are two forms of tokens: The full length form containing all PDU and EDU
-// positions separated by "_", and the short form containing only the PDU
-// position. Short form can be used for, e.g., `prev_batch` tokens.
-func getPaginationToken(since string) (*types.PaginationToken, error) {
- if since == "" {
- return nil, nil
- }
-
- return types.NewPaginationTokenFromString(since)
-}