mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 05:42:46 +00:00
parent
0dcf0a7d64
commit
3578d77d25
3 changed files with 117 additions and 29 deletions
|
@ -65,8 +65,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
|||
|
||||
currPos := rp.notifier.CurrentPosition()
|
||||
|
||||
// If this is an initial sync or timeout=0 we return immediately
|
||||
if syncReq.since == nil || syncReq.timeout == 0 {
|
||||
if shouldReturnImmediately(syncReq) {
|
||||
syncData, err = rp.currentSyncForUser(*syncReq, currPos)
|
||||
if err != nil {
|
||||
return httputil.LogThenError(req, err)
|
||||
|
@ -135,7 +134,7 @@ func (rp *RequestPool) currentSyncForUser(req syncRequest, latestPos types.SyncP
|
|||
if req.since == nil {
|
||||
res, err = rp.db.CompleteSync(req.ctx, req.device.UserID, req.limit)
|
||||
} else {
|
||||
res, err = rp.db.IncrementalSync(req.ctx, req.device, *req.since, latestPos, req.limit)
|
||||
res, err = rp.db.IncrementalSync(req.ctx, req.device, *req.since, latestPos, req.limit, req.wantFullState)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -216,3 +215,10 @@ func (rp *RequestPool) appendAccountData(
|
|||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// shouldReturnImmediately returns whether the /sync request is an initial sync,
|
||||
// or timeout=0, or full_state=true, in any of the cases the request should
|
||||
// return immediately.
|
||||
func shouldReturnImmediately(syncReq *syncRequest) bool {
|
||||
return syncReq.since == nil || syncReq.timeout == 0 || syncReq.wantFullState
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue