From 9d2898bb359fbd583c0b4aff450616baeeef5476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Wed, 2 Aug 2017 00:08:11 +0200 Subject: [PATCH] Log sent messages with new logger method - also save stanza id to the DB --- gajim/chat_control.py | 2 +- gajim/common/connection.py | 14 ++++++-------- gajim/common/connection_handlers_events.py | 8 +++++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gajim/chat_control.py b/gajim/chat_control.py index 4c9bfdcad..88a281bb9 100644 --- a/gajim/chat_control.py +++ b/gajim/chat_control.py @@ -927,7 +927,7 @@ class ChatControl(ChatControlBase): gtkgui_helpers.remove_css_class( self.msg_textview, 'msgcorrectingcolor') - self.print_conversation(message, self.contact.jid, + self.print_conversation(message, self.contact.jid, tim=obj.timestamp, encrypted=encrypted, xep0184_id=xep0184_id, xhtml=xhtml, displaymarking=displaymarking, msg_stanza_id=id_, correct_id=obj.correct_id, diff --git a/gajim/common/connection.py b/gajim/common/connection.py index f3d0251dc..d35328db6 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -433,14 +433,11 @@ class CommonConnection: if not message: return - if obj.type_ == 'chat': - kind = 'chat_msg_sent' - else: - kind = 'single_msg_sent' - - gajim.logger.write( - kind, jid, message, subject=obj.subject, - additional_data=obj.additional_data) + gajim.logger.insert_into_logs(jid, obj.timestamp, obj.kind, + message=message, + subject=obj.subject, + additional_data=obj.additional_data, + stanza_id=obj.stanza_id) def ack_subscribed(self, jid): """ @@ -2051,6 +2048,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.send_message(obj) def send_message(self, obj): + obj.timestamp = time.time() obj.stanza_id = self.connection.send(obj.msg_iq, now=obj.now) gajim.nec.push_incoming_event(MessageSentEvent( diff --git a/gajim/common/connection_handlers_events.py b/gajim/common/connection_handlers_events.py index 8bdc03cf7..8010f8567 100644 --- a/gajim/common/connection_handlers_events.py +++ b/gajim/common/connection_handlers_events.py @@ -2707,10 +2707,12 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent): base_network_events = [] def init(self): - self.additional_data = {} + self.additional_data = None self.message = '' self.keyID = None self.type_ = 'chat' + self.kind = None + self.timestamp = None self.subject = '' self.chatstate = None self.stanza_id = None @@ -2741,6 +2743,10 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent): return self.jid def generate(self): + if self.type_ == 'chat': + self.kind = KindConstant.CHAT_MSG_SENT + else: + self.kind = KindConstant.SINGLE_MSG_SENT return True class StanzaMessageOutgoingEvent(nec.NetworkOutgoingEvent):