Merge branch 'master' into 'master'
Fix additional_data in events See merge request gajim/gajim!146
This commit is contained in:
commit
3bf3ddebfe
|
@ -1385,7 +1385,7 @@ class ChatControl(ChatControlBase):
|
||||||
self.print_conversation(event.message, kind, tim=event.time,
|
self.print_conversation(event.message, kind, tim=event.time,
|
||||||
encrypted=event.encrypted, subject=event.subject,
|
encrypted=event.encrypted, subject=event.subject,
|
||||||
xhtml=event.xhtml, displaymarking=event.displaymarking,
|
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):
|
if isinstance(event.msg_log_id, int):
|
||||||
message_ids.append(event.msg_log_id)
|
message_ids.append(event.msg_log_id)
|
||||||
|
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
base_network_events = ['raw-message-received']
|
base_network_events = ['raw-message-received']
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.additional_data = None
|
self.additional_data = {}
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.conn = self.base_event.conn
|
self.conn = self.base_event.conn
|
||||||
|
@ -2696,7 +2696,7 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent):
|
||||||
base_network_events = []
|
base_network_events = []
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.additional_data = None
|
self.additional_data = {}
|
||||||
self.message = None
|
self.message = None
|
||||||
self.keyID = None
|
self.keyID = None
|
||||||
self.type_ = 'chat'
|
self.type_ = 'chat'
|
||||||
|
|
|
@ -83,6 +83,8 @@ class ChatEvent(Event):
|
||||||
self.form_node = form_node
|
self.form_node = form_node
|
||||||
self.displaymarking = displaymarking
|
self.displaymarking = displaymarking
|
||||||
self.sent_forwarded = sent_forwarded
|
self.sent_forwarded = sent_forwarded
|
||||||
|
if additional_data is None:
|
||||||
|
additional_data = {}
|
||||||
self.additional_data = additional_data
|
self.additional_data = additional_data
|
||||||
|
|
||||||
class NormalEvent(ChatEvent):
|
class NormalEvent(ChatEvent):
|
||||||
|
|
|
@ -132,9 +132,8 @@ class Logger:
|
||||||
Row = namedtuple("Row", fields)
|
Row = namedtuple("Row", fields)
|
||||||
named_row = Row(*row)
|
named_row = Row(*row)
|
||||||
if 'additional_data' in fields:
|
if 'additional_data' in fields:
|
||||||
if named_row.additional_data is not None:
|
named_row = named_row._replace(
|
||||||
named_row = named_row._replace(
|
additional_data=json.loads(named_row.additional_data or '{}'))
|
||||||
additional_data=json.loads(named_row.additional_data))
|
|
||||||
return named_row
|
return named_row
|
||||||
|
|
||||||
def dispatch(self, event, error):
|
def dispatch(self, event, error):
|
||||||
|
@ -1113,7 +1112,13 @@ class Logger:
|
||||||
a field in the `logs` table
|
a field in the `logs` table
|
||||||
"""
|
"""
|
||||||
jid_id = self.get_jid_id(jid, kind=kind)
|
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 = '''
|
sql = '''
|
||||||
INSERT INTO logs (jid_id, time, kind, {columns})
|
INSERT INTO logs (jid_id, time, kind, {columns})
|
||||||
VALUES (?, ?, ?, {values})
|
VALUES (?, ?, ?, {values})
|
||||||
|
|
|
@ -2723,7 +2723,7 @@ class RosterWindow:
|
||||||
tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject,
|
tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject,
|
||||||
xhtml=obj.xhtml, displaymarking=obj.displaymarking,
|
xhtml=obj.xhtml, displaymarking=obj.displaymarking,
|
||||||
msg_log_id=obj.msg_log_id, msg_stanza_id=obj.id_, correct_id=obj.correct_id,
|
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:
|
if obj.msg_log_id:
|
||||||
pw = obj.session.control.parent_win
|
pw = obj.session.control.parent_win
|
||||||
end = obj.session.control.was_at_the_end
|
end = obj.session.control.was_at_the_end
|
||||||
|
|
|
@ -273,7 +273,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
displaymarking=obj.displaymarking,
|
displaymarking=obj.displaymarking,
|
||||||
sent_forwarded=obj.forwarded and obj.sent,
|
sent_forwarded=obj.forwarded and obj.sent,
|
||||||
show_in_roster=obj.show_in_roster,
|
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)
|
app.events.add_event(self.conn.name, fjid, event)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue