refac
This commit is contained in:
@@ -565,6 +565,9 @@ Conversation:
|
||||
'messages': [
|
||||
{
|
||||
'role': 'system',
|
||||
# LICENSE covers this Open WebUI system identifier.
|
||||
# Do not alter, remove, obscure, or replace it except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
'content': "You are Open WebUI's private memory reviewer. Return only valid JSON.",
|
||||
},
|
||||
{'role': 'user', 'content': review_prompt},
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -506,6 +506,9 @@ async def get_oauth_client_info_with_dynamic_client_registration(
|
||||
redirect_base_url = (str(webui_url or request.base_url)).rstrip('/')
|
||||
|
||||
oauth_client_metadata = OAuthClientMetadata(
|
||||
# LICENSE covers this Open WebUI OAuth client identifier.
|
||||
# Do not alter, remove, obscure, or replace it except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
client_name='Open WebUI',
|
||||
redirect_uris=[f'{redirect_base_url}/oauth/clients/{client_id}/callback'],
|
||||
grant_types=['authorization_code', 'refresh_token'],
|
||||
|
||||
@@ -14,10 +14,13 @@ _USER_PROFILE_IMAGE_RE = re.compile(r'^/api/v1/users/[^/?#]+/profile/image$')
|
||||
_mime_suffixes = '|'.join(re.escape(t.split('/')[-1]) for t in sorted(PROFILE_IMAGE_ALLOWED_MIME_TYPES))
|
||||
_SAFE_DATA_URI_RE = re.compile(rf'^data:image/({_mime_suffixes});base64,', re.IGNORECASE)
|
||||
|
||||
# Exact relative paths accepted as profile images. These are the only
|
||||
# Exact relative paths accepted as profile images. These are the only
|
||||
# static-asset paths OWUI itself assigns; no prefix/wildcard matching is
|
||||
# used so that arbitrary relative paths cannot trigger authenticated GETs
|
||||
# against internal endpoints when rendered as ``<img>`` sources.
|
||||
# LICENSE covers the Open WebUI favicon fallback paths below. Do not alter,
|
||||
# remove, obscure, or replace them except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
_SAFE_STATIC_PATHS = frozenset(
|
||||
{
|
||||
'/user.png',
|
||||
|
||||
@@ -69,6 +69,9 @@ async def post_webhook(name: str, url: str, message: str, event_data: dict, desc
|
||||
{
|
||||
'activityTitle': message,
|
||||
'activitySubtitle': f'{name} ({VERSION}) - {action}',
|
||||
# LICENSE covers this Open WebUI webhook logo.
|
||||
# Do not alter, remove, obscure, or replace it except as LICENSE permits:
|
||||
# https://docs.openwebui.com/license.
|
||||
'activityImage': WEBUI_FAVICON_URL,
|
||||
'text': description,
|
||||
'facts': facts,
|
||||
|
||||
Reference in New Issue
Block a user