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
2ba35625b3
commit
6f92cd78ee
4 changed files with 14 additions and 4 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue