Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
bd84387a
Commit
bd84387a
authored
8 years ago
by
Erik Johnston
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1869 from matrix-org/erikj/device_list_stream
Implement /keys/changes
parents
ebfaff84
73d676dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/handlers/device.py
+16
-0
16 additions, 0 deletions
synapse/handlers/device.py
synapse/rest/client/v2_alpha/keys.py
+49
-0
49 additions, 0 deletions
synapse/rest/client/v2_alpha/keys.py
with
65 additions
and
0 deletions
synapse/handlers/device.py
+
16
−
0
View file @
bd84387a
...
...
@@ -220,6 +220,22 @@ class DeviceHandler(BaseHandler):
for
host
in
hosts
:
self
.
federation_sender
.
send_device_messages
(
host
)
@defer.inlineCallbacks
def
get_user_ids_changed
(
self
,
user_id
,
from_device_key
):
rooms
=
yield
self
.
store
.
get_rooms_for_user
(
user_id
)
room_ids
=
set
(
r
.
room_id
for
r
in
rooms
)
user_ids_changed
=
set
()
changed
=
yield
self
.
store
.
get_user_whose_devices_changed
(
from_device_key
)
for
other_user_id
in
changed
:
other_rooms
=
yield
self
.
store
.
get_rooms_for_user
(
other_user_id
)
if
room_ids
.
intersection
(
e
.
room_id
for
e
in
other_rooms
):
user_ids_changed
.
add
(
other_user_id
)
defer
.
returnValue
(
user_ids_changed
)
@defer.inlineCallbacks
def
_incoming_device_list_update
(
self
,
origin
,
edu_content
):
user_id
=
edu_content
[
"
user_id
"
]
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/client/v2_alpha/keys.py
+
49
−
0
View file @
bd84387a
...
...
@@ -21,6 +21,8 @@ from synapse.api.errors import SynapseError
from
synapse.http.servlet
import
(
RestServlet
,
parse_json_object_from_request
,
parse_integer
)
from
synapse.http.servlet
import
parse_string
from
synapse.types
import
StreamToken
from
._base
import
client_v2_patterns
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -149,6 +151,52 @@ class KeyQueryServlet(RestServlet):
defer
.
returnValue
((
200
,
result
))
class
KeyChangesServlet
(
RestServlet
):
"""
Returns the list of changes of keys between two stream tokens (may return
spurious extra results, since we currently ignore the `to` param).
GET /keys/changes?from=...&to=...
200 OK
{
"
changed
"
: [
"
@foo:example.com
"
] }
"""
PATTERNS
=
client_v2_patterns
(
"
/keys/changes$
"
,
releases
=
()
)
def
__init__
(
self
,
hs
):
"""
Args:
hs (synapse.server.HomeServer):
"""
super
(
KeyChangesServlet
,
self
).
__init__
()
self
.
auth
=
hs
.
get_auth
()
self
.
device_handler
=
hs
.
get_device_handler
()
@defer.inlineCallbacks
def
on_GET
(
self
,
request
):
requester
=
yield
self
.
auth
.
get_user_by_req
(
request
,
allow_guest
=
True
)
from_token_string
=
parse_string
(
request
,
"
from
"
)
# We want to enforce they do pass us one, but we ignore it and return
# changes after the "to" as well as before.
parse_string
(
request
,
"
to
"
)
from_token
=
StreamToken
.
from_string
(
from_token_string
)
user_id
=
requester
.
user
.
to_string
()
changed
=
yield
self
.
device_handler
.
get_user_ids_changed
(
user_id
,
from_token
.
device_list_key
,
)
defer
.
returnValue
((
200
,
{
"
changed
"
:
changed
}))
class
OneTimeKeyServlet
(
RestServlet
):
"""
POST /keys/claim HTTP/1.1
...
...
@@ -192,4 +240,5 @@ class OneTimeKeyServlet(RestServlet):
def
register_servlets
(
hs
,
http_server
):
KeyUploadServlet
(
hs
).
register
(
http_server
)
KeyQueryServlet
(
hs
).
register
(
http_server
)
KeyChangesServlet
(
hs
).
register
(
http_server
)
OneTimeKeyServlet
(
hs
).
register
(
http_server
)
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