A smarter way of building and matching the event condition

This commit is contained in:
Fabio Manganiello 2022-08-31 02:19:21 +02:00
parent 67413c02cd
commit 96b2ad148c
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 4 additions and 2 deletions

View File

@ -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)