fix(matrix): handle matrix-nio upload tuple response

This commit is contained in:
Alexander Minges
2026-02-11 10:55:51 +01:00
parent 97cb85ee0b
commit a28ae51ce9
2 changed files with 3 additions and 2 deletions

View File

@@ -517,12 +517,13 @@ class MatrixChannel(BaseChannel):
return MATRIX_ATTACHMENT_UPLOAD_FAILED_TEMPLATE.format(filename) return MATRIX_ATTACHMENT_UPLOAD_FAILED_TEMPLATE.format(filename)
mime = mimetypes.guess_type(filename, strict=False)[0] or "application/octet-stream" mime = mimetypes.guess_type(filename, strict=False)[0] or "application/octet-stream"
upload_response = await self.client.upload( upload_result = await self.client.upload(
data, data,
content_type=mime, content_type=mime,
filename=filename, filename=filename,
filesize=len(data), filesize=len(data),
) )
upload_response = upload_result[0] if isinstance(upload_result, tuple) else upload_result
if isinstance(upload_response, UploadError): if isinstance(upload_response, UploadError):
logger.warning( logger.warning(
"Matrix outbound attachment upload failed for {}: {}", "Matrix outbound attachment upload failed for {}: {}",

View File

@@ -133,7 +133,7 @@ class _FakeAsyncClient:
) )
if self.upload_response is not None: if self.upload_response is not None:
return self.upload_response return self.upload_response
return SimpleNamespace(content_uri="mxc://example.org/uploaded") return SimpleNamespace(content_uri="mxc://example.org/uploaded"), None
async def content_repository_config(self): async def content_repository_config(self):
return self.content_repository_config_response return self.content_repository_config_response