Skip to content

Commit

Permalink
feat(backend): added isOffline parameter to startRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
zavorotynskiy committed Dec 20, 2023
1 parent 9a84d1d commit 7284818
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/internal/http/router/handlers-web.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func (e *Router) readBody(w http.ResponseWriter, r *http.Request, limit int64) (

func getSessionTimestamp(req *StartSessionRequest, startTimeMili int64) (ts uint64) {
ts = uint64(req.Timestamp)
if req.IsOffline {
return
}
c, err := semver.NewConstraint(">=4.1.6")
if err != nil {
return
Expand All @@ -78,7 +81,7 @@ func getSessionTimestamp(req *StartSessionRequest, startTimeMili int64) (ts uint
}
if c.Check(v) {
ts = uint64(startTimeMili)
if req.BufferDiff > 0 && req.BufferDiff < 3*60*1000 {
if req.BufferDiff > 0 && req.BufferDiff < 5*60*1000 {
ts -= req.BufferDiff
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/internal/http/router/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type StartSessionRequest struct {
UserID string `json:"userID"`
DoNotRecord bool `json:"doNotRecord"` // start record session or not
BufferDiff uint64 `json:"bufferDiff"` // buffer diff in ms for start record session
IsOffline bool `json:"isOffline"` // to indicate that we have to use user's start timestamp
}

type StartSessionResponse struct {
Expand Down

0 comments on commit 7284818

Please sign in to comment.