plugin XEP-0231: Bits of Binary first draft:
The current implementation only retrieve data from Bits of Binary, it's not used yet for sending. When an XHTML-IM message is received (XEP-0071), all <img> are checked and if a cid scheme is found in src attribute the file is retrieved and the src is changed with cached file.
This commit is contained in:
parent
6872df4fd3
commit
d0c56aaadb
1 changed files with 147 additions and 5 deletions
|
|
@ -86,9 +86,11 @@ class XEP_0071(object):
|
|||
def getHandler(self, profile):
|
||||
return XEP_0071_handler(self)
|
||||
|
||||
def _messagePostTreat(self, data, body_elts):
|
||||
def _messagePostTreat(self, data, message_elt, body_elts, client):
|
||||
"""Callback which manage the post treatment of the message in case of XHTML-IM found
|
||||
|
||||
@param data: data send by MessageReceived trigger through post_treat deferred
|
||||
@param message_elt: whole <message> stanza
|
||||
@param body_elts: XHTML-IM body elements found
|
||||
@return: the data with the extra parameter updated
|
||||
"""
|
||||
|
|
@ -102,9 +104,12 @@ class XEP_0071(object):
|
|||
defers = []
|
||||
for body_elt in body_elts:
|
||||
lang = body_elt.getAttribute((C.NS_XML, 'lang'), '')
|
||||
d = self._s.convert(body_elt.toXml(), self.SYNTAX_XHTML_IM, safe=True)
|
||||
d.addCallback(converted, lang)
|
||||
defers.append(d)
|
||||
treat_d = defer.succeed(None) # deferred used for treatments
|
||||
if self.host.trigger.point("xhtml_post_treat", client, message_elt, body_elt, lang, treat_d):
|
||||
continue
|
||||
treat_d.addCallback(lambda dummy: self._s.convert(body_elt.toXml(), self.SYNTAX_XHTML_IM, safe=True))
|
||||
treat_d.addCallback(converted, lang)
|
||||
defers.append(treat_d)
|
||||
|
||||
d_list = defer.DeferredList(defers)
|
||||
d_list.addCallback(lambda dummy: data)
|
||||
|
|
@ -175,7 +180,7 @@ class XEP_0071(object):
|
|||
pass
|
||||
else:
|
||||
body_elts = html_elt.elements(NS_XHTML, 'body')
|
||||
post_treat.addCallback(self._messagePostTreat, body_elts)
|
||||
post_treat.addCallback(self._messagePostTreat, message, body_elts, client)
|
||||
return True
|
||||
|
||||
def messageSendTrigger(self, client, data, pre_xml_treatments, post_xml_treatments):
|
||||
|
|
|
|||
Loading…
Reference in a new issue