Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert webhooks.event_filter None, {} to [] #3

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ex_app/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,13 @@ def _webhooks_syncing():
registered_listeners = get_registered_listeners()
print("get_registered_listeners: ", json.dumps(registered_listeners, indent=4), flush=True)
for expected_listener in expected_listeners:
expected_listener["filters"] = _preprocess_webhook_event_filter(expected_listener["filters"])
registered_listeners_for_uri = get_registered_listeners_for_uri(
expected_listener["webhook"], registered_listeners
)
for event in expected_listener["events"]:
listener = next(filter(lambda listener: listener["event"] == event, registered_listeners_for_uri), None)
listener["eventFilter"] = _preprocess_webhook_event_filter(listener["eventFilter"])
if listener is not None:
if listener["eventFilter"] != expected_listener["filters"]:
print("webhooks_syncing: before update_listener:", json.dumps(listener))
Expand All @@ -398,6 +400,12 @@ def _webhooks_syncing():
sleep(30)


def _preprocess_webhook_event_filter(event_filter):
if event_filter in (None, {}):
return []
return event_filter


def get_flow_paths(workspace: str, token: str) -> list[str]:
method = "GET"
path = f"w/{workspace}/flows/list"
Expand Down