f56b088643
Base Image Build / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
Base Image Build / docker (amd64, ubuntu-24.04) (push) Has been cancelled
Base Image Build / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
Base Image Build / create-manifest (push) Has been cancelled
22 lines
694 B
Python
22 lines
694 B
Python
# connect/handlers/webhook.py
|
|
import requests, json, logging
|
|
from .base import IntegrationHandler
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class WebhookHandler(IntegrationHandler):
|
|
def execute(self):
|
|
url = self.integration.config.get("url")
|
|
headers = self.integration.config.get("headers", {})
|
|
logger.info(self.payload)
|
|
|
|
try:
|
|
parsed = json.loads(self.payload)
|
|
headers["Content-Type"] = "application/json"
|
|
except Exception:
|
|
pass
|
|
|
|
response = requests.post(url, data=self.payload, headers=headers, timeout=10)
|
|
|
|
return {"status_code": response.status_code, "body": response.text, "success": response.ok}
|