diff --git a/gajim/chat_control.py b/gajim/chat_control.py index bf0ba8a12..57a03f58f 100644 --- a/gajim/chat_control.py +++ b/gajim/chat_control.py @@ -1385,7 +1385,7 @@ class ChatControl(ChatControlBase): self.print_conversation(event.message, kind, tim=event.time, encrypted=event.encrypted, subject=event.subject, xhtml=event.xhtml, displaymarking=event.displaymarking, - correct_id=event.correct_id) + correct_id=event.correct_id, additional_data=event.additional_data) if isinstance(event.msg_log_id, int): message_ids.append(event.msg_log_id) diff --git a/gajim/common/connection_handlers_events.py b/gajim/common/connection_handlers_events.py index 6987cb200..02a3ddf41 100644 --- a/gajim/common/connection_handlers_events.py +++ b/gajim/common/connection_handlers_events.py @@ -1124,7 +1124,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): base_network_events = ['raw-message-received'] def init(self): - self.additional_data = None + self.additional_data = {} def generate(self): self.conn = self.base_event.conn @@ -2696,7 +2696,7 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent): base_network_events = [] def init(self): - self.additional_data = None + self.additional_data = {} self.message = None self.keyID = None self.type_ = 'chat' diff --git a/gajim/common/events.py b/gajim/common/events.py index 3896cc69b..9cf719155 100644 --- a/gajim/common/events.py +++ b/gajim/common/events.py @@ -83,6 +83,8 @@ class ChatEvent(Event): self.form_node = form_node self.displaymarking = displaymarking self.sent_forwarded = sent_forwarded + if additional_data is None: + additional_data = {} self.additional_data = additional_data class NormalEvent(ChatEvent): diff --git a/gajim/common/logger.py b/gajim/common/logger.py index caf13db93..27036b0ce 100644 --- a/gajim/common/logger.py +++ b/gajim/common/logger.py @@ -132,9 +132,8 @@ class Logger: Row = namedtuple("Row", fields) named_row = Row(*row) if 'additional_data' in fields: - if named_row.additional_data is not None: - named_row = named_row._replace( - additional_data=json.loads(named_row.additional_data)) + named_row = named_row._replace( + additional_data=json.loads(named_row.additional_data or '{}')) return named_row def dispatch(self, event, error): @@ -1113,7 +1112,13 @@ class Logger: a field in the `logs` table """ jid_id = self.get_jid_id(jid, kind=kind) - + + if 'additional_data' in kwargs: + if not kwargs['additional_data']: + del kwargs['additional_data'] + else: + kwargs['additional_data'] = json.dumps(kwargs["additional_data"]) + sql = ''' INSERT INTO logs (jid_id, time, kind, {columns}) VALUES (?, ?, ?, {values}) diff --git a/gajim/roster_window.py b/gajim/roster_window.py index e64fc767d..b6b5645cb 100644 --- a/gajim/roster_window.py +++ b/gajim/roster_window.py @@ -2723,7 +2723,7 @@ class RosterWindow: tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject, xhtml=obj.xhtml, displaymarking=obj.displaymarking, msg_log_id=obj.msg_log_id, msg_stanza_id=obj.id_, correct_id=obj.correct_id, - xep0184_id=xep0184_id) + xep0184_id=xep0184_id, additional_data=obj.additional_data) if obj.msg_log_id: pw = obj.session.control.parent_win end = obj.session.control.was_at_the_end diff --git a/gajim/session.py b/gajim/session.py index afb3b552e..de18f912d 100644 --- a/gajim/session.py +++ b/gajim/session.py @@ -273,7 +273,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): displaymarking=obj.displaymarking, sent_forwarded=obj.forwarded and obj.sent, show_in_roster=obj.show_in_roster, - show_in_systray=obj.show_in_systray) + show_in_systray=obj.show_in_systray, + additional_data=obj.additional_data) app.events.add_event(self.conn.name, fjid, event)