correctly store and restore single message subject. Fixes #8251
This commit is contained in:
parent
737b689c98
commit
9fbd7efa2a
|
@ -2957,7 +2957,8 @@ class ChatControl(ChatControlBase):
|
||||||
local_old_kind = None
|
local_old_kind = None
|
||||||
self.conv_textview.just_cleared = True
|
self.conv_textview.just_cleared = True
|
||||||
for row in rows: # row[0] time, row[1] has kind, row[2] the message
|
for row in rows: # row[0] time, row[1] has kind, row[2] the message
|
||||||
if not row[2]: # message is empty, we don't print it
|
msg = row[2]
|
||||||
|
if not msg: # message is empty, we don't print it
|
||||||
continue
|
continue
|
||||||
if row[1] in (constants.KIND_CHAT_MSG_SENT,
|
if row[1] in (constants.KIND_CHAT_MSG_SENT,
|
||||||
constants.KIND_SINGLE_MSG_SENT):
|
constants.KIND_SINGLE_MSG_SENT):
|
||||||
|
@ -2978,9 +2979,12 @@ class ChatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
small_attr = []
|
small_attr = []
|
||||||
xhtml = None
|
xhtml = None
|
||||||
if row[2].startswith('<body '):
|
if msg.startswith('<body '):
|
||||||
xhtml = row[2]
|
xhtml = msg
|
||||||
ChatControlBase.print_conversation_line(self, row[2], kind, name,
|
if row[3]:
|
||||||
|
msg = _('Subject: %(subject)s\n%(message)s') % \
|
||||||
|
{'subject': row[3], 'message': msg}
|
||||||
|
ChatControlBase.print_conversation_line(self, msg, kind, name,
|
||||||
tim, small_attr, small_attr + ['restored_message'],
|
tim, small_attr, small_attr + ['restored_message'],
|
||||||
small_attr + ['restored_message'], False,
|
small_attr + ['restored_message'], False,
|
||||||
old_kind=local_old_kind, xhtml=xhtml)
|
old_kind=local_old_kind, xhtml=xhtml)
|
||||||
|
|
|
@ -522,9 +522,6 @@ class CommonConnection:
|
||||||
log_msg = msg
|
log_msg = msg
|
||||||
if original_message is not None:
|
if original_message is not None:
|
||||||
log_msg = original_message
|
log_msg = original_message
|
||||||
if subject:
|
|
||||||
log_msg = _('Subject: %(subject)s\n%(message)s') % \
|
|
||||||
{'subject': subject, 'message': log_msg}
|
|
||||||
if log_msg:
|
if log_msg:
|
||||||
if type_ == 'chat':
|
if type_ == 'chat':
|
||||||
kind = 'chat_msg_sent'
|
kind = 'chat_msg_sent'
|
||||||
|
@ -534,7 +531,7 @@ class CommonConnection:
|
||||||
if xhtml and gajim.config.get('log_xhtml_messages'):
|
if xhtml and gajim.config.get('log_xhtml_messages'):
|
||||||
log_msg = '<body xmlns="%s">%s</body>' % (
|
log_msg = '<body xmlns="%s">%s</body>' % (
|
||||||
nbxmpp.NS_XHTML, xhtml)
|
nbxmpp.NS_XHTML, xhtml)
|
||||||
gajim.logger.write(kind, jid, log_msg)
|
gajim.logger.write(kind, jid, log_msg, subject=subject)
|
||||||
except exceptions.PysqliteOperationalError as e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
self.dispatch('DB_ERROR', (_('Disk Write Error'),
|
self.dispatch('DB_ERROR', (_('Disk Write Error'),
|
||||||
str(e)))
|
str(e)))
|
||||||
|
|
|
@ -585,8 +585,8 @@ class Logger:
|
||||||
Accept how many rows to restore and when to time them out (in minutes)
|
Accept how many rows to restore and when to time them out (in minutes)
|
||||||
(mark them as too old) and number of messages that are in queue and are
|
(mark them as too old) and number of messages that are in queue and are
|
||||||
already logged but pending to be viewed, returns a list of tupples
|
already logged but pending to be viewed, returns a list of tupples
|
||||||
containg time, kind, message, list with empty tupple if nothing found to
|
containg time, kind, message, sibject list with empty tupple if nothing
|
||||||
meet our demands
|
found to meet our demands
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.get_jid_id(jid)
|
self.get_jid_id(jid)
|
||||||
|
@ -601,7 +601,7 @@ class Logger:
|
||||||
# 3 - 8 (we avoid the last 2 lines but we still return 5 asked)
|
# 3 - 8 (we avoid the last 2 lines but we still return 5 asked)
|
||||||
try:
|
try:
|
||||||
self.cur.execute('''
|
self.cur.execute('''
|
||||||
SELECT time, kind, message FROM logs
|
SELECT time, kind, message, subject FROM logs
|
||||||
WHERE (%s) AND kind IN (%d, %d, %d, %d, %d) AND time > %d
|
WHERE (%s) AND kind IN (%d, %d, %d, %d, %d) AND time > %d
|
||||||
ORDER BY time DESC LIMIT %d OFFSET %d
|
ORDER BY time DESC LIMIT %d OFFSET %d
|
||||||
''' % (where_sql, constants.KIND_SINGLE_MSG_RECV,
|
''' % (where_sql, constants.KIND_SINGLE_MSG_RECV,
|
||||||
|
|
Loading…
Reference in New Issue