plugin XEP-0297: used sendMessage in forward, and added comment/warning:

this method need to be checked as it is not used currently, and it may need better integration in the current message sending workflow
This commit is contained in:
Goffi 2017-02-05 14:55:56 +01:00
commit 4e13215a94

View file

@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from sat.core.constants import Const as C
from sat.core.i18n import _
from sat.core.i18n import _, D_
from sat.core.log import getLogger
log = getLogger(__name__)
@ -35,17 +35,18 @@ from twisted.words.xish import domish
NS_SF = C.NS_FORWARD
PLUGIN_INFO = {
"name": "Stanza Forwarding",
"import_name": "XEP-0297",
"type": "XEP",
"protocols": ["XEP-0297"],
"main": "XEP_0297",
"handler": "yes",
"description": _("""Implementation of Stanza Forwarding""")
u"name": u"Stanza Forwarding",
u"import_name": u"XEP-0297",
u"type": u"XEP",
u"protocols": [u"XEP-0297"],
u"main": "XEP_0297",
u"handler": u"yes",
u"description": D_(u"""Implementation of Stanza Forwarding""")
}
class XEP_0297(object):
# FIXME: check this implementation which doesn't seems to be used
def __init__(self, host):
log.info(_("Stanza Forwarding plugin initialization"))
@ -79,6 +80,9 @@ class XEP_0297(object):
@param profile_key (unicode): %(doc_profile_key)s
@return: a Deferred when the message has been sent
"""
# FIXME: this method is not used and doesn't use mess_data which should be used for client.sendMessage
# should it be deprecated? A method constructing the element without sending it seems more natural
log.warning(u"THIS METHOD IS DEPRECATED") # FIXME: we use this warning until we check the method
msg = domish.Element((None, 'message'))
msg['to'] = to_jid.full()
msg['type'] = stanza['type']
@ -98,7 +102,7 @@ class XEP_0297(object):
msg.addChild(forwarded_elt)
client = self.host.getClient(profile_key)
return client.send(msg.toXml())
return client.sendMessage({u'xml': msg})
class XEP_0297_handler(XMPPHandler):