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

Commits:

3 changed files:

Changes:

  • nbxmpp/modules/entity_caps.py
    ... ... @@ -57,6 +57,7 @@ class EntityCaps(BaseModule):
    57 57
                 return
    
    58 58
     
    
    59 59
             iq = stanza.buildReply('result')
    
    60
    +        iq.setQuerynode(self._node)
    
    60 61
             query = iq.getQuery()
    
    61 62
             for identity in self._caps.identities:
    
    62 63
                 query.addChild(node=identity.get_node())
    

  • nbxmpp/smacks.py
    ... ... @@ -126,14 +126,13 @@ class Smacks:
    126 126
                 # We did not yet sent 'enable' so the server
    
    127 127
                 # will not count our stanzas
    
    128 128
                 return
    
    129
    -        if (stanza.getName() == 'message' and
    
    130
    -                stanza.getType() in ('chat', 'groupchat')):
    
    131
    -            timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
    
    132
    -            attrs = {'stamp': timestamp}
    
    133
    -            if stanza.getType() != 'groupchat':
    
    134
    -                # Dont leak our JID to Groupchats
    
    135
    -                attrs['from'] = str(self._client.get_bound_jid())
    
    136
    -            stanza.addChild('delay', namespace=NS_DELAY2, attrs=attrs)
    
    129
    +
    
    130
    +        # Make a full copy so we dont run into problems when
    
    131
    +        # the stanza is modified after sending for some reason
    
    132
    +        stanza = type(stanza)(node=str(stanza))
    
    133
    +
    
    134
    +        self._add_delay(stanza)
    
    135
    +
    
    137 136
             self._uqueue.append(stanza)
    
    138 137
             self._log.debug('OUT, %s', stanza.getName())
    
    139 138
             self._out_h += 1
    
    ... ... @@ -144,6 +143,22 @@ class Smacks:
    144 143
             if (self._in_h - self._acked_h) > 100:
    
    145 144
                 self._send_ack()
    
    146 145
     
    
    146
    +    def _add_delay(self, stanza):
    
    147
    +        if stanza.getName() != 'message':
    
    148
    +            return
    
    149
    +
    
    150
    +        if stanza.getType() not in ('chat', 'groupchat'):
    
    151
    +            return
    
    152
    +
    
    153
    +        timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
    
    154
    +        attrs = {'stamp': timestamp}
    
    155
    +
    
    156
    +        if stanza.getType() != 'groupchat':
    
    157
    +            # Dont leak our JID to Groupchats
    
    158
    +            attrs['from'] = str(self._client.get_bound_jid())
    
    159
    +
    
    160
    +        stanza.addChild('delay', namespace=NS_DELAY2, attrs=attrs)
    
    161
    +
    
    147 162
         def _resend_queue(self):
    
    148 163
             """
    
    149 164
             Resends unsent stanzas when a new session is established.
    

  • nbxmpp/websocket.py
    ... ... @@ -139,7 +139,7 @@ class WebsocketConnection(Connection):
    139 139
             data = str(stanza)
    
    140 140
             self._websocket.send_text(data)
    
    141 141
             self._log_stanza(data, received=False)
    
    142
    -        self.notify('data-sent', data)
    
    142
    +        self.notify('data-sent', stanza)
    
    143 143
     
    
    144 144
         def disconnect(self):
    
    145 145
             if self._state == TCPState.CONNECTING: