MCPcopy
hub / github.com/PostHog/posthog / test_slack_webhook

Function test_slack_webhook

posthog/api/user.py:273–293  ·  view source on GitHub ↗

Test webhook.

(request)

Source from the content-addressed store, hash-verified

271@require_http_methods(["POST"])
272@authenticate_secondarily
273def test_slack_webhook(request):
274 """Test webhook."""
275 try:
276 body = json.loads(request.body)
277 except (TypeError, json.decoder.JSONDecodeError):
278 return JsonResponse({"error": "Cannot parse request body"}, status=400)
279
280 webhook = body.get("webhook")
281
282 if not webhook:
283 return JsonResponse({"error": "no webhook URL"})
284 message = {"text": "_Greetings_ from PostHog!"}
285 try:
286 response = requests.post(webhook, verify=False, json=message)
287
288 if response.ok:
289 return JsonResponse({"success": True})
290 else:
291 return JsonResponse({"error": response.text})
292 except:
293 return JsonResponse({"error": "invalid webhook URL"})

Callers

nothing calls this directly

Calls 2

postMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…