serJD commited on
Commit
5093424
1 Parent(s): b942bda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -54,6 +54,8 @@ else:
54
  # checks payload of webhook and runs the main code if webhook was triggered by specified stream + one of the branches
55
  listendStreams = [STREAM_ID]
56
  listendBranchNames = [BRANCH_NAME_LAND_USES,BRANCH_NAME_DISTANCE_MATRIX,BRANCH_NAME_METRIC_DIST_MATRIX]
 
 
57
 
58
  @webhook_endpoint
59
  async def update_streams(request: Request):
@@ -71,10 +73,10 @@ async def update_streams(request: Request):
71
  if "event" in payload and "data" in payload["event"]:
72
  event_data = payload["event"]["data"]
73
 
74
- # Check if the event type is "commit_create"
75
- if "type" in event_data and event_data["type"] in ["commit_create", "commit_delete"]:
76
  # Check if the stream name matches the specified list
77
- if "stream" in event_data and event_data["stream"] in listendStreams:
78
  # Check if the branch name matches the specified list
79
  if "commit" in event_data and "branchName" in event_data["commit"]:
80
  if event_data["commit"]["branchName"] in listendBranchNames:
@@ -84,7 +86,7 @@ async def update_streams(request: Request):
84
  else:
85
  print("Stream name not found or not in the specified list.")
86
  else:
87
- print("Event type is not 'commit_create'.")
88
  else:
89
  print("Payload structure does not match the expected format.")
90
 
@@ -96,7 +98,7 @@ async def update_streams(request: Request):
96
  print("Flag is False. Skipping further execution.")
97
 
98
  return "Webhook processing complete."
99
-
100
 
101
 
102
  def runAll():
 
54
  # checks payload of webhook and runs the main code if webhook was triggered by specified stream + one of the branches
55
  listendStreams = [STREAM_ID]
56
  listendBranchNames = [BRANCH_NAME_LAND_USES,BRANCH_NAME_DISTANCE_MATRIX,BRANCH_NAME_METRIC_DIST_MATRIX]
57
+ print("branchnames", listendBranchNames)
58
+ print("stream", listendStreams)
59
 
60
  @webhook_endpoint
61
  async def update_streams(request: Request):
 
73
  if "event" in payload and "data" in payload["event"]:
74
  event_data = payload["event"]["data"]
75
 
76
+ # Check if the event type is one of the specified types
77
+ if "event_name" in payload["event"] and payload["event"]["event_name"] in ["commit_create", "commit_delete", "commit_update"]:
78
  # Check if the stream name matches the specified list
79
+ if "stream" in payload and payload["stream"]["name"] in listendStreams:
80
  # Check if the branch name matches the specified list
81
  if "commit" in event_data and "branchName" in event_data["commit"]:
82
  if event_data["commit"]["branchName"] in listendBranchNames:
 
86
  else:
87
  print("Stream name not found or not in the specified list.")
88
  else:
89
+ print("Event type is not one of the specified types.")
90
  else:
91
  print("Payload structure does not match the expected format.")
92
 
 
98
  print("Flag is False. Skipping further execution.")
99
 
100
  return "Webhook processing complete."
101
+
102
 
103
 
104
  def runAll():