Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0297.py @ 2137:410e7a940a8b
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 05 Feb 2017 14:55:56 +0100 |
parents | 6a66c8c5a567 |
children | 1d3f73e065e1 |
comparison
equal
deleted
inserted
replaced
2136:cc3a6aea9508 | 2137:410e7a940a8b |
---|---|
17 | 17 |
18 # You should have received a copy of the GNU Affero General Public License | 18 # You should have received a copy of the GNU Affero General Public License |
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | 20 |
21 from sat.core.constants import Const as C | 21 from sat.core.constants import Const as C |
22 from sat.core.i18n import _ | 22 from sat.core.i18n import _, D_ |
23 from sat.core.log import getLogger | 23 from sat.core.log import getLogger |
24 log = getLogger(__name__) | 24 log = getLogger(__name__) |
25 | 25 |
26 from wokkel import disco, iwokkel | 26 from wokkel import disco, iwokkel |
27 try: | 27 try: |
33 from twisted.words.xish import domish | 33 from twisted.words.xish import domish |
34 | 34 |
35 NS_SF = C.NS_FORWARD | 35 NS_SF = C.NS_FORWARD |
36 | 36 |
37 PLUGIN_INFO = { | 37 PLUGIN_INFO = { |
38 "name": "Stanza Forwarding", | 38 u"name": u"Stanza Forwarding", |
39 "import_name": "XEP-0297", | 39 u"import_name": u"XEP-0297", |
40 "type": "XEP", | 40 u"type": u"XEP", |
41 "protocols": ["XEP-0297"], | 41 u"protocols": [u"XEP-0297"], |
42 "main": "XEP_0297", | 42 u"main": "XEP_0297", |
43 "handler": "yes", | 43 u"handler": u"yes", |
44 "description": _("""Implementation of Stanza Forwarding""") | 44 u"description": D_(u"""Implementation of Stanza Forwarding""") |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 class XEP_0297(object): | 48 class XEP_0297(object): |
49 # FIXME: check this implementation which doesn't seems to be used | |
49 | 50 |
50 def __init__(self, host): | 51 def __init__(self, host): |
51 log.info(_("Stanza Forwarding plugin initialization")) | 52 log.info(_("Stanza Forwarding plugin initialization")) |
52 self.host = host | 53 self.host = host |
53 | 54 |
77 @param stamp (datetime): offset-aware timestamp of the original reception. | 78 @param stamp (datetime): offset-aware timestamp of the original reception. |
78 @param body (unicode): optional description. | 79 @param body (unicode): optional description. |
79 @param profile_key (unicode): %(doc_profile_key)s | 80 @param profile_key (unicode): %(doc_profile_key)s |
80 @return: a Deferred when the message has been sent | 81 @return: a Deferred when the message has been sent |
81 """ | 82 """ |
83 # FIXME: this method is not used and doesn't use mess_data which should be used for client.sendMessage | |
84 # should it be deprecated? A method constructing the element without sending it seems more natural | |
85 log.warning(u"THIS METHOD IS DEPRECATED") #Â FIXME: we use this warning until we check the method | |
82 msg = domish.Element((None, 'message')) | 86 msg = domish.Element((None, 'message')) |
83 msg['to'] = to_jid.full() | 87 msg['to'] = to_jid.full() |
84 msg['type'] = stanza['type'] | 88 msg['type'] = stanza['type'] |
85 | 89 |
86 body_elt = domish.Element((None, 'body')) | 90 body_elt = domish.Element((None, 'body')) |
96 | 100 |
97 msg.addChild(body_elt) | 101 msg.addChild(body_elt) |
98 msg.addChild(forwarded_elt) | 102 msg.addChild(forwarded_elt) |
99 | 103 |
100 client = self.host.getClient(profile_key) | 104 client = self.host.getClient(profile_key) |
101 return client.send(msg.toXml()) | 105 return client.sendMessage({u'xml': msg}) |
102 | 106 |
103 | 107 |
104 class XEP_0297_handler(XMPPHandler): | 108 class XEP_0297_handler(XMPPHandler): |
105 implements(iwokkel.IDisco) | 109 implements(iwokkel.IDisco) |
106 | 110 |