Commit d9ab39b0 authored by Markus Böhme's avatar Markus Böhme

Fix loading of additional_data column from log database

Currently, the additional_data column is not correctly loaded from the
log database in the logger module's methods get_last_conversation_lines
and get_conversation_for_date. While the JSON data in the column is
parsed, the parsed value is not saved, because the code assumes that
changes to a loop variable are reflected in the list that is iterated
over. Instead, the unparsed JSON string is returned. Fix this by building
a separate list with the JSON string replaced by the parsed JSON object.
parent 49a5bb63
......@@ -609,13 +609,16 @@ class Logger:
restore_how_many_rows, pending_how_many), jid_tuple)
results = self.cur.fetchall()
messages = []
for entry in results:
entry = list(entry)
entry[4] = json.loads(entry[4])
additional_data = json.loads(entry[4])
parsed_entry = entry[:4] + (additional_data, ) + entry[5:]
messages.append(parsed_entry)
except sqlite.DatabaseError:
raise exceptions.DatabaseMalformed
results.reverse()
return results
messages.reverse()
return messages
def get_unix_time_from_date(self, year, month, day):
# year (fe 2005), month (fe 11), day (fe 25)
......@@ -655,10 +658,13 @@ class Logger:
''' % (where_sql, start_of_day, last_second_of_day), jid_tuple)
results = self.cur.fetchall()
messages = []
for entry in results:
entry = list(entry)
entry[6] = json.loads(entry[6])
return results
additional_data = json.loads(entry[6])
parsed_entry = entry[:6] + (additional_data, ) + entry[7:]
messages.append(parsed_entry)
return messages
def get_search_results_for_query(self, jid, query, account, year=False,
month=False, day=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment