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
e4bfe50e
Commit
e4bfe50e
authored
9 years ago
by
Mark Haines
Committed by
review.rocks
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow filter JSON object in the filter query parameter in /sync
Documented by matrix-org/matrix-doc#224
parent
0f826b0b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/rest/client/v2_alpha/sync.py
+21
-9
21 additions, 9 deletions
synapse/rest/client/v2_alpha/sync.py
with
21 additions
and
9 deletions
synapse/rest/client/v2_alpha/sync.py
+
21
−
9
View file @
e4bfe50e
...
...
@@ -25,11 +25,14 @@ from synapse.events.utils import (
serialize_event
,
format_event_for_client_v2_without_room_id
,
)
from
synapse.api.filtering
import
FilterCollection
from
synapse.api.errors
import
SynapseError
from
._base
import
client_v2_patterns
import
copy
import
logging
import
ujson
as
json
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -48,7 +51,7 @@ class SyncRestServlet(RestServlet):
"
next_batch
"
: // batch token for the next /sync
"
presence
"
: // presence data for the user.
"
rooms
"
: {
"
join
ed
"
: { // Joined rooms being updated.
"
join
"
: { // Joined rooms being updated.
"
${room_id}
"
: { // Id of the room being updated
"
event_map
"
: // Map of EventID -> event JSON.
"
timeline
"
: { // The recent events in the room if gap is
"
true
"
...
...
@@ -63,8 +66,8 @@ class SyncRestServlet(RestServlet):
"
ephemeral
"
: {
"
events
"
: []} // list of event objects
}
},
"
invite
d
"
: {}, // Invited rooms being updated.
"
archi
ve
d
"
: {} // Archived rooms being updated.
"
invite
"
: {}, // Invited rooms being updated.
"
lea
ve
"
: {} // Archived rooms being updated.
}
}
"""
...
...
@@ -100,12 +103,21 @@ class SyncRestServlet(RestServlet):
)
)
try
:
filter
=
yield
self
.
filtering
.
get_user_filter
(
user
.
localpart
,
filter_id
)
except
:
filter
=
FilterCollection
({})
if
filter_id
and
filter_id
.
startswith
(
'
{
'
):
logging
.
error
(
"
MJH %r
"
,
filter_id
)
try
:
filter_object
=
json
.
loads
(
filter_id
)
except
:
raise
SynapseError
(
400
,
"
Invalid filter JSON
"
)
self
.
filtering
.
_check_valid_filter
(
filter_object
)
filter
=
FilterCollection
(
filter_object
)
else
:
try
:
filter
=
yield
self
.
filtering
.
get_user_filter
(
user
.
localpart
,
filter_id
)
except
:
filter
=
FilterCollection
({})
sync_config
=
SyncConfig
(
user
=
user
,
...
...
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