mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 21:33:19 -06:00
Deduplicate transactions
This commit is contained in:
parent
5cf900428c
commit
dddc9efe3e
|
|
@ -33,13 +33,11 @@ func SendToDevice(
|
||||||
eventType string, txnID *string,
|
eventType string, txnID *string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if txnID != nil {
|
if txnID != nil {
|
||||||
// Try to fetch response from transactionsCache
|
|
||||||
if res, ok := txnCache.FetchTransaction(device.AccessToken, *txnID); ok {
|
if res, ok := txnCache.FetchTransaction(device.AccessToken, *txnID); ok {
|
||||||
return *res
|
return *res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the incoming http request
|
|
||||||
var httpReq struct {
|
var httpReq struct {
|
||||||
Messages map[string]map[string]json.RawMessage `json:"messages"`
|
Messages map[string]map[string]json.RawMessage `json:"messages"`
|
||||||
}
|
}
|
||||||
|
|
@ -59,8 +57,14 @@ func SendToDevice(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return util.JSONResponse{
|
res := util.JSONResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
JSON: struct{}{},
|
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
|
// 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
|
// 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
|
// 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
|
// sync tokens are updated properly. Set a zero timeout on the next step so
|
||||||
// that we return faster.
|
// that we return immediately.
|
||||||
ctx, cancel := context.WithTimeout(req.ctx, time.Second)
|
req.timeout = 0
|
||||||
defer cancel()
|
|
||||||
req.ctx = ctx
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle ignored users
|
// TODO: handle ignored users
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue