mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Initialise UserPresenceCache instances to always contain a 'presence' key
This commit is contained in:
parent
4eada9a908
commit
03dc63f6c8
@ -139,9 +139,7 @@ class PresenceHandler(BaseHandler):
|
|||||||
if user in self._user_cachemap:
|
if user in self._user_cachemap:
|
||||||
return self._user_cachemap[user]
|
return self._user_cachemap[user]
|
||||||
else:
|
else:
|
||||||
statuscache = UserPresenceCache()
|
return UserPresenceCache()
|
||||||
statuscache.update({"presence": PresenceState.OFFLINE}, user)
|
|
||||||
return statuscache
|
|
||||||
|
|
||||||
def registered_user(self, user):
|
def registered_user(self, user):
|
||||||
self.store.create_presence(user.localpart)
|
self.store.create_presence(user.localpart)
|
||||||
@ -873,7 +871,7 @@ class UserPresenceCache(object):
|
|||||||
Includes the update timestamp.
|
Includes the update timestamp.
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.state = {}
|
self.state = {"presence": PresenceState.OFFLINE}
|
||||||
self.serial = None
|
self.serial = None
|
||||||
|
|
||||||
def update(self, state, serial):
|
def update(self, state, serial):
|
||||||
|
@ -1200,7 +1200,10 @@ class PresencePollingTestCase(unittest.TestCase):
|
|||||||
path=ANY,
|
path=ANY,
|
||||||
data=_expect_edu("remote", "m.presence",
|
data=_expect_edu("remote", "m.presence",
|
||||||
content={
|
content={
|
||||||
"push": [ {"user_id": "@clementine:test" }],
|
"push": [ {
|
||||||
|
"user_id": "@clementine:test",
|
||||||
|
"presence": OFFLINE,
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
json_data_callback=ANY,
|
json_data_callback=ANY,
|
||||||
@ -1229,7 +1232,10 @@ class PresencePollingTestCase(unittest.TestCase):
|
|||||||
path=ANY,
|
path=ANY,
|
||||||
data=_expect_edu("remote", "m.presence",
|
data=_expect_edu("remote", "m.presence",
|
||||||
content={
|
content={
|
||||||
"push": [ {"user_id": "@fig:test" }],
|
"push": [ {
|
||||||
|
"user_id": "@fig:test",
|
||||||
|
"presence": OFFLINE,
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
json_data_callback=ANY,
|
json_data_callback=ANY,
|
||||||
|
Loading…
Reference in New Issue
Block a user