优化消息里的URL访问出错导致消息无法进行的BUG

This commit is contained in:
Yanyutin753 2024-05-27 20:30:28 +08:00
parent 58c60811f3
commit 4ff7e72190
2 changed files with 5 additions and 1 deletions

View File

@ -15,7 +15,8 @@ async def get_file_content(url):
client = Client()
try:
r = await client.get(url)
r.raise_for_status()
if r.status_code != 200:
return None, None
file_content = r.content
mime_type = r.headers.get('Content-Type', '').split(';')[0].strip()
return file_content, mime_type

View File

@ -410,6 +410,9 @@ class ChatService:
return False
async def upload_file(self, file_content, mime_type):
if not file_content or not mime_type:
return None
width, height = None, None
if mime_type.startswith("image/"):
try: