From 11703ccb41a9c821eab62c1c91ddc0a5305a45a3 Mon Sep 17 00:00:00 2001 From: Lubos Kocman Date: Mon, 26 Sep 2016 15:24:43 +0200 Subject: [PATCH] Improved conditions for message filtering --- rida/messaging.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rida/messaging.py b/rida/messaging.py index a2680dc6..05a7c33d 100644 --- a/rida/messaging.py +++ b/rida/messaging.py @@ -57,15 +57,16 @@ class BaseMessage(object): @staticmethod def from_amq(topic, msg): msg_obj = None - properties = None - body = None - if hasattr(msg, 'properties'): - properties = json.loads(msg.properties, encoding='utf8') - if not ((properties.get('service') == 'koji' or properties.get('service') == 'rida')): - log.debug("Skipping msg: %s" % msg) - return None + if not hasattr(msg, 'properties'): + return None # Unrelated message not identifying service origin + properties = json.loads(msg.properties, encoding='utf8') service = properties.get('service') + + if service not in ('koji', 'rida'): + log.debug('Skipping msg due service=%s which is not related (msg=%r): ' % (service, msg)) + return None + # This probably appies only for brew # Also wouldn't be easier to use properties? if service == 'koji':