forked from platypush/platypush
A smarter way of building and matching the event condition
This commit is contained in:
parent
67413c02cd
commit
96b2ad148c
1 changed files with 4 additions and 2 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue