From 96b2ad148c3f81fb826055b4c97667cdf7b69ec2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 31 Aug 2022 02:19:21 +0200 Subject: [PATCH] A smarter way of building and matching the event condition --- platypush/backend/http/app/routes/hook.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platypush/backend/http/app/routes/hook.py b/platypush/backend/http/app/routes/hook.py index 8d49530c..6996fcad 100644 --- a/platypush/backend/http/app/routes/hook.py +++ b/platypush/backend/http/app/routes/hook.py @@ -20,11 +20,13 @@ __routes__ = [ def matches_condition(event: WebhookEvent, hook): if isinstance(hook, dict): - condition = hook.get('condition', {}) + if_ = hook['if'].copy() + if_['type'] = '.'.join([event.__module__, event.__class__.__qualname__]) + + condition = EventCondition.build(if_) else: condition = hook.condition - condition = EventCondition.build(condition) return event.matches_condition(condition)