correctly store and restore single message subject. Fixes #8251

This commit is contained in:
Yann Leboulanger 2016-01-31 19:58:51 +01:00
parent 737b689c98
commit 9fbd7efa2a
3 changed files with 12 additions and 11 deletions

View File

@ -2957,7 +2957,8 @@ class ChatControl(ChatControlBase):
local_old_kind = None
self.conv_textview.just_cleared = True
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
if row[1] in (constants.KIND_CHAT_MSG_SENT,
constants.KIND_SINGLE_MSG_SENT):
@ -2978,9 +2979,12 @@ class ChatControl(ChatControlBase):
else:
small_attr = []
xhtml = None
if row[2].startswith('<body '):
xhtml = row[2]
ChatControlBase.print_conversation_line(self, row[2], kind, name,
if msg.startswith('<body '):
xhtml = msg
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'],
small_attr + ['restored_message'], False,
old_kind=local_old_kind, xhtml=xhtml)

View File

@ -522,9 +522,6 @@ class CommonConnection:
log_msg = msg
if original_message is not None:
log_msg = original_message
if subject:
log_msg = _('Subject: %(subject)s\n%(message)s') % \
{'subject': subject, 'message': log_msg}
if log_msg:
if type_ == 'chat':
kind = 'chat_msg_sent'
@ -534,7 +531,7 @@ class CommonConnection:
if xhtml and gajim.config.get('log_xhtml_messages'):
log_msg = '<body xmlns="%s">%s</body>' % (
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:
self.dispatch('DB_ERROR', (_('Disk Write Error'),
str(e)))

View File

@ -585,8 +585,8 @@ class Logger:
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
already logged but pending to be viewed, returns a list of tupples
containg time, kind, message, list with empty tupple if nothing found to
meet our demands
containg time, kind, message, sibject list with empty tupple if nothing
found to meet our demands
"""
try:
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)
try:
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
ORDER BY time DESC LIMIT %d OFFSET %d
''' % (where_sql, constants.KIND_SINGLE_MSG_RECV,