From 5e3b41c3ad93118fb9724c3074c082d3aa16ae72 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 13 May 2018 11:39:55 +0200 Subject: [PATCH] Made the Pushbullet backend more resilient in case of rogue messages with no type specified --- platypush/backend/pushbullet/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platypush/backend/pushbullet/__init__.py b/platypush/backend/pushbullet/__init__.py index 61637bb0bc..8a51364f22 100644 --- a/platypush/backend/pushbullet/__init__.py +++ b/platypush/backend/pushbullet/__init__.py @@ -51,7 +51,8 @@ class PushbulletBackend(Backend): if not isinstance(msg, dict): return True # We received something weird is_duplicate=False - last_msg = self._last_received_msg[msg['type']] + msgtype = msg['type'] if 'type' in msg else 'notype' + last_msg = self._last_received_msg[msgtype] if last_msg: msg = Message.parse(msg) @@ -62,7 +63,7 @@ class PushbulletBackend(Backend): logging.debug('Ignoring duplicate message received on the socket') is_duplicate = True - self._last_received_msg[msg['type']] = { + self._last_received_msg[msgtype] = { 'body': msg, 'time': time.time() }