Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
83e72bb2
Commit
83e72bb2
authored
6 years ago
by
David Baker
Browse files
Options
Downloads
Patches
Plain Diff
PR feedback pt. 1
parent
b8d9e108
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/api/errors.py
+0
-8
0 additions, 8 deletions
synapse/api/errors.py
synapse/handlers/e2e_room_keys.py
+21
-20
21 additions, 20 deletions
synapse/handlers/e2e_room_keys.py
synapse/rest/client/v2_alpha/room_keys.py
+1
-1
1 addition, 1 deletion
synapse/rest/client/v2_alpha/room_keys.py
with
22 additions
and
29 deletions
synapse/api/errors.py
+
0
−
8
View file @
83e72bb2
...
...
@@ -348,14 +348,6 @@ class IncompatibleRoomVersionError(SynapseError):
)
def
cs_exception
(
exception
):
if
isinstance
(
exception
,
CodeMessageException
):
return
exception
.
error_dict
()
else
:
logger
.
error
(
"
Unknown exception type: %s
"
,
type
(
exception
))
return
{}
def
cs_error
(
msg
,
code
=
Codes
.
UNKNOWN
,
**
kwargs
):
"""
Utility method for constructing an error response for client-server
interactions.
...
...
This diff is collapsed.
Click to expand it.
synapse/handlers/e2e_room_keys.py
+
21
−
20
View file @
83e72bb2
# -*- coding: utf-8 -*-
# Copyright 2017 New Vector Ltd
# Copyright 2017
, 2018
New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -49,6 +49,11 @@ class E2eRoomKeysHandler(object):
room, or a given session.
See EndToEndRoomKeyStore.get_e2e_room_keys for full details.
Args:
user_id(str): the user whose keys we
'
re getting
version(str): the version ID of the backup we
'
re getting keys from
room_id(string): room ID to get keys for, for None to get keys for all rooms
session_id(string): session ID to get keys for, for None to get keys for all sessions
Returns:
A deferred list of dicts giving the session_data and message metadata for
these room keys.
...
...
@@ -72,6 +77,11 @@ class E2eRoomKeysHandler(object):
room or a given session.
See EndToEndRoomKeyStore.delete_e2e_room_keys for full details.
Args:
user_id(str): the user whose backup we
'
re deleting
version(str): the version ID of the backup we
'
re deleting
room_id(string): room ID to delete keys for, for None to delete keys for all rooms
session_id(string): session ID to delete keys for, for None to delete keys for all sessions
Returns:
A deferred of the deletion transaction
"""
...
...
@@ -118,24 +128,24 @@ class E2eRoomKeysHandler(object):
# Check that the version we're trying to upload is the current version
try
:
version_info
=
yield
self
.
_get
_version_info
_unlocked
(
user_id
)
version_info
=
yield
self
.
store
.
get_e2e_room_keys
_version_info
(
user_id
)
except
StoreError
as
e
:
if
e
.
code
==
404
:
raise
SynapseError
(
404
,
"
Version
'
%s
'
not found
"
%
(
version
,))
else
:
raise
e
raise
if
version_info
[
'
version
'
]
!=
version
:
# Check that the version we're trying to upload actually exists
try
:
version_info
=
yield
self
.
_get
_version_info
_unlocked
(
user_id
,
version
)
version_info
=
yield
self
.
store
.
get_e2e_room_keys
_version_info
(
user_id
,
version
)
# if we get this far, the version must exist
raise
RoomKeysVersionError
(
current_version
=
version_info
[
'
version
'
])
except
StoreError
as
e
:
if
e
.
code
==
404
:
raise
SynapseError
(
404
,
"
Version
'
%s
'
not found
"
%
(
version
,))
else
:
raise
e
raise
# go through the room_keys.
# XXX: this should/could be done concurrently, given we're in a lock.
...
...
@@ -168,9 +178,9 @@ class E2eRoomKeysHandler(object):
if
e
.
code
==
404
:
pass
else
:
raise
e
raise
if
E2eRoomKeysHandler
.
_should_replace_room_key
(
current_room_key
,
room_key
):
if
self
.
_should_replace_room_key
(
current_room_key
,
room_key
):
yield
self
.
store
.
set_e2e_room_key
(
user_id
,
version
,
room_id
,
session_id
,
room_key
)
...
...
@@ -195,14 +205,14 @@ class E2eRoomKeysHandler(object):
# purely for legibility.
if
room_key
[
'
is_verified
'
]
and
not
current_room_key
[
'
is_verified
'
]:
pass
return
True
elif
(
room_key
[
'
first_message_index
'
]
<
current_room_key
[
'
first_message_index
'
]
):
pass
return
True
elif
room_key
[
'
forwarded_count
'
]
<
current_room_key
[
'
forwarded_count
'
]:
pass
return
True
else
:
return
False
return
True
...
...
@@ -256,18 +266,9 @@ class E2eRoomKeysHandler(object):
"""
with
(
yield
self
.
_upload_linearizer
.
queue
(
user_id
)):
res
=
yield
self
.
_get
_version_info
_unlocked
(
user_id
,
version
)
res
=
yield
self
.
store
.
get_e2e_room_keys
_version_info
(
user_id
,
version
)
defer
.
returnValue
(
res
)
@defer.inlineCallbacks
def
_get_version_info_unlocked
(
self
,
user_id
,
version
=
None
):
"""
Get the info about a given version of the user
'
s backup
without obtaining the upload_linearizer lock. For params see get_version_info
"""
results
=
yield
self
.
store
.
get_e2e_room_keys_version_info
(
user_id
,
version
)
defer
.
returnValue
(
results
)
@defer.inlineCallbacks
def
delete_version
(
self
,
user_id
,
version
=
None
):
"""
Deletes a given version of the user
'
s e2e_room_keys backup
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/client/v2_alpha/room_keys.py
+
1
−
1
View file @
83e72bb2
# -*- coding: utf-8 -*-
# Copyright 2017 New Vector Ltd
# Copyright 2017
, 2018
New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment