Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -224,21 +224,20 @@ def debug_cw():
|
|
| 224 |
|
| 225 |
@app.route("/slack/events", methods=["POST"])
|
| 226 |
def slack_events():
|
| 227 |
-
data = request.get_json()
|
| 228 |
|
| 229 |
-
# URL verification
|
| 230 |
if data.get("type") == "url_verification":
|
| 231 |
-
return jsonify({"challenge": data
|
| 232 |
|
| 233 |
-
#
|
| 234 |
-
event_id = data.get("event_id"
|
| 235 |
if event_id and already_seen(event_id):
|
| 236 |
-
logger.info("Duplicate event
|
| 237 |
return "", 200
|
| 238 |
|
| 239 |
-
#
|
| 240 |
-
|
| 241 |
-
thread.start()
|
| 242 |
|
| 243 |
return "", 200
|
| 244 |
|
|
|
|
| 224 |
|
| 225 |
@app.route("/slack/events", methods=["POST"])
|
| 226 |
def slack_events():
|
| 227 |
+
data = request.get_json(force=True, silent=True) or {}
|
| 228 |
|
| 229 |
+
# Slack URL verification
|
| 230 |
if data.get("type") == "url_verification":
|
| 231 |
+
return jsonify({"challenge": data["challenge"]})
|
| 232 |
|
| 233 |
+
# Deduplicate Slack retries
|
| 234 |
+
event_id = data.get("event_id")
|
| 235 |
if event_id and already_seen(event_id):
|
| 236 |
+
logger.info(f"Duplicate event {event_id} ignored")
|
| 237 |
return "", 200
|
| 238 |
|
| 239 |
+
# Process event in background thread
|
| 240 |
+
threading.Thread(target=handle_event, args=(data,), daemon=True).start()
|
|
|
|
| 241 |
|
| 242 |
return "", 200
|
| 243 |
|