serJD commited on
Commit
fe55366
·
verified ·
1 Parent(s): ceb99e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -18
app.py CHANGED
@@ -52,27 +52,41 @@ async def mergeStreams(request: Request):
52
  print("============= config =============")
53
  print(config)
54
  payload = payload["payload"]
55
- event_name = payload["event"]["event_name"]
56
- streamid = payload.get("stream", {}).get("id")
57
- # Extract branchName for commit_update events from the "old" commit data
58
- if event_name == "commit_update":
59
- branchName = payload.get("event", {}).get("data", {}).get("old", {}).get("branchName")
60
- else:
61
- branchName = payload.get("event", {}).get("data", {}).get("commit", {}).get("branchName")
62
 
63
- # List of valid event types
64
- valid_event_types = ["commit_create", "commit_delete", "commit_update"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- if event_name in valid_event_types:
67
- if streamid == STREAM_ID:
68
- if branchName == branchA:
69
- should_continue = True
 
 
 
 
 
70
  else:
71
- print(f"Branch name {branchName} not found in config.")
72
  else:
73
- print(f"Stream name {streamid} not found in config.")
74
- else:
75
- print(f"Event type {event_name} is not one of the specified types.")
76
 
77
  # If the flag is True, continue running the main part of the code
78
  if should_continue:
@@ -143,4 +157,5 @@ async def mergeStreams(request: Request):
143
  geometryGroupPath=["@Data", "@{0}"],
144
  match_by_id="id",
145
  #openai_key =None,
146
- return_original = False)
 
 
52
  print("============= config =============")
53
  print(config)
54
  payload = payload["payload"]
 
 
 
 
 
 
 
55
 
56
+
57
+ # webhook calls can come from different sources
58
+ if payload.get('source') == 'notionTrigger':
59
+ action = payload.get('action')
60
+ streamName = payload.get('streamName')
61
+ branchName = payload.get('branchName')
62
+ update_source = "notionTrigger"
63
+
64
+ should_continue = True
65
+
66
+
67
+ else:
68
+ update_source = "speckleWebhook"
69
+ event_name = payload["event"]["event_name"]
70
+ streamid = payload.get("stream", {}).get("id")
71
+ # Extract branchName for commit_update events from the "old" commit data
72
+ if event_name == "commit_update":
73
+ branchName = payload.get("event", {}).get("data", {}).get("old", {}).get("branchName")
74
+ else:
75
+ branchName = payload.get("event", {}).get("data", {}).get("commit", {}).get("branchName")
76
 
77
+ # List of valid event types
78
+ valid_event_types = ["commit_create", "commit_delete", "commit_update"]
79
+
80
+ if event_name in valid_event_types:
81
+ if streamid == STREAM_ID:
82
+ if branchName == branchA:
83
+ should_continue = True
84
+ else:
85
+ print(f"Branch name {branchName} not found in config.")
86
  else:
87
+ print(f"Stream name {streamid} not found in config.")
88
  else:
89
+ print(f"Event type {event_name} is not one of the specified types.")
 
 
90
 
91
  # If the flag is True, continue running the main part of the code
92
  if should_continue:
 
157
  geometryGroupPath=["@Data", "@{0}"],
158
  match_by_id="id",
159
  #openai_key =None,
160
+ return_original = False,
161
+ comm_message="auto commit from HF; Triggered by:" + update_source)