# HG changeset patch # User Goffi # Date 1484520748 -3600 # Node ID c3952922ca56ed73fe056f44f4cbc597abd667aa # Parent 34dfe0e32064e859cbec390b9605f88139f0d2ff chat: uploaded images are now sent with XHTML, so they are shown inline diff -r 34dfe0e32064 -r c3952922ca56 src/cagou/plugins/plugin_wid_chat.py --- a/src/cagou/plugins/plugin_wid_chat.py Sun Jan 15 21:21:32 2017 +0100 +++ b/src/cagou/plugins/plugin_wid_chat.py Sun Jan 15 23:52:28 2017 +0100 @@ -35,6 +35,7 @@ from cagou.core.common import JidWidget from kivy.uix.dropdown import DropDown from cagou import G +import mimetypes PLUGIN_INFO = { @@ -289,10 +290,20 @@ def fileTransferDone(self, metadata, profile): log.debug("file transfered: {}".format(metadata)) + extra = {} + + # FIXME: Q&D way of getting file type, upload plugins shouls give it + mime_type = mimetypes.guess_type(metadata['url'])[0] + if mime_type is not None: + if mime_type.split(u'/')[0] == 'image': + # we generate url ourselves, so this formatting is safe + extra['xhtml'] = u"".format(**metadata) + G.host.messageSend( self.target, {'': metadata['url']}, mess_type = C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, + extra = extra, profile_key=profile )