This commit is contained in:
Timothy Jaeryang Baek
2026-07-16 00:58:34 -04:00
parent 771a024b40
commit c55e373b99
14 changed files with 921 additions and 161 deletions
+28
View File
@@ -52,6 +52,7 @@ from open_webui.routers.retrieval import search_web as _search_web
from open_webui.tasks import stop_item_tasks
from open_webui.events import EVENTS, publish_event
from open_webui.socket.main import sio
from open_webui.utils.notifications import notify_target
from open_webui.utils.sanitize import sanitize_code
log = logging.getLogger(__name__)
@@ -111,6 +112,33 @@ async def _has_read_access_to_file(
# =============================================================================
async def notify(
message: str,
target: str = '',
title: str = '',
__request__: Request = None,
__user__: dict = None,
) -> str:
"""
Send a notification to the user's configured notification target.
:param message: Notification body.
:param target: Optional target id or name. Empty uses the default target.
:param title: Optional notification title.
"""
user_id = (__user__ or {}).get('id')
if not user_id:
return 'Notification failed: user not found.'
app_name = getattr(getattr(__request__, 'app', None), 'state', None)
app_name = getattr(app_name, 'WEBUI_NAME', 'Open WebUI')
try:
result = await notify_target(user_id, message, target=target, title=title, app_name=app_name)
return f'Notification sent to {result.get("target_id")}.'
except Exception as e:
return f'Notification failed: {e}'
async def get_current_timestamp(
__request__: Request = None,
__user__: dict = None,