Philipp Hörist pushed to branch master at gajim / gajim
Commits: 2e266601 by Philipp Hörist at 2019-11-05T18:14:20Z Remove nick and nickname attribute from gc-message-received event
It's available via properties attribute
- - - - - 74ac7653 by Philipp Hörist at 2019-11-05T18:14:21Z Remove nick attribute from mam-decrypted-message-received event
It's available via properties attribute
- - - - - b8d83eb5 by Philipp Hörist at 2019-11-05T18:14:25Z Remove unused real_jid attribute from mam-decrypted-message-received event
- - - - -
4 changed files:
- gajim/common/connection_handlers_events.py - gajim/common/modules/mam.py - gajim/common/modules/message.py - gajim/groupchat_control.py
Changes:
===================================== gajim/common/connection_handlers_events.py ===================================== @@ -423,7 +423,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): sound = msg_obj.gc_control.highlighting_for_message( msg_obj.msgtxt, msg_obj.properties.timestamp)[1]
- if msg_obj.nickname != msg_obj.gc_control.nick: + if msg_obj.properties.muc_nickname != msg_obj.gc_control.nick: self.do_sound = True if sound == 'received': self.sound_event = 'muc_message_received' @@ -471,7 +471,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): self.popup_title = i18n.ngettext( 'New message from %(nickname)s', '%(n_msgs)i unread messages in %(groupchat_name)s', - count) % {'nickname': msg_obj.nick, + count) % {'nickname': msg_obj.properties.muc_nickname, 'n_msgs': count, 'groupchat_name': contact.get_shown_name()}
===================================== gajim/common/modules/mam.py ===================================== @@ -250,7 +250,7 @@ class MAM(BaseModule): event_attrs['kind'], unread=False, message=msgtxt, - contact_name=event_attrs['nick'], + contact_name=properties.muc_nickname, additional_data=additional_data, stanza_id=stanza_id, message_id=properties.id) @@ -260,12 +260,7 @@ class MAM(BaseModule):
@staticmethod def _parse_gc_attrs(properties): - real_jid = None - if properties.muc_user is not None: - real_jid = properties.muc_user.jid return {'with_': properties.jid, - 'nick': properties.muc_nickname, - 'real_jid': real_jid, 'kind': KindConstant.GC_MSG}
def _parse_chat_attrs(self, properties): @@ -275,7 +270,6 @@ class MAM(BaseModule): kind = KindConstant.CHAT_MSG_RECV
return {'with_': properties.jid, - 'nick': None, 'kind': kind}
def _is_valid_request(self, properties):
===================================== gajim/common/modules/message.py ===================================== @@ -200,8 +200,6 @@ class Message(BaseModule):
event_attr.update({ 'room_jid': jid, - 'nickname': resource, - 'nick': resource or '', }) event = NetworkEvent('gc-message-received', **event_attr) app.nec.push_incoming_event(event) @@ -236,19 +234,20 @@ class Message(BaseModule): self._check_for_mam_compliance(event.room_jid, event.stanza_id)
if (app.config.should_log(self._account, event.jid) and - event.msgtxt and event.nick): + event.msgtxt and event.properties.muc_nickname): # if not event.nick, it means message comes from room itself # usually it hold description and can be send at each connection # so don't store it in logs - app.logger.insert_into_logs(self._account, - event.jid, - event.properties.timestamp, - KindConstant.GC_MSG, - message=event.msgtxt, - contact_name=event.nick, - additional_data=event.additional_data, - stanza_id=event.stanza_id, - message_id=event.properties.id) + app.logger.insert_into_logs( + self._account, + event.jid, + event.properties.timestamp, + KindConstant.GC_MSG, + message=event.msgtxt, + contact_name=event.properties.muc_nickname, + additional_data=event.additional_data, + stanza_id=event.stanza_id, + message_id=event.properties.id)
def _check_for_mam_compliance(self, room_jid, stanza_id): disco_info = app.logger.get_last_disco_info(room_jid)
===================================== gajim/groupchat_control.py ===================================== @@ -820,7 +820,7 @@ class GroupchatControl(ChatControlBase): if obj.archive_jid != self.room_jid: return self.add_message(obj.msgtxt, - contact=obj.nick, + contact=obj.properties.muc_nickname, tim=obj.properties.mam.timestamp, correct_id=obj.correct_id, message_id=obj.properties.id, @@ -828,17 +828,17 @@ class GroupchatControl(ChatControlBase):
@event_filter(['account', 'room_jid']) def _nec_gc_message_received(self, obj): - if not obj.nick: + if obj.properties.muc_nickname is None: # message from server self.add_message(obj.msgtxt, tim=obj.properties.timestamp, displaymarking=obj.displaymarking, additional_data=obj.additional_data) else: - if obj.nick == self.nick: + if obj.properties.muc_nickname == self.nick: self.last_sent_txt = obj.msgtxt self.add_message(obj.msgtxt, - contact=obj.nick, + contact=obj.properties.muc_nickname, tim=obj.properties.timestamp, displaymarking=obj.displaymarking, correct_id=obj.correct_id,
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/b4797d25a2dfcf297e448cbeae51171d85...