Philipp Hörist pushed to branch master at gajim / gajim

Commits:

3 changed files:

Changes:

  • gajim/chat_control.py
    ... ... @@ -786,18 +786,16 @@ class ChatControl(ChatControlBase):
    786 786
                 fixed.set_no_show_all(True)
    
    787 787
                 self.close_jingle_content(jingle_type)
    
    788 788
     
    
    789
    +    @event_filter(['account'])
    
    789 790
         def _nec_mam_decrypted_message_received(self, obj):
    
    790
    -        if obj.conn.name != self.account:
    
    791
    -            return
    
    792
    -
    
    793 791
             if obj.properties.type.is_groupchat:
    
    794 792
                 return
    
    795 793
     
    
    796 794
             if obj.properties.is_muc_pm:
    
    797
    -            if not obj.with_ == self.contact.get_full_jid():
    
    795
    +            if not obj.properties.jid == self.contact.get_full_jid():
    
    798 796
                     return
    
    799 797
             else:
    
    800
    -            if not obj.with_.bareMatch(self.contact.jid):
    
    798
    +            if not obj.properties.jid.bareMatch(self.contact.jid):
    
    801 799
                     return
    
    802 800
     
    
    803 801
             kind = '' # incoming
    

  • gajim/common/modules/mam.py
    ... ... @@ -167,14 +167,14 @@ class MAM(BaseModule):
    167 167
                 self._log.debug(stanza)
    
    168 168
                 raise nbxmpp.NodeProcessed
    
    169 169
     
    
    170
    -        event_attrs = {}
    
    171
    -
    
    172
    -        groupchat = properties.type.is_groupchat
    
    173
    -
    
    174
    -        if groupchat:
    
    175
    -            event_attrs.update(self._parse_gc_attrs(properties))
    
    170
    +        is_groupchat = properties.type.is_groupchat
    
    171
    +        if is_groupchat:
    
    172
    +            kind = KindConstant.GC_MSG
    
    176 173
             else:
    
    177
    -            event_attrs.update(self._parse_chat_attrs(properties))
    
    174
    +            if properties.from_.bareMatch(self._con.get_own_jid()):
    
    175
    +                kind = KindConstant.CHAT_MSG_SENT
    
    176
    +            else:
    
    177
    +                kind = KindConstant.CHAT_MSG_RECV
    
    178 178
     
    
    179 179
             stanza_id, message_id = self._get_unique_id(properties)
    
    180 180
     
    
    ... ... @@ -184,7 +184,7 @@ class MAM(BaseModule):
    184 184
                                              str(properties.mam.archive),
    
    185 185
                                              stanza_id,
    
    186 186
                                              message_id,
    
    187
    -                                         groupchat=groupchat):
    
    187
    +                                         groupchat=is_groupchat):
    
    188 188
                     self._log.info('Found duplicate with stanza-id: %s, '
    
    189 189
                                    'message-id: %s', stanza_id, message_id)
    
    190 190
                     raise nbxmpp.NodeProcessed
    
    ... ... @@ -228,26 +228,10 @@ class MAM(BaseModule):
    228 228
                     self._log.info('Found duplicate with fallback for mam:1')
    
    229 229
                     return
    
    230 230
     
    
    231
    -        event_attrs.update(
    
    232
    -            {'conn': self._con,
    
    233
    -             'account': self._account,
    
    234
    -             'additional_data': additional_data,
    
    235
    -             'groupchat': groupchat,
    
    236
    -             'stanza_id': stanza_id,
    
    237
    -             'origin_id': message_id,
    
    238
    -             'correct_id': parse_correction(properties),
    
    239
    -             'archive_jid': properties.mam.archive,
    
    240
    -             'msgtxt': properties.body,
    
    241
    -             'message': stanza,
    
    242
    -             'stanza': stanza,
    
    243
    -             'namespace': properties.mam.namespace,
    
    244
    -             'properties': properties,
    
    245
    -             })
    
    246
    -
    
    247 231
             app.logger.insert_into_logs(self._account,
    
    248 232
                                         with_,
    
    249 233
                                         properties.mam.timestamp,
    
    250
    -                                    event_attrs['kind'],
    
    234
    +                                    kind,
    
    251 235
                                         unread=False,
    
    252 236
                                         message=msgtxt,
    
    253 237
                                         contact_name=properties.muc_nickname,
    
    ... ... @@ -256,21 +240,16 @@ class MAM(BaseModule):
    256 240
                                         message_id=properties.id)
    
    257 241
     
    
    258 242
             app.nec.push_incoming_event(
    
    259
    -            NetworkEvent('mam-decrypted-message-received', **event_attrs))
    
    260
    -
    
    261
    -    @staticmethod
    
    262
    -    def _parse_gc_attrs(properties):
    
    263
    -        return {'with_': properties.jid,
    
    264
    -                'kind': KindConstant.GC_MSG}
    
    265
    -
    
    266
    -    def _parse_chat_attrs(self, properties):
    
    267
    -        if properties.from_.bareMatch(self._con.get_own_jid()):
    
    268
    -            kind = KindConstant.CHAT_MSG_SENT
    
    269
    -        else:
    
    270
    -            kind = KindConstant.CHAT_MSG_RECV
    
    271
    -
    
    272
    -        return {'with_': properties.jid,
    
    273
    -                'kind': kind}
    
    243
    +            NetworkEvent('mam-decrypted-message-received',
    
    244
    +                         account=self._account,
    
    245
    +                         additional_data=additional_data,
    
    246
    +                         correct_id=parse_correction(properties),
    
    247
    +                         archive_jid=properties.mam.archive,
    
    248
    +                         msgtxt=properties.body,
    
    249
    +                         properties=properties,
    
    250
    +                         kind=kind,
    
    251
    +                         )
    
    252
    +        )
    
    274 253
     
    
    275 254
         def _is_valid_request(self, properties):
    
    276 255
             valid_id = self._mam_query_ids.get(str(properties.mam.archive), None)
    

  • gajim/groupchat_control.py
    ... ... @@ -815,7 +815,7 @@ class GroupchatControl(ChatControlBase):
    815 815
     
    
    816 816
         @event_filter(['account'])
    
    817 817
         def _nec_mam_decrypted_message_received(self, obj):
    
    818
    -        if not obj.groupchat:
    
    818
    +        if not obj.properties.type.is_groupchat:
    
    819 819
                 return
    
    820 820
             if obj.archive_jid != self.room_jid:
    
    821 821
                 return