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
365a1867
Commit
365a1867
authored
10 years ago
by
Mark Haines
Browse files
Options
Downloads
Patches
Plain Diff
Add basic filtering support
parent
7ceda8bf
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
+14
-5
14 additions, 5 deletions
synapse/rest/client/v2_alpha/sync.py
with
14 additions
and
5 deletions
synapse/rest/client/v2_alpha/sync.py
+
14
−
5
View file @
365a1867
...
...
@@ -21,6 +21,7 @@ from synapse.types import StreamToken
from
synapse.events.utils
import
(
serialize_event
,
format_event_for_client_v2_without_event_id
,
)
from
synapse.api.filtering
import
Filter
from
._base
import
client_v2_pattern
import
logging
...
...
@@ -80,6 +81,7 @@ class SyncRestServlet(RestServlet):
self
.
auth
=
hs
.
get_auth
()
self
.
sync_handler
=
hs
.
get_handlers
().
sync_handler
self
.
clock
=
hs
.
get_clock
()
self
.
filtering
=
hs
.
get_filtering
()
@defer.inlineCallbacks
def
on_GET
(
self
,
request
):
...
...
@@ -109,9 +111,14 @@ class SyncRestServlet(RestServlet):
)
# TODO(mjark): Load filter and apply overrides.
# filter = self.filters.load_fitler(filter_id_str)
try
:
filter
=
yield
self
.
filtering
.
get_user_filter
(
user
.
localpart
,
filter_id
)
except
:
filter
=
Filter
({})
# filter = filter.apply_overrides(http_request)
#
if filter.matches(event):
#if filter.matches(event):
# # stuff
sync_config
=
SyncConfig
(
...
...
@@ -121,7 +128,7 @@ class SyncRestServlet(RestServlet):
limit
=
limit
,
sort
=
sort
,
backfill
=
backfill
,
filter
=
"
TODO
"
,
# TODO(mjark) Add the filter to the config.
filter
=
filter
,
)
if
since
is
not
None
:
...
...
@@ -162,9 +169,11 @@ class SyncRestServlet(RestServlet):
@staticmethod
def
encode_room
(
room
,
filter
,
time_now
,
token_id
):
event_map
=
{}
state_events
=
filter
.
filter_room_state
(
room
.
state
)
recent_events
=
filter
.
filter_room_events
(
room
.
events
)
state_event_ids
=
[]
recent_event_ids
=
[]
for
event
in
room
.
state
:
for
event
in
state
_events
:
# TODO(mjark): Respect formatting requirements in the filter.
event_map
[
event
.
event_id
]
=
serialize_event
(
event
,
time_now
,
token_id
=
token_id
,
...
...
@@ -172,7 +181,7 @@ class SyncRestServlet(RestServlet):
)
state_event_ids
.
append
(
event
.
event_id
)
for
event
in
r
oom
.
events
:
for
event
in
r
ecent_
events
:
# TODO(mjark): Respect formatting requirements in the filter.
event_map
[
event
.
event_id
]
=
serialize_event
(
event
,
time_now
,
token_id
=
token_id
,
...
...
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