diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-11-19 17:30:35 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-11-19 17:31:46 +0000 |
commit | 03dc63f6c86f82743b53adadf7d442d6b478a1bf (patch) | |
tree | b94e6c1f7d1e309357e52dcdcb35dff9720a037a | |
parent | Fix backfill request (diff) | |
download | synapse-03dc63f6c86f82743b53adadf7d442d6b478a1bf.tar.xz |
Initialise UserPresenceCache instances to always contain a 'presence' key
-rw-r--r-- | synapse/handlers/presence.py | 6 | ||||
-rw-r--r-- | tests/handlers/test_presence.py | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 325ae45257..fcc92a8e32 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -139,9 +139,7 @@ class PresenceHandler(BaseHandler): if user in self._user_cachemap: return self._user_cachemap[user] else: - statuscache = UserPresenceCache() - statuscache.update({"presence": PresenceState.OFFLINE}, user) - return statuscache + return UserPresenceCache() def registered_user(self, user): self.store.create_presence(user.localpart) @@ -873,7 +871,7 @@ class UserPresenceCache(object): Includes the update timestamp. """ def __init__(self): - self.state = {} + self.state = {"presence": PresenceState.OFFLINE} self.serial = None def update(self, state, serial): diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py index cdaf93429b..fe69ce47eb 100644 --- a/tests/handlers/test_presence.py +++ b/tests/handlers/test_presence.py @@ -1200,7 +1200,10 @@ class PresencePollingTestCase(unittest.TestCase): path=ANY, data=_expect_edu("remote", "m.presence", content={ - "push": [ {"user_id": "@clementine:test" }], + "push": [ { + "user_id": "@clementine:test", + "presence": OFFLINE, + }], }, ), json_data_callback=ANY, @@ -1229,7 +1232,10 @@ class PresencePollingTestCase(unittest.TestCase): path=ANY, data=_expect_edu("remote", "m.presence", content={ - "push": [ {"user_id": "@fig:test" }], + "push": [ { + "user_id": "@fig:test", + "presence": OFFLINE, + }], }, ), json_data_callback=ANY, |