Mercurial > libervia-desktop-kivy
changeset 111:c3952922ca56
chat: uploaded images are now sent with XHTML, so they are shown inline
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 15 Jan 2017 23:52:28 +0100 |
parents | 34dfe0e32064 |
children | d654bdfeb404 |
files | src/cagou/plugins/plugin_wid_chat.py |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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"<img src='{url}' />".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 )