Member ev. processing: don't assume any key exists

This commit is contained in:
miruka 2020-03-24 03:56:31 -04:00
parent a0e659098d
commit 0e191f11d0

View File

@ -269,13 +269,13 @@ class NioCallbacks:
# Profile changes # Profile changes
changed = [] changed = []
if prev and now["avatar_url"] != prev["avatar_url"]: if prev and now.get("avatar_url") != prev.get("avatar_url"):
changed.append("profile picture") # TODO: <img>s changed.append("profile picture") # TODO: <img>s
if prev and now["displayname"] != prev["displayname"]: if prev and now.get("displayname") != prev.get("displayname"):
changed.append('display name from "{}" to "{}"'.format( changed.append('display name from "{}" to "{}"'.format(
prev["displayname"] or ev.state_key, prev.get("displayname") or ev.state_key,
now["displayname"] or ev.state_key, now.get("displayname") or ev.state_key,
)) ))
if changed: if changed:
@ -285,8 +285,8 @@ class NioCallbacks:
if account.profile_updated < ev_date: if account.profile_updated < ev_date:
account.profile_updated = ev_date account.profile_updated = ev_date
account.display_name = now["displayname"] or "" account.display_name = now.get("displayname") or ""
account.avatar_url = now["avatar_url"] or "" account.avatar_url = now.get("avatar_url") or ""
if self.client.backend.ui_settings["hideProfileChangeEvents"]: if self.client.backend.ui_settings["hideProfileChangeEvents"]:
self.client.skipped_events[room.room_id] += 1 self.client.skipped_events[room.room_id] += 1