mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-14 04:08:46 +00:00
refac
This commit is contained in:
parent
4f9f04ceee
commit
3f6c3e31a0
2 changed files with 11 additions and 3 deletions
|
|
@ -113,14 +113,19 @@ class MessageUserResponse(MessageModel):
|
|||
|
||||
|
||||
class MessageUserSlimResponse(MessageUserResponse):
|
||||
data: bool | None = None
|
||||
data: dict | bool | None = None
|
||||
|
||||
@field_validator('data', mode='before')
|
||||
def convert_data_to_bool(cls, v):
|
||||
def summarize_data(cls, v):
|
||||
# No data or not a dict → False
|
||||
if not isinstance(v, dict):
|
||||
return False
|
||||
|
||||
# Reply previews need card text, but not actions or other message data.
|
||||
app = v.get('app')
|
||||
if isinstance(app, dict) and app.get('embeds'):
|
||||
return {'app': {'embeds': app['embeds']}}
|
||||
|
||||
# True if ANY value in the dict is non-empty
|
||||
return any(bool(val) for val in v.values())
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,10 @@
|
|||
browser &&
|
||||
idType === 'U' &&
|
||||
requestedUserId !== id &&
|
||||
(!token?.label || token.label === id || /^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(token.label))
|
||||
(!token?.label ||
|
||||
token.label === _id ||
|
||||
token.label === id ||
|
||||
/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(token.label))
|
||||
) {
|
||||
requestedUserId = id;
|
||||
resolvedUser = null;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue