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
77c81ca6
Commit
77c81ca6
authored
7 years ago
by
Erik Johnston
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2451 from matrix-org/erikj/add_state_to_timeline
Don't filter out current state events from timeline
parents
862c8da5
2d1b7955
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/handlers/sync.py
+7
-0
7 additions, 0 deletions
synapse/handlers/sync.py
synapse/visibility.py
+11
-3
11 additions, 3 deletions
synapse/visibility.py
with
18 additions
and
3 deletions
synapse/handlers/sync.py
+
7
−
0
View file @
77c81ca6
...
@@ -293,6 +293,11 @@ class SyncHandler(object):
...
@@ -293,6 +293,11 @@ class SyncHandler(object):
timeline_limit
=
sync_config
.
filter_collection
.
timeline_limit
()
timeline_limit
=
sync_config
.
filter_collection
.
timeline_limit
()
block_all_timeline
=
sync_config
.
filter_collection
.
blocks_all_room_timeline
()
block_all_timeline
=
sync_config
.
filter_collection
.
blocks_all_room_timeline
()
# Pull out the current state, as we always want to include those events
# in the timeline if they're there.
current_state_ids
=
yield
self
.
state
.
get_current_state_ids
(
room_id
)
current_state_ids
=
frozenset
(
current_state_ids
.
itervalues
())
if
recents
is
None
or
newly_joined_room
or
timeline_limit
<
len
(
recents
):
if
recents
is
None
or
newly_joined_room
or
timeline_limit
<
len
(
recents
):
limited
=
True
limited
=
True
else
:
else
:
...
@@ -304,6 +309,7 @@ class SyncHandler(object):
...
@@ -304,6 +309,7 @@ class SyncHandler(object):
self
.
store
,
self
.
store
,
sync_config
.
user
.
to_string
(),
sync_config
.
user
.
to_string
(),
recents
,
recents
,
always_include_ids
=
current_state_ids
,
)
)
else
:
else
:
recents
=
[]
recents
=
[]
...
@@ -339,6 +345,7 @@ class SyncHandler(object):
...
@@ -339,6 +345,7 @@ class SyncHandler(object):
self
.
store
,
self
.
store
,
sync_config
.
user
.
to_string
(),
sync_config
.
user
.
to_string
(),
loaded_recents
,
loaded_recents
,
always_include_ids
=
current_state_ids
,
)
)
loaded_recents
.
extend
(
recents
)
loaded_recents
.
extend
(
recents
)
recents
=
loaded_recents
recents
=
loaded_recents
...
...
This diff is collapsed.
Click to expand it.
synapse/visibility.py
+
11
−
3
View file @
77c81ca6
...
@@ -43,7 +43,8 @@ MEMBERSHIP_PRIORITY = (
...
@@ -43,7 +43,8 @@ MEMBERSHIP_PRIORITY = (
@defer.inlineCallbacks
@defer.inlineCallbacks
def
filter_events_for_clients
(
store
,
user_tuples
,
events
,
event_id_to_state
):
def
filter_events_for_clients
(
store
,
user_tuples
,
events
,
event_id_to_state
,
always_include_ids
=
frozenset
()):
"""
Returns dict of user_id -> list of events that user is allowed to
"""
Returns dict of user_id -> list of events that user is allowed to
see.
see.
...
@@ -54,6 +55,8 @@ def filter_events_for_clients(store, user_tuples, events, event_id_to_state):
...
@@ -54,6 +55,8 @@ def filter_events_for_clients(store, user_tuples, events, event_id_to_state):
* the user has not been a member of the room since the
* the user has not been a member of the room since the
given events
given events
events ([synapse.events.EventBase]): list of events to filter
events ([synapse.events.EventBase]): list of events to filter
always_include_ids (set(event_id)): set of event ids to specifically
include (unless sender is ignored)
"""
"""
forgotten
=
yield
preserve_context_over_deferred
(
defer
.
gatherResults
([
forgotten
=
yield
preserve_context_over_deferred
(
defer
.
gatherResults
([
defer
.
maybeDeferred
(
defer
.
maybeDeferred
(
...
@@ -91,6 +94,9 @@ def filter_events_for_clients(store, user_tuples, events, event_id_to_state):
...
@@ -91,6 +94,9 @@ def filter_events_for_clients(store, user_tuples, events, event_id_to_state):
if
not
event
.
is_state
()
and
event
.
sender
in
ignore_list
:
if
not
event
.
is_state
()
and
event
.
sender
in
ignore_list
:
return
False
return
False
if
event
.
event_id
in
always_include_ids
:
return
True
state
=
event_id_to_state
[
event
.
event_id
]
state
=
event_id_to_state
[
event
.
event_id
]
# get the room_visibility at the time of the event.
# get the room_visibility at the time of the event.
...
@@ -189,7 +195,8 @@ def filter_events_for_clients(store, user_tuples, events, event_id_to_state):
...
@@ -189,7 +195,8 @@ def filter_events_for_clients(store, user_tuples, events, event_id_to_state):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
filter_events_for_client
(
store
,
user_id
,
events
,
is_peeking
=
False
):
def
filter_events_for_client
(
store
,
user_id
,
events
,
is_peeking
=
False
,
always_include_ids
=
frozenset
()):
"""
"""
Check which events a user is allowed to see
Check which events a user is allowed to see
...
@@ -213,6 +220,7 @@ def filter_events_for_client(store, user_id, events, is_peeking=False):
...
@@ -213,6 +220,7 @@ def filter_events_for_client(store, user_id, events, is_peeking=False):
types
=
types
types
=
types
)
)
res
=
yield
filter_events_for_clients
(
res
=
yield
filter_events_for_clients
(
store
,
[(
user_id
,
is_peeking
)],
events
,
event_id_to_state
store
,
[(
user_id
,
is_peeking
)],
events
,
event_id_to_state
,
always_include_ids
=
always_include_ids
,
)
)
defer
.
returnValue
(
res
.
get
(
user_id
,
[]))
defer
.
returnValue
(
res
.
get
(
user_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