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
c2c9a78d
Commit
c2c9a78d
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Noop device key changes if they're the same
parent
e75a779d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/handlers/e2e_keys.py
+5
-4
5 additions, 4 deletions
synapse/handlers/e2e_keys.py
synapse/storage/devices.py
+1
-0
1 addition, 0 deletions
synapse/storage/devices.py
synapse/storage/end_to_end_keys.py
+39
-11
39 additions, 11 deletions
synapse/storage/end_to_end_keys.py
with
45 additions
and
15 deletions
synapse/handlers/e2e_keys.py
+
5
−
4
View file @
c2c9a78d
...
@@ -287,11 +287,12 @@ class E2eKeysHandler(object):
...
@@ -287,11 +287,12 @@ class E2eKeysHandler(object):
device_id
,
user_id
,
time_now
device_id
,
user_id
,
time_now
)
)
# TODO: Sign the JSON with the server key
# TODO: Sign the JSON with the server key
yield
self
.
store
.
set_e2e_device_keys
(
changed
=
yield
self
.
store
.
set_e2e_device_keys
(
user_id
,
device_id
,
time_now
,
user_id
,
device_id
,
time_now
,
device_keys
,
encode_canonical_json
(
device_keys
)
)
)
yield
self
.
device_handler
.
notify_device_update
(
user_id
,
[
device_id
])
if
changed
:
# Only notify about device updates *if* the keys actually changed
yield
self
.
device_handler
.
notify_device_update
(
user_id
,
[
device_id
])
one_time_keys
=
keys
.
get
(
"
one_time_keys
"
,
None
)
one_time_keys
=
keys
.
get
(
"
one_time_keys
"
,
None
)
if
one_time_keys
:
if
one_time_keys
:
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/devices.py
+
1
−
0
View file @
c2c9a78d
...
@@ -164,6 +164,7 @@ class DeviceStore(SQLBaseStore):
...
@@ -164,6 +164,7 @@ class DeviceStore(SQLBaseStore):
keyvalues
=
{
keyvalues
=
{
"
user_id
"
:
user_id
,
"
user_id
"
:
user_id
,
},
},
desc
=
"
mark_remote_user_device_list_as_unsubscribed
"
,
)
)
def
update_remote_device_list_cache_entry
(
self
,
user_id
,
device_id
,
content
,
def
update_remote_device_list_cache_entry
(
self
,
user_id
,
device_id
,
content
,
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/end_to_end_keys.py
+
39
−
11
View file @
c2c9a78d
...
@@ -14,21 +14,49 @@
...
@@ -14,21 +14,49 @@
# limitations under the License.
# limitations under the License.
from
twisted.internet
import
defer
from
twisted.internet
import
defer
from
canonicaljson
import
encode_canonical_json
from
._base
import
SQLBaseStore
from
._base
import
SQLBaseStore
class
EndToEndKeyStore
(
SQLBaseStore
):
class
EndToEndKeyStore
(
SQLBaseStore
):
def
set_e2e_device_keys
(
self
,
user_id
,
device_id
,
time_now
,
json_bytes
):
def
set_e2e_device_keys
(
self
,
user_id
,
device_id
,
time_now
,
device_keys
):
return
self
.
_simple_upsert
(
"""
Stores device keys for a device. Returns whether there was a change
table
=
"
e2e_device_keys_json
"
,
or the keys were already in the database.
keyvalues
=
{
"""
"
user_id
"
:
user_id
,
def
_set_e2e_device_keys_txn
(
txn
):
"
device_id
"
:
device_id
,
old_key_json
=
self
.
_simple_select_one_onecol_txn
(
},
txn
,
values
=
{
table
=
"
e2e_device_keys_json
"
,
"
ts_added_ms
"
:
time_now
,
keyvalues
=
{
"
key_json
"
:
json_bytes
,
"
user_id
"
:
user_id
,
}
"
device_id
"
:
device_id
,
},
retcol
=
"
key_json
"
,
allow_none
=
True
,
)
new_key_json
=
encode_canonical_json
(
device_keys
)
if
old_key_json
==
new_key_json
:
return
False
self
.
_simple_upsert_txn
(
txn
,
table
=
"
e2e_device_keys_json
"
,
keyvalues
=
{
"
user_id
"
:
user_id
,
"
device_id
"
:
device_id
,
},
values
=
{
"
ts_added_ms
"
:
time_now
,
"
key_json
"
:
new_key_json
,
}
)
return
True
return
self
.
runInteraction
(
"
set_e2e_device_keys
"
,
_set_e2e_device_keys_txn
)
)
def
get_e2e_device_keys
(
self
,
query_list
,
include_all_devices
=
False
):
def
get_e2e_device_keys
(
self
,
query_list
,
include_all_devices
=
False
):
...
...
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