diff --git a/libervia/backend/plugins/plugin_xep_0049.py b/libervia/backend/plugins/plugin_xep_0049.py index 87ea41d2..c1f62512 100644 --- a/libervia/backend/plugins/plugin_xep_0049.py +++ b/libervia/backend/plugins/plugin_xep_0049.py @@ -55,7 +55,7 @@ class XEP_0049(object): client = self.host.get_client(profile_key) # XXX: feature announcement in disco#info is not mandatory in XEP-0049, so we have to try to use private XML, and react according to the answer iq_elt = compat.IQ(client.xmlstream) - query_elt = iq_elt.addElement("query", XEP_0049.NS_PRIVATE) + query_elt = iq_elt.addElement((XEP_0049.NS_PRIVATE, "query")) query_elt.addChild(element) return iq_elt.send() @@ -70,8 +70,8 @@ class XEP_0049(object): client = self.host.get_client(profile_key) # XXX: see private_xml_store note about feature checking iq_elt = compat.IQ(client.xmlstream, "get") - query_elt = iq_elt.addElement("query", XEP_0049.NS_PRIVATE) - query_elt.addElement(node_name, namespace) + query_elt = iq_elt.addElement((XEP_0049.NS_PRIVATE, "query")) + query_elt.addElement((namespace, node_name)) def get_cb(answer_iq_elt): answer_query_elt = next(answer_iq_elt.elements(XEP_0049.NS_PRIVATE, "query")) diff --git a/libervia/backend/plugins/plugin_xep_0050.py b/libervia/backend/plugins/plugin_xep_0050.py index b4892c71..9c9d8da6 100644 --- a/libervia/backend/plugins/plugin_xep_0050.py +++ b/libervia/backend/plugins/plugin_xep_0050.py @@ -458,7 +458,7 @@ class AdHocCommandHandler(XMPPHandler): result["type"] = "result" result["id"] = iq_elt["id"] result["to"] = iq_elt["from"] - command_elt = result.addElement("command", NS_COMMANDS) + command_elt = result.addElement((NS_COMMANDS, "command" )) command_elt["sessionid"] = session_id command_elt["node"] = self.command.node command_elt["status"] = status @@ -723,7 +723,7 @@ class XEP_0050: """ iq_elt = client.IQ(timeout=timeout) iq_elt["to"] = entity.full() - command_elt = iq_elt.addElement("command", NS_COMMANDS) + command_elt = iq_elt.addElement((NS_COMMANDS, "command")) command_elt["node"] = node command_elt["action"] = action if session_id is not None: diff --git a/libervia/backend/plugins/plugin_xep_0054.py b/libervia/backend/plugins/plugin_xep_0054.py index c312504d..db6c3f1c 100644 --- a/libervia/backend/plugins/plugin_xep_0054.py +++ b/libervia/backend/plugins/plugin_xep_0054.py @@ -229,7 +229,7 @@ class XEP_0054(object): iq_elt = client.IQ("get") iq_elt["from"] = client.jid.full() iq_elt["to"] = entity_jid.full() - iq_elt.addElement("vCard", NS_VCARD) + iq_elt.addElement((NS_VCARD, "vCard")) iq_ret_elt = await iq_elt.send(entity_jid.full()) try: return next(iq_ret_elt.elements(NS_VCARD, "vCard")) diff --git a/libervia/backend/plugins/plugin_xep_0085.py b/libervia/backend/plugins/plugin_xep_0085.py index 54c4efac..c6408972 100644 --- a/libervia/backend/plugins/plugin_xep_0085.py +++ b/libervia/backend/plugins/plugin_xep_0085.py @@ -27,10 +27,7 @@ from wokkel import disco, iwokkel from zope.interface import implementer from twisted.words.protocols.jabber.jid import JID -try: - from twisted.words.protocols.xmlstream import XMPPHandler -except ImportError: - from wokkel.subprotocols import XMPPHandler +from twisted.words.protocols.jabber.xmlstream import XMPPHandler from twisted.words.xish import domish from twisted.internet import reactor from twisted.internet import error as internet_error @@ -235,7 +232,7 @@ class XEP_0085(object): try: # message with a body always mean active state next(domish.generateElementsNamed(message.elements(), name="body")) - message.addElement("active", NS_CHAT_STATES) + message.addElement((NS_CHAT_STATES, "active")) # launch the chat state machine (init the timer) if self._is_muc(to_jid, profile): to_jid = to_jid.userhostJID() @@ -244,7 +241,7 @@ class XEP_0085(object): if "chat_state" in mess_data["extra"]: state = mess_data["extra"].pop("chat_state") assert state in CHAT_STATES - message.addElement(state, NS_CHAT_STATES) + message.addElement((NS_CHAT_STATES, state)) return mess_data post_xml_treatments.addCallback(treatment) @@ -404,7 +401,7 @@ class ChatStateMachine(object): "extra": {}, } client.generate_message_xml(mess_data) - mess_data["xml"].addElement(state, NS_CHAT_STATES) + mess_data["xml"].addElement((NS_CHAT_STATES, state)) client.send(mess_data["xml"]) self.state = state diff --git a/libervia/backend/plugins/plugin_xep_0433.py b/libervia/backend/plugins/plugin_xep_0433.py index 3843a10c..b9245800 100644 --- a/libervia/backend/plugins/plugin_xep_0433.py +++ b/libervia/backend/plugins/plugin_xep_0433.py @@ -206,14 +206,14 @@ class SearchItem(BaseModel): for field, element_name in field_mappings.items(): value = getattr(self, field) if value is not None: - elem = item.addElement(element_name, NS_SEARCH) + elem = item.addElement((NS_SEARCH, element_name)) elem.addContent( str(value).lower() if isinstance(value, bool) else str(value) ) if self.is_open is not None: item.addElement( - ("is-open", NS_SEARCH), content="true" if self.is_open else "false" + (NS_SEARCH, "is-open"), content="true" if self.is_open else "false" ) return item