mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 05:13:11 -06:00
Deduplicate transactions
This commit is contained in:
parent
5cf900428c
commit
dddc9efe3e
|
|
@ -33,13 +33,11 @@ func SendToDevice(
|
|||
eventType string, txnID *string,
|
||||
) util.JSONResponse {
|
||||
if txnID != nil {
|
||||
// Try to fetch response from transactionsCache
|
||||
if res, ok := txnCache.FetchTransaction(device.AccessToken, *txnID); ok {
|
||||
return *res
|
||||
}
|
||||
}
|
||||
|
||||
// parse the incoming http request
|
||||
var httpReq struct {
|
||||
Messages map[string]map[string]json.RawMessage `json:"messages"`
|
||||
}
|
||||
|
|
@ -59,8 +57,14 @@ func SendToDevice(
|
|||
}
|
||||
}
|
||||
|
||||
return util.JSONResponse{
|
||||
res := util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
|
||||
if txnID != nil {
|
||||
txnCache.AddTransaction(device.AccessToken, *txnID, &res)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,11 +174,9 @@ func (rp *RequestPool) currentSyncForUser(req syncRequest, latestPos types.Strea
|
|||
// This is a bit of a hack until we can do something better with the sync API
|
||||
// than this mess. If we have pending send-to-device updates then we want to
|
||||
// deliver them pretty quickly. We still want the next step to run so that the
|
||||
// sync tokens are updated properly. Set a short timeout on the next step so
|
||||
// that we return faster.
|
||||
ctx, cancel := context.WithTimeout(req.ctx, time.Second)
|
||||
defer cancel()
|
||||
req.ctx = ctx
|
||||
// sync tokens are updated properly. Set a zero timeout on the next step so
|
||||
// that we return immediately.
|
||||
req.timeout = 0
|
||||
}
|
||||
|
||||
// TODO: handle ignored users
|
||||
|
|
|
|||
Loading…
Reference in a new issue