mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 03:47:49 +01:00
refac: post webhook
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import requests
|
||||
|
||||
|
||||
def post_webhook(url: str, json: dict) -> bool:
|
||||
def post_webhook(url: str, message: str, event_data: dict) -> bool:
|
||||
try:
|
||||
r = requests.post(url, json=json)
|
||||
payload = {}
|
||||
|
||||
if "https://hooks.slack.com" in url:
|
||||
payload["text"] = message
|
||||
elif "https://discord.com/api/webhooks" in url:
|
||||
payload["content"] = message
|
||||
else:
|
||||
payload = {**event_data}
|
||||
|
||||
r = requests.post(url, json=payload)
|
||||
r.raise_for_status()
|
||||
return True
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user