forked from MirrorHub/synapse
Fix an off-by-one bug in presence event stream pagination; this might be responsible for any number of bug reports
This commit is contained in:
parent
d6bcffa929
commit
b1ee6fd7ed
|
@ -838,7 +838,7 @@ class PresenceEventSource(object):
|
||||||
updates = []
|
updates = []
|
||||||
# TODO(paul): use a DeferredList ? How to limit concurrency.
|
# TODO(paul): use a DeferredList ? How to limit concurrency.
|
||||||
for observed_user in cachemap.keys():
|
for observed_user in cachemap.keys():
|
||||||
if not (to_key < cachemap[observed_user].serial < from_key):
|
if not (to_key < cachemap[observed_user].serial <= from_key):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (yield self.is_visible(observer_user, observed_user)):
|
if (yield self.is_visible(observer_user, observed_user)):
|
||||||
|
|
|
@ -29,6 +29,7 @@ from synapse.server import HomeServer
|
||||||
from synapse.api.constants import PresenceState
|
from synapse.api.constants import PresenceState
|
||||||
from synapse.api.errors import SynapseError
|
from synapse.api.errors import SynapseError
|
||||||
from synapse.handlers.presence import PresenceHandler, UserPresenceCache
|
from synapse.handlers.presence import PresenceHandler, UserPresenceCache
|
||||||
|
from synapse.streams.config import SourcePaginationConfig
|
||||||
|
|
||||||
|
|
||||||
OFFLINE = PresenceState.OFFLINE
|
OFFLINE = PresenceState.OFFLINE
|
||||||
|
@ -676,6 +677,21 @@ class PresencePushTestCase(unittest.TestCase):
|
||||||
msg="Presence event should be visible to self-reflection"
|
msg="Presence event should be visible to self-reflection"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
config = SourcePaginationConfig(from_key=1, to_key=0)
|
||||||
|
(chunk, _) = yield self.event_source.get_pagination_rows(
|
||||||
|
self.u_apple, config, None
|
||||||
|
)
|
||||||
|
self.assertEquals(chunk,
|
||||||
|
[
|
||||||
|
{"type": "m.presence",
|
||||||
|
"content": {
|
||||||
|
"user_id": "@apple:test",
|
||||||
|
"presence": ONLINE,
|
||||||
|
"last_active_ago": 0,
|
||||||
|
}},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# Banana sees it because of presence subscription
|
# Banana sees it because of presence subscription
|
||||||
(events, _) = yield self.event_source.get_new_events_for_user(
|
(events, _) = yield self.event_source.get_new_events_for_user(
|
||||||
self.u_banana, 0, None
|
self.u_banana, 0, None
|
||||||
|
|
Loading…
Reference in a new issue