Mercurial > libervia-backend
changeset 2652:baccc27d5c5c
plugin XEP-0334: added a method to add hint directly to elements (i.e. on domish.Element instead of message data)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 11 Aug 2018 18:24:55 +0200 |
parents | ebcff5423465 |
children | 7213caa5c5d0 |
files | sat/plugins/plugin_xep_0334.py |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0334.py Sat Aug 11 18:24:55 2018 +0200 +++ b/sat/plugins/plugin_xep_0334.py Sat Aug 11 18:24:55 2018 +0200 @@ -85,10 +85,18 @@ else: log.error(u"Unknown hint: {}".format(hint)) + def addHintElements(self, message_elt, hints): + """Add hints elements to message stanza + + @param message_elt(domish.Element): stanza where hints must be added + @param hints(iterable(unicode)): hints to add + """ + for hint in hints: + message_elt.addElement((NS_HINTS, hint)) + def _sendPostXmlTreatment(self, mess_data): if "hints" in mess_data: - for hint in mess_data["hints"]: - mess_data[u"xml"].addElement((NS_HINTS, hint)) + self.addHintElements(mess_data[u"xml"], mess_data[u"hints"]) return mess_data def sendMessageTrigger(