diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2021-07-28 10:25:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-28 10:25:45 +0100 |
commit | 9e4618000e0347741eac1279bf6c94c3b9980785 (patch) | |
tree | 8ba672b67d7a3fe599649b308f044362be37b6fe /userapi/api | |
parent | 3e01a88a0cb5b22dfa5247e855ba2f5f7c97d8c2 (diff) |
Alias key backup endpoints onto /unstable, fix key backup bugs (#1947)
* Default /unstable requests to stable endpoints if not overridden specifically with a custom route
* Rewrite URL
* Try something different
* Fix routing manually
* Fix selectLatestVersionSQL
* Don't return 0 if no backup version exists
* Log more useful error
* fix up replace keys check
* Don't enforce uniqueness on e2e_room_keys_versions_idx
Co-authored-by: kegsay <kegan@matrix.org>
Diffstat (limited to 'userapi/api')
-rw-r--r-- | userapi/api/api.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/userapi/api/api.go b/userapi/api/api.go index b0d91856..75d06dd6 100644 --- a/userapi/api/api.go +++ b/userapi/api/api.go @@ -72,13 +72,11 @@ func (a *KeyBackupSession) ShouldReplaceRoomKey(newKey *KeyBackupSession) bool { // "if the keys have different values for is_verified, then it will keep the key that has is_verified set to true" if newKey.IsVerified && !a.IsVerified { return true - } - // "if they have the same values for is_verified, then it will keep the key with a lower first_message_index" - if newKey.FirstMessageIndex < a.FirstMessageIndex { + } else if newKey.FirstMessageIndex < a.FirstMessageIndex { + // "if they have the same values for is_verified, then it will keep the key with a lower first_message_index" return true - } - // "and finally, is is_verified and first_message_index are equal, then it will keep the key with a lower forwarded_count" - if newKey.ForwardedCount < a.ForwardedCount { + } else if newKey.ForwardedCount < a.ForwardedCount { + // "and finally, is is_verified and first_message_index are equal, then it will keep the key with a lower forwarded_count" return true } return false |