Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
fa74adc8 by wurstsalat at 2021-12-07T21:16:25+01:00
BaseControl: Process status messages
Fixes #10692
- - - - -
ea137625 by wurstsalat at 2021-12-07T21:16:41+01:00
Archive: Don’t load kind ERROR messages
- - - - -
2 changed files:
- gajim/common/storage/archive.py
- gajim/gtk/controls/base.py
Changes:
=====================================
gajim/common/storage/archive.py
=====================================
@@ -332,6 +332,8 @@ def get_conversation_before_after(self, account, jid,
before, timestamp,
"""
jids = [jid]
account_id = self.get_account_id(account)
+ kinds = map(str, [KindConstant.ERROR])
+
if before:
time_order = 'AND time < ? ORDER BY time DESC, log_line_id DESC'
else:
@@ -344,10 +346,12 @@ def get_conversation_before_after(self, account, jid,
before, timestamp,
marker as "marker [marker]"
FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
AND account_id = {account_id}
+ AND kind NOT IN ({kinds})
{time_order}
LIMIT ?
'''.format(jids=', '.join('?' * len(jids)),
account_id=account_id,
+ kinds=', '.join(kinds),
time_order=time_order)
return self._con.execute(
@@ -443,6 +447,7 @@ def get_conversation_around(self, account, jid, timestamp):
"""
jids = [jid]
account_id = self.get_account_id(account)
+ kinds = map(str, [KindConstant.ERROR])
n_lines = 20
sql_before = '''
@@ -452,11 +457,13 @@ def get_conversation_around(self, account, jid,
timestamp):
marker as "marker [marker]"
FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
AND account_id = {account_id}
+ AND kind NOT IN ({kinds})
AND time < ?
ORDER BY time DESC, log_line_id DESC
LIMIT ?
'''.format(jids=', '.join('?' * len(jids)),
- account_id=account_id)
+ account_id=account_id,
+ kinds=', '.join(kinds))
sql_at_after = '''
SELECT contact_name, time, kind, show, message, subject,
additional_data, log_line_id, message_id, stanza_id,
@@ -464,11 +471,13 @@ def get_conversation_around(self, account, jid,
timestamp):
marker as "marker [marker]"
FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
AND account_id = {account_id}
+ AND kind NOT IN ({kinds})
AND time >= ?
ORDER BY time ASC, log_line_id ASC
LIMIT ?
'''.format(jids=', '.join('?' * len(jids)),
- account_id=account_id)
+ account_id=account_id,
+ kinds=', '.join(kinds))
before = self._con.execute(
sql_before,
tuple(jids) + (timestamp, n_lines)).fetchall()
@@ -494,6 +503,7 @@ def get_conversation_between(self, account, jid, before,
after):
"""
jids = [jid]
account_id = self.get_account_id(account)
+ kinds = map(str, [KindConstant.ERROR])
sql = '''
SELECT contact_name, time, kind, show, message, subject,
@@ -502,10 +512,12 @@ def get_conversation_between(self, account, jid, before,
after):
marker as "marker [marker]"
FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
AND account_id = {account_id}
+ AND kind NOT IN ({kinds})
AND time < ? AND time >= ?
ORDER BY time DESC, log_line_id DESC
'''.format(jids=', '.join('?' * len(jids)),
- account_id=account_id)
+ account_id=account_id,
+ kinds=', '.join(kinds))
return self._con.execute(
sql,
=====================================
gajim/gtk/controls/base.py
=====================================
@@ -29,6 +29,7 @@
from typing import Optional
import os
+import logging
import sys
import time
import uuid
@@ -101,6 +102,8 @@
COPY_MODIFIER = Gdk.ModifierType.CONTROL_MASK
COPY_MODIFIER_KEYS = (Gdk.KEY_Control_L, Gdk.KEY_Control_R)
+log = logging.getLogger('gajim.gui.controls.base')
+
################################################################################
class BaseControl(ChatCommandProcessor, CommandTools, EventHelper):
@@ -1422,6 +1425,11 @@ def add_messages(self, messages):
self.conversation_view.add_call_message(db_message=msg)
continue
+ if msg.kind in (KindConstant.STATUS,
+ KindConstant.GCSTATUS):
+ self.conversation_view.add_info_message(msg.message)
+ continue
+
if not msg.message:
continue
@@ -1439,7 +1447,8 @@ def add_messages(self, messages):
kind = 'outgoing'
contact_name = self.get_our_nick()
else:
- raise ValueError('no kind attribute')
+ log.warning('kind attribute could not be processed'
+ 'while adding message')
if msg.additional_data is not None:
retracted_by = msg.additional_data.get_value('retracted', 'by')
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/54248d4d97e1937835e050cbe5f1ebc8409ade46...ea137625c0e84da8a71a7d302eda90960d772bd2
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/54248d4d97e1937835e050cbe5f1ebc8409ade46...ea137625c0e84da8a71a7d302eda90960d772bd2
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits