mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-11 20:31:08 +01:00
Fix panic when uploading keys (#1203)
We don't return OTK counts when the client doesn't upload OTKs.
This commit is contained in:
parent
84387e5249
commit
df8d6823ee
1 changed files with 6 additions and 1 deletions
|
@ -82,10 +82,15 @@ func UploadKeys(req *http.Request, keyAPI api.KeyInternalAPI, device *userapi.De
|
||||||
JSON: uploadRes.KeyErrors,
|
JSON: uploadRes.KeyErrors,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
keyCount := make(map[string]int)
|
||||||
|
// we only return key counts when the client uploads OTKs
|
||||||
|
if len(uploadRes.OneTimeKeyCounts) > 0 {
|
||||||
|
keyCount = uploadRes.OneTimeKeyCounts[0].KeyCount
|
||||||
|
}
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: 200,
|
Code: 200,
|
||||||
JSON: struct {
|
JSON: struct {
|
||||||
OTKCounts interface{} `json:"one_time_key_counts"`
|
OTKCounts interface{} `json:"one_time_key_counts"`
|
||||||
}{uploadRes.OneTimeKeyCounts[0].KeyCount},
|
}{keyCount},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue