Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:
caa63371 by Philipp Hörist at 2017-04-26T16:52:36+02:00
Dont deepcopy stanza for smack queue

the Node Object is not deepcopy-able in all cases.
Specifically the ESession negotiation does not work.

Sending the stanza first and adding the delay tag for the
queue afterwards makes it so we dont have to copy the object

- - - - -
c9ca5e48 by Philipp Hörist at 2017-04-26T17:11:17+02:00
Simplify code and satisfy pylint

- - - - -
9cfe6015 by Philipp Hörist at 2017-04-26T21:02:41+02:00
Merge branch 'master' into 'master'

Fix problems with deepcopy

See merge request !6
- - - - -


1 changed file:

- nbxmpp/dispatcher_nb.py


Changes:

=====================================
nbxmpp/dispatcher_nb.py
=====================================
--- a/nbxmpp/dispatcher_nb.py
+++ b/nbxmpp/dispatcher_nb.py
@@ -571,23 +571,23 @@ class XMPPDispatcher(PlugIn):
                 if self._owner._registered_name and not stanza.getAttr('from'):
                     stanza.setAttr('from', self._owner._registered_name)
 
+        self._owner.Connection.send(stanza, now)
+
         # If no ID then it is a whitespace
         if self.sm and self.sm.enabled and ID:
-            stanza_copy = copy.deepcopy(stanza)
             # add timestamp to message stanza in queue
-            if stanza_copy.getName() == 'message' and \
-            (stanza_copy.getType() == 'chat' or stanza_copy.getType() == 
'groupchat'):
-                our_jid = stanza_copy.getAttr('from')
-                timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', 
time.gmtime(None))
-                stanza_copy.addChild('delay', namespace=NS_DELAY2,
-                        attrs={'from': our_jid or "Gajim", 'stamp': timestamp})
-            self.sm.uqueue.append(stanza_copy)
+            if (stanza.getName() == 'message' and
+                    stanza.getType() in ('chat', 'groupchat')):
+                our_jid = stanza.getAttr('from')
+                timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
+                stanza.addChild('delay', namespace=NS_DELAY2,
+                                attrs={'from': our_jid or 'Gajim',
+                                       'stamp': timestamp})
+            self.sm.uqueue.append(stanza)
             self.sm.out_h += 1
 
-        self._owner.Connection.send(stanza, now)
-
-        if self.sm and self.sm.enabled and ID and len(self.sm.uqueue) > 
self.sm.max_queue:
-            self.sm.request_ack()
+            if len(self.sm.uqueue) > self.sm.max_queue:
+                self.sm.request_ack()
 
         return ID
 



View it on GitLab: 
https://dev.gajim.org/gajim/python-nbxmpp/compare/23a410277ac89e5cd69030c2f69d78b840dca778...9cfe60153dfb0931ffcba6f8b149c352ef6d5144
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to