Log sent messages with new logger method

- also save stanza id to the DB
This commit is contained in:
Philipp Hörist 2017-08-02 00:08:11 +02:00
parent a01611178d
commit 9d2898bb35
3 changed files with 14 additions and 10 deletions

View File

@ -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,

View File

@ -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(

View File

@ -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):