refac
This commit is contained in:
@@ -343,6 +343,9 @@ def _notification_webhook_content(event: Any) -> tuple[str, str, dict[str, Any],
|
||||
return str(title), message, event.model_dump(), message if title else None
|
||||
|
||||
|
||||
# LICENSE covers this Open WebUI notification identifier.
|
||||
# Do not alter, remove, obscure, or replace it except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
async def test_target(user_id: str, target_id: str, app_name: str = 'Open WebUI') -> dict[str, Any]:
|
||||
notifications = await _load_notifications(user_id)
|
||||
target = _find_target(notifications, target_id)
|
||||
@@ -351,6 +354,9 @@ async def test_target(user_id: str, target_id: str, app_name: str = 'Open WebUI'
|
||||
await _send_webhook(
|
||||
app_name,
|
||||
target,
|
||||
# LICENSE covers this Open WebUI notification copy.
|
||||
# Do not alter, remove, obscure, or replace it except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
'This is a test notification from Open WebUI.',
|
||||
{'action': 'test', 'user_id': user_id},
|
||||
'Test notification',
|
||||
@@ -358,8 +364,15 @@ async def test_target(user_id: str, target_id: str, app_name: str = 'Open WebUI'
|
||||
return {'ok': True}
|
||||
|
||||
|
||||
# LICENSE covers this Open WebUI notification identifier.
|
||||
# Do not alter, remove, obscure, or replace it except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
async def notify_target(
|
||||
user_id: str, message: str, target: str = '', title: str = '', app_name: str = 'Open WebUI'
|
||||
user_id: str,
|
||||
message: str,
|
||||
target: str = '',
|
||||
title: str = '',
|
||||
app_name: str = 'Open WebUI',
|
||||
) -> dict[str, Any]:
|
||||
notifications = await _load_notifications(user_id)
|
||||
item = _find_target(notifications, target)
|
||||
@@ -383,6 +396,9 @@ async def dispatch_notification_event(app: Any, event: Any) -> None:
|
||||
|
||||
from open_webui.events import event_user_ids
|
||||
|
||||
# LICENSE covers this Open WebUI notification identifier.
|
||||
# Do not alter, remove, obscure, or replace it except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
app_name = getattr(getattr(app, 'state', None), 'WEBUI_NAME', 'Open WebUI')
|
||||
for user_id in event_user_ids(event):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user