Model item events: add a media_http_url field

This commit is contained in:
miruka
2020-07-20 23:09:28 -04:00
parent 55e22ea948
commit 99017adc1d
5 changed files with 8 additions and 7 deletions

View File

@@ -838,6 +838,7 @@ class MatrixClient(nio.AsyncClient):
inline_content = content["body"],
media_url = url,
media_http_url = await self.mxc_to_http(url),
media_title = path.name,
media_width = content["info"].get("w", 0),
media_height = content["info"].get("h", 0),

View File

@@ -280,6 +280,7 @@ class Event(ModelItem):
source: Optional[nio.Event] = None
media_url: str = ""
media_http_url: str = ""
media_title: str = ""
media_width: int = 0
media_height: int = 0

View File

@@ -209,6 +209,7 @@ class NioCallbacks:
inline_content = ev.body,
media_url = ev.url,
media_http_url = await self.client.mxc_to_http(ev.url),
media_title = ev.body,
media_width = info.get("w") or 0,
media_height = info.get("h") or 0,
@@ -615,8 +616,10 @@ class NioCallbacks:
else:
co = "%1 removed the room's picture"
http = await self.client.mxc_to_http(ev.avatar_url)
await self.client.register_nio_event(
room, ev, content=co, media_url=ev.avatar_url,
room, ev, content=co, media_url=ev.avatar_url, media_http_url=http,
)