changeset 65ffcdd09223 in /home/hg/repos/gajim

author: Yann Leboulanger <[email protected]>
branches: 
details:http://hg.gajim.org/gajim?cmd=changeset;node=65ffcdd09223
description: correctly store and restore single message subject. Fixes #8251

diffstat:

 src/chat_control.py      |  12 ++++++++----
 src/common/connection.py |   5 +----
 src/common/logger.py     |   6 +++---
 3 files changed, 12 insertions(+), 11 deletions(-)

diffs (74 lines):

diff -r 209d558b9401 -r 65ffcdd09223 src/chat_control.py
--- a/src/chat_control.py       Sun Jan 24 19:12:30 2016 +0000
+++ b/src/chat_control.py       Sun Jan 31 19:58:51 2016 +0100
@@ -2957,7 +2957,8 @@
         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 @@
             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)
diff -r 209d558b9401 -r 65ffcdd09223 src/common/connection.py
--- a/src/common/connection.py  Sun Jan 24 19:12:30 2016 +0000
+++ b/src/common/connection.py  Sun Jan 31 19:58:51 2016 +0100
@@ -522,9 +522,6 @@
                 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 @@
                         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)))
diff -r 209d558b9401 -r 65ffcdd09223 src/common/logger.py
--- a/src/common/logger.py      Sun Jan 24 19:12:30 2016 +0000
+++ b/src/common/logger.py      Sun Jan 31 19:58:51 2016 +0100
@@ -585,8 +585,8 @@
         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 @@
         # 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,
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to