From 6f92cd78ee9e2cb29ddd783c11d95a2e56c5e71f Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 12 Oct 2026 18:37:30 +0400 Subject: [PATCH] refac --- backend/open_webui/models/apps.py | 2 +- backend/open_webui/routers/apps.py | 7 ++++++- backend/open_webui/routers/channels.py | 2 +- backend/open_webui/utils/apps.py | 7 ++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/models/apps.py b/backend/open_webui/models/apps.py index a184d75b8e..2e52ef8ce4 100644 --- a/backend/open_webui/models/apps.py +++ b/backend/open_webui/models/apps.py @@ -125,7 +125,7 @@ class AppUpdateForm(StrictModel): class AppTokenForm(StrictModel): - token: str = Field(max_length=100000) + token: str = Field(max_length=1048576) class AppConnectionForm(StrictModel): diff --git a/backend/open_webui/routers/apps.py b/backend/open_webui/routers/apps.py index e6e111965e..4382ead1a0 100644 --- a/backend/open_webui/routers/apps.py +++ b/backend/open_webui/routers/apps.py @@ -457,7 +457,12 @@ async def create_app_interaction( user, message.channel_id, 'channel.action', - {'message_id': message.id, 'action_id': form_data.action_id, 'context': action['context']}, + { + 'message_id': message.id, + 'parent_id': message.parent_id, + 'action_id': form_data.action_id, + 'context': action['context'], + }, source={'id': message.id, 'updated_at': message.updated_at}, db=db, ) diff --git a/backend/open_webui/routers/channels.py b/backend/open_webui/routers/channels.py index 018425b646..8455227165 100644 --- a/backend/open_webui/routers/channels.py +++ b/backend/open_webui/routers/channels.py @@ -1115,7 +1115,7 @@ async def app_channel_reply_handler(channel_id, message_id, user_id): user, channel_id, 'channel.mention', - {'text': text, 'message_id': message_id}, + {'text': text, 'message_id': message_id, 'parent_id': parent_id}, operation_id=message_id, db=db, scope='channels:messages:read' diff --git a/backend/open_webui/utils/apps.py b/backend/open_webui/utils/apps.py index 5b7996b016..c5965c3072 100644 --- a/backend/open_webui/utils/apps.py +++ b/backend/open_webui/utils/apps.py @@ -200,10 +200,14 @@ def verify_app_token(app: AppModel, token: str, token_type: str = 'webui-app+jwt async def send_app_event(app: AppModel, event_data: dict, *, timeout: float = 3) -> tuple[int, Any]: + body = _serialize_json({**event_data, 'app_id': app.id, 'webui_url': app.data['webui_url']}) + if len(body) > 1048576: + log.warning('App %s event exceeds the 1 MiB delivery limit', app.id) + raise ValueError('App event exceeds 1 MiB') api_key = get_app_encryption_cipher().decrypt(app.api_key.encode()).decode() return await send_app_request( app.data['url'], - body=_serialize_json({**event_data, 'app_id': app.id, 'webui_url': app.data['webui_url']}), + body=body, timeout=timeout, headers={'Content-Type': 'application/json', 'Authorization': f'Bearer {api_key}'}, ) @@ -335,6 +339,7 @@ def get_app_message_data(message): 'actions': (message.data or {}).get('app', {}).get('actions', []), 'created_at': str(message.created_at), 'updated_at': str(message.updated_at), + 'etag': str(message.updated_at), }