def render(self): # type: () -> str assert self.content_uri if self.encrypt: http_url = Api.encrypted_mxc_to_plumb( self.content_uri, self.file_keys["key"]["k"], self.file_keys["hashes"]["sha256"], self.file_keys["iv"]) url = http_url if http_url else self.content_uri description = "{}".format(self.file_name) return ("{del_color}<{ncolor}{desc}{del_color}>{ncolor} " "{del_color}[{ncolor}{url}{del_color}]{ncolor}").format( del_color=W.color("chat_delimiters"), ncolor=W.color("reset"), desc=description, url=url) http_url = Api.mxc_to_http(self.content_uri) description = ("/{}".format(self.file_name) if self.file_name else "") return "{url}{desc}".format(url=http_url, desc=description)
def media(mxc, body, homeserver=None): """Render a mxc media URI.""" url = Api.mxc_to_http(mxc, homeserver) description = "{}".format(body) if body else "file" return Render._media(url, description)