From 4c18e08036a15c536070ae6b9c0b314fc032010d Mon Sep 17 00:00:00 2001
From: "Paul \"LeoNerd\" Evans" <paul@matrix.org>
Date: Tue, 18 Nov 2014 15:10:11 +0000
Subject: [PATCH] Don't expect all _user_cachemap entries to definitely contain
 a "last_active" key

---
 synapse/handlers/presence.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 2ccc2245b7..36d864e3f1 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -180,9 +180,9 @@ class PresenceHandler(BaseHandler):
             state["presence"] = state.pop("state")
 
             if target_user in self._user_cachemap:
-                state["last_active"] = (
-                    self._user_cachemap[target_user].get_state()["last_active"]
-                )
+                cached_state = self._user_cachemap[target_user].get_state()
+                if "last_active" in cached_state:
+                    state["last_active"] = cached_state["last_active"]
         else:
             # TODO(paul): Have remote server send us permissions set
             state = self._get_or_offline_usercache(target_user).get_state()
-- 
GitLab