mirror of
https://github.com/open-webui/open-webui
synced 2025-01-01 08:42:14 +00:00
Merge branch 'open-webui:dev' into dev
This commit is contained in:
commit
9d3ab2e40e
@ -608,15 +608,16 @@ async def process_chat_response(request, response, user, events, metadata, tasks
|
|||||||
is None
|
is None
|
||||||
):
|
):
|
||||||
webhook_url = Users.get_user_webhook_url_by_id(user.id)
|
webhook_url = Users.get_user_webhook_url_by_id(user.id)
|
||||||
|
webui_url = f"{request.headers.get('x-forwarded-proto', request.url.scheme)}://{request.headers.get('x-forwarded-host', f'{request.client.host}:{request.url.port}')}"
|
||||||
if webhook_url:
|
if webhook_url:
|
||||||
post_webhook(
|
post_webhook(
|
||||||
webhook_url,
|
webhook_url,
|
||||||
f"{title} - {WEBUI_URL}/c/{metadata['chat_id']}\n\n{content}",
|
f"{title} - {webui_url}/c/{metadata['chat_id']}\n\n{content}",
|
||||||
{
|
{
|
||||||
"action": "chat",
|
"action": "chat",
|
||||||
"message": content,
|
"message": content,
|
||||||
"title": title,
|
"title": title,
|
||||||
"url": f"{WEBUI_URL}/c/{metadata['chat_id']}",
|
"url": f"{webui_url}/c/{metadata['chat_id']}",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +19,11 @@ def post_webhook(url: str, message: str, event_data: dict) -> bool:
|
|||||||
payload["text"] = message
|
payload["text"] = message
|
||||||
# Discord Webhooks
|
# Discord Webhooks
|
||||||
elif "https://discord.com/api/webhooks" in url:
|
elif "https://discord.com/api/webhooks" in url:
|
||||||
payload["content"] = message
|
payload["content"] = (
|
||||||
|
message
|
||||||
|
if len(message) > 2000
|
||||||
|
else f"{message[: 2000 - 14]}... (truncated)"
|
||||||
|
)
|
||||||
# Microsoft Teams Webhooks
|
# Microsoft Teams Webhooks
|
||||||
elif "webhook.office.com" in url:
|
elif "webhook.office.com" in url:
|
||||||
action = event_data.get("action", "undefined")
|
action = event_data.get("action", "undefined")
|
||||||
|
Loading…
Reference in New Issue
Block a user