Philipp Hörist pushed to branch master at gajim / gajim
Commits: fe8eba08 by Philipp Hörist at 2019-11-10T21:10:43Z MAM: Remove some attributes of mam-decrypted-message-received event
- Remove the with_ attribute - Remove the groupchat attribute
Both are available via properties attribute
- - - - - 83af0aa2 by Philipp Hörist at 2019-11-10T21:15:52Z MAM: Remove unused namespace attribute from mam-decrypted-message-received event
- - - - - 2ea0125a by Philipp Hörist at 2019-11-10T21:27:36Z MAM: Pass attributes to event directly
- - - - - f8d76392 by Philipp Hörist at 2019-11-10T21:46:28Z MAM: Remove conn attribute from mam-decrypted-message-received event
- - - - - 2698e995 by Philipp Hörist at 2019-11-10T21:54:34Z MAM: Remove unused attributes from mam-decrypted-message-received event
- - - - -
3 changed files:
- gajim/chat_control.py - gajim/common/modules/mam.py - gajim/groupchat_control.py
Changes:
===================================== gajim/chat_control.py ===================================== @@ -786,18 +786,16 @@ class ChatControl(ChatControlBase): fixed.set_no_show_all(True) self.close_jingle_content(jingle_type)
+ @event_filter(['account']) def _nec_mam_decrypted_message_received(self, obj): - if obj.conn.name != self.account: - return - if obj.properties.type.is_groupchat: return
if obj.properties.is_muc_pm: - if not obj.with_ == self.contact.get_full_jid(): + if not obj.properties.jid == self.contact.get_full_jid(): return else: - if not obj.with_.bareMatch(self.contact.jid): + if not obj.properties.jid.bareMatch(self.contact.jid): return
kind = '' # incoming
===================================== gajim/common/modules/mam.py ===================================== @@ -167,14 +167,14 @@ class MAM(BaseModule): self._log.debug(stanza) raise nbxmpp.NodeProcessed
- event_attrs = {} - - groupchat = properties.type.is_groupchat - - if groupchat: - event_attrs.update(self._parse_gc_attrs(properties)) + is_groupchat = properties.type.is_groupchat + if is_groupchat: + kind = KindConstant.GC_MSG else: - event_attrs.update(self._parse_chat_attrs(properties)) + if properties.from_.bareMatch(self._con.get_own_jid()): + kind = KindConstant.CHAT_MSG_SENT + else: + kind = KindConstant.CHAT_MSG_RECV
stanza_id, message_id = self._get_unique_id(properties)
@@ -184,7 +184,7 @@ class MAM(BaseModule): str(properties.mam.archive), stanza_id, message_id, - groupchat=groupchat): + groupchat=is_groupchat): self._log.info('Found duplicate with stanza-id: %s, ' 'message-id: %s', stanza_id, message_id) raise nbxmpp.NodeProcessed @@ -228,26 +228,10 @@ class MAM(BaseModule): self._log.info('Found duplicate with fallback for mam:1') return
- event_attrs.update( - {'conn': self._con, - 'account': self._account, - 'additional_data': additional_data, - 'groupchat': groupchat, - 'stanza_id': stanza_id, - 'origin_id': message_id, - 'correct_id': parse_correction(properties), - 'archive_jid': properties.mam.archive, - 'msgtxt': properties.body, - 'message': stanza, - 'stanza': stanza, - 'namespace': properties.mam.namespace, - 'properties': properties, - }) - app.logger.insert_into_logs(self._account, with_, properties.mam.timestamp, - event_attrs['kind'], + kind, unread=False, message=msgtxt, contact_name=properties.muc_nickname, @@ -256,21 +240,16 @@ class MAM(BaseModule): message_id=properties.id)
app.nec.push_incoming_event( - NetworkEvent('mam-decrypted-message-received', **event_attrs)) - - @staticmethod - def _parse_gc_attrs(properties): - return {'with_': properties.jid, - 'kind': KindConstant.GC_MSG} - - def _parse_chat_attrs(self, properties): - if properties.from_.bareMatch(self._con.get_own_jid()): - kind = KindConstant.CHAT_MSG_SENT - else: - kind = KindConstant.CHAT_MSG_RECV - - return {'with_': properties.jid, - 'kind': kind} + NetworkEvent('mam-decrypted-message-received', + account=self._account, + additional_data=additional_data, + correct_id=parse_correction(properties), + archive_jid=properties.mam.archive, + msgtxt=properties.body, + properties=properties, + kind=kind, + ) + )
def _is_valid_request(self, properties): valid_id = self._mam_query_ids.get(str(properties.mam.archive), None)
===================================== gajim/groupchat_control.py ===================================== @@ -815,7 +815,7 @@ class GroupchatControl(ChatControlBase):
@event_filter(['account']) def _nec_mam_decrypted_message_received(self, obj): - if not obj.groupchat: + if not obj.properties.type.is_groupchat: return if obj.archive_jid != self.room_jid: return
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/85a59711fd1feac1fde1aeb55d25315ef2...