From ed8c744e77a335109bc4c4802dae9d8f7786cf42 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 14 Oct 2026 00:19:15 +0400 Subject: [PATCH] refac --- backend/open_webui/models/messages.py | 6 ++++++ backend/open_webui/routers/channels.py | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/models/messages.py b/backend/open_webui/models/messages.py index cdc51f0139..31251e11ff 100644 --- a/backend/open_webui/models/messages.py +++ b/backend/open_webui/models/messages.py @@ -137,6 +137,12 @@ class MessageReplyToResponse(MessageUserResponse): class MessageWithReactionsResponse(MessageUserSlimResponse): reactions: list[Reactions] + @field_validator('data', mode='before') + def summarize_data(cls, v, info): + if info.data.get('app_id') and isinstance(v, dict): + return v + return super().summarize_data(v) + class MessageResponse(MessageReplyToResponse): latest_reply_at: Optional[int] diff --git a/backend/open_webui/routers/channels.py b/backend/open_webui/routers/channels.py index 8554f22d5c..da6c3aa343 100644 --- a/backend/open_webui/routers/channels.py +++ b/backend/open_webui/routers/channels.py @@ -905,15 +905,15 @@ async def remove_app( class MessageUserResponse(MessageResponse): - data: bool | None = None + data: dict | bool | None = None @field_validator('data', mode='before') - def convert_data_to_bool(cls, v): - # No data or not a dict → False + def serialize_data(cls, v, info): if not isinstance(v, dict): return False - - # True if ANY value in the dict is non-empty + # App cards and buttons are message content, not lazy-loaded attachments. + if info.data.get('app_id'): + return v return any(bool(val) for val in v.values())