presence: Avoid failures with obsolete events.

We only recently added `user_id` to presence
events.
This commit is contained in:
Steve Howell
2020-03-03 12:05:09 +00:00
committed by Tim Abbott
parent eee784312d
commit 862515b7a4

View File

@@ -916,6 +916,12 @@ def process_message_event(event_template: Mapping[str, Any], users: Iterable[Map
client.add_event(user_event)
def process_presence_event(event: Mapping[str, Any], users: Iterable[int]) -> None:
if 'user_id' not in event:
# We only recently added `user_id` to presence data.
# Any old events in our queue can just be dropped,
# since presence events are pretty ephemeral in nature.
logging.warning('Dropping some obsolete presence events after upgrade.')
slim_event = dict(
type='presence',
user_id=event['user_id'],