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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
8fe39a03
Commit
8fe39a03
authored
10 years ago
by
Mark Haines
Browse files
Options
Downloads
Patches
Plain Diff
Check if the user has joined the room between incremental syncs
parent
4a67834b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/sync.py
+27
-4
27 additions, 4 deletions
synapse/handlers/sync.py
with
27 additions
and
4 deletions
synapse/handlers/sync.py
+
27
−
4
View file @
8fe39a03
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
from
._base
import
BaseHandler
from
._base
import
BaseHandler
from
synapse.streams.config
import
PaginationConfig
from
synapse.streams.config
import
PaginationConfig
from
synapse.api.constants
import
Membership
from
synapse.api.constants
import
Membership
,
EventTypes
from
twisted.internet
import
defer
from
twisted.internet
import
defer
...
@@ -250,6 +250,11 @@ class SyncHandler(BaseHandler):
...
@@ -250,6 +250,11 @@ class SyncHandler(BaseHandler):
)
)
else
:
else
:
prev_batch
=
now_token
prev_batch
=
now_token
state
=
yield
self
.
check_joined_room
(
sync_config
,
room_id
,
state
)
room_sync
=
RoomSyncResult
(
room_sync
=
RoomSyncResult
(
room_id
=
room_id
,
room_id
=
room_id
,
published
=
room_id
in
published_room_ids
,
published
=
room_id
in
published_room_ids
,
...
@@ -323,8 +328,6 @@ class SyncHandler(BaseHandler):
...
@@ -323,8 +328,6 @@ class SyncHandler(BaseHandler):
A Deferred RoomSyncResult
A Deferred RoomSyncResult
"""
"""
# TODO(mjark): Check if they have joined the room between
# the previous sync and this one.
# TODO(mjark): Check for redactions we might have missed.
# TODO(mjark): Check for redactions we might have missed.
recents
,
prev_batch_token
,
limited
=
yield
self
.
load_filtered_recents
(
recents
,
prev_batch_token
,
limited
=
yield
self
.
load_filtered_recents
(
...
@@ -349,6 +352,10 @@ class SyncHandler(BaseHandler):
...
@@ -349,6 +352,10 @@ class SyncHandler(BaseHandler):
current_state
=
current_state_events
,
current_state
=
current_state_events
,
)
)
state_events_delta
=
yield
self
.
check_joined_room
(
sync_config
,
room_id
,
state_events_delta
)
room_sync
=
RoomSyncResult
(
room_sync
=
RoomSyncResult
(
room_id
=
room_id
,
room_id
=
room_id
,
published
=
room_id
in
published_room_ids
,
published
=
room_id
in
published_room_ids
,
...
@@ -356,7 +363,7 @@ class SyncHandler(BaseHandler):
...
@@ -356,7 +363,7 @@ class SyncHandler(BaseHandler):
prev_batch
=
prev_batch_token
,
prev_batch
=
prev_batch_token
,
state
=
state_events_delta
,
state
=
state_events_delta
,
limited
=
limited
,
limited
=
limited
,
typing
=
typing_by_room
.
get
(
room_id
,
None
)
ephemeral
=
typing_by_room
.
get
(
room_id
,
None
)
)
)
logging
.
debug
(
"
Room sync: %r
"
,
room_sync
)
logging
.
debug
(
"
Room sync: %r
"
,
room_sync
)
...
@@ -402,3 +409,19 @@ class SyncHandler(BaseHandler):
...
@@ -402,3 +409,19 @@ class SyncHandler(BaseHandler):
if
event
.
event_id
not
in
previous_dict
:
if
event
.
event_id
not
in
previous_dict
:
state_delta
.
append
(
event
)
state_delta
.
append
(
event
)
return
state_delta
return
state_delta
@defer.inlineCallbacks
def
check_joined_room
(
self
,
sync_config
,
room_id
,
state_delta
):
joined
=
False
for
event
in
state_delta
:
if
(
event
.
type
==
EventTypes
.
Member
and
event
.
state_key
==
sync_config
.
user
.
to_string
()
):
if
event
.
content
[
"
membership
"
]
==
Membership
.
JOIN
:
joined
=
True
if
joined
:
state_delta
=
yield
self
.
state_handler
.
get_current_state
(
room_id
)
defer
.
returnValue
(
state_delta
)
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