comparison sat/plugins/plugin_xep_0334.py @ 3923:13a2403774d4

plugin XEP-0334: avoid adding twice the same hint: rel 379
author Goffi <goffi@goffi.org>
date Thu, 06 Oct 2022 16:02:05 +0200
parents 8289ac1b34f4
children 524856bd7b19
comparison
equal deleted inserted replaced
3922:0ff265725489 3923:13a2403774d4
90 90
91 @param message_elt: stanza where hints must be added 91 @param message_elt: stanza where hints must be added
92 @param hints: hints to add 92 @param hints: hints to add
93 """ 93 """
94 for hint in hints: 94 for hint in hints:
95 message_elt.addElement((NS_HINTS, hint)) 95 if not list(message_elt.elements(NS_HINTS, hint)):
96 message_elt.addElement((NS_HINTS, hint))
97 else:
98 log.debug('Not adding {hint!r} hint: it is already present in <message>')
96 99
97 def _sendPostXmlTreatment(self, mess_data): 100 def _sendPostXmlTreatment(self, mess_data):
98 if "hints" in mess_data: 101 if "hints" in mess_data:
99 self.addHintElements(mess_data["xml"], mess_data["hints"]) 102 self.addHintElements(mess_data["xml"], mess_data["hints"])
100 return mess_data 103 return mess_data