Daniel Brötzmann pushed to branch master at gajim / gajim

Commits:

2 changed files:

Changes:

  • gajim/common/storage/archive.py
    ... ... @@ -332,6 +332,8 @@ def get_conversation_before_after(self, account, jid, before, timestamp,
    332 332
             """
    
    333 333
             jids = [jid]
    
    334 334
             account_id = self.get_account_id(account)
    
    335
    +        kinds = map(str, [KindConstant.ERROR])
    
    336
    +
    
    335 337
             if before:
    
    336 338
                 time_order = 'AND time < ? ORDER BY time DESC, log_line_id DESC'
    
    337 339
             else:
    
    ... ... @@ -344,10 +346,12 @@ def get_conversation_before_after(self, account, jid, before, timestamp,
    344 346
                        marker as "marker [marker]"
    
    345 347
                 FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
    
    346 348
                 AND account_id = {account_id}
    
    349
    +            AND kind NOT IN ({kinds})
    
    347 350
                 {time_order}
    
    348 351
                 LIMIT ?
    
    349 352
                 '''.format(jids=', '.join('?' * len(jids)),
    
    350 353
                            account_id=account_id,
    
    354
    +                       kinds=', '.join(kinds),
    
    351 355
                            time_order=time_order)
    
    352 356
     
    
    353 357
             return self._con.execute(
    
    ... ... @@ -443,6 +447,7 @@ def get_conversation_around(self, account, jid, timestamp):
    443 447
             """
    
    444 448
             jids = [jid]
    
    445 449
             account_id = self.get_account_id(account)
    
    450
    +        kinds = map(str, [KindConstant.ERROR])
    
    446 451
             n_lines = 20
    
    447 452
     
    
    448 453
             sql_before = '''
    
    ... ... @@ -452,11 +457,13 @@ def get_conversation_around(self, account, jid, timestamp):
    452 457
                        marker as "marker [marker]"
    
    453 458
                 FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
    
    454 459
                 AND account_id = {account_id}
    
    460
    +            AND kind NOT IN ({kinds})
    
    455 461
                 AND time < ?
    
    456 462
                 ORDER BY time DESC, log_line_id DESC
    
    457 463
                 LIMIT ?
    
    458 464
                 '''.format(jids=', '.join('?' * len(jids)),
    
    459
    -                       account_id=account_id)
    
    465
    +                       account_id=account_id,
    
    466
    +                       kinds=', '.join(kinds))
    
    460 467
             sql_at_after = '''
    
    461 468
                 SELECT contact_name, time, kind, show, message, subject,
    
    462 469
                        additional_data, log_line_id, message_id, stanza_id,
    
    ... ... @@ -464,11 +471,13 @@ def get_conversation_around(self, account, jid, timestamp):
    464 471
                        marker as "marker [marker]"
    
    465 472
                 FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
    
    466 473
                 AND account_id = {account_id}
    
    474
    +            AND kind NOT IN ({kinds})
    
    467 475
                 AND time >= ?
    
    468 476
                 ORDER BY time ASC, log_line_id ASC
    
    469 477
                 LIMIT ?
    
    470 478
                 '''.format(jids=', '.join('?' * len(jids)),
    
    471
    -                       account_id=account_id)
    
    479
    +                       account_id=account_id,
    
    480
    +                       kinds=', '.join(kinds))
    
    472 481
             before = self._con.execute(
    
    473 482
                 sql_before,
    
    474 483
                 tuple(jids) + (timestamp, n_lines)).fetchall()
    
    ... ... @@ -494,6 +503,7 @@ def get_conversation_between(self, account, jid, before, after):
    494 503
             """
    
    495 504
             jids = [jid]
    
    496 505
             account_id = self.get_account_id(account)
    
    506
    +        kinds = map(str, [KindConstant.ERROR])
    
    497 507
     
    
    498 508
             sql = '''
    
    499 509
                 SELECT contact_name, time, kind, show, message, subject,
    
    ... ... @@ -502,10 +512,12 @@ def get_conversation_between(self, account, jid, before, after):
    502 512
                        marker as "marker [marker]"
    
    503 513
                 FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
    
    504 514
                 AND account_id = {account_id}
    
    515
    +            AND kind NOT IN ({kinds})
    
    505 516
                 AND time < ? AND time >= ?
    
    506 517
                 ORDER BY time DESC, log_line_id DESC
    
    507 518
                 '''.format(jids=', '.join('?' * len(jids)),
    
    508
    -                       account_id=account_id)
    
    519
    +                       account_id=account_id,
    
    520
    +                       kinds=', '.join(kinds))
    
    509 521
     
    
    510 522
             return self._con.execute(
    
    511 523
                 sql,
    

  • gajim/gtk/controls/base.py
    ... ... @@ -29,6 +29,7 @@
    29 29
     from typing import Optional
    
    30 30
     
    
    31 31
     import os
    
    32
    +import logging
    
    32 33
     import sys
    
    33 34
     import time
    
    34 35
     import uuid
    
    ... ... @@ -101,6 +102,8 @@
    101 102
         COPY_MODIFIER = Gdk.ModifierType.CONTROL_MASK
    
    102 103
         COPY_MODIFIER_KEYS = (Gdk.KEY_Control_L, Gdk.KEY_Control_R)
    
    103 104
     
    
    105
    +log = logging.getLogger('gajim.gui.controls.base')
    
    106
    +
    
    104 107
     
    
    105 108
     ################################################################################
    
    106 109
     class BaseControl(ChatCommandProcessor, CommandTools, EventHelper):
    
    ... ... @@ -1422,6 +1425,11 @@ def add_messages(self, messages):
    1422 1425
                     self.conversation_view.add_call_message(db_message=msg)
    
    1423 1426
                     continue
    
    1424 1427
     
    
    1428
    +            if msg.kind in (KindConstant.STATUS,
    
    1429
    +                            KindConstant.GCSTATUS):
    
    1430
    +                self.conversation_view.add_info_message(msg.message)
    
    1431
    +                continue
    
    1432
    +
    
    1425 1433
                 if not msg.message:
    
    1426 1434
                     continue
    
    1427 1435
     
    
    ... ... @@ -1439,7 +1447,8 @@ def add_messages(self, messages):
    1439 1447
                     kind = 'outgoing'
    
    1440 1448
                     contact_name = self.get_our_nick()
    
    1441 1449
                 else:
    
    1442
    -                raise ValueError('no kind attribute')
    
    1450
    +                log.warning('kind attribute could not be processed'
    
    1451
    +                            'while adding message')
    
    1443 1452
     
    
    1444 1453
                 if msg.additional_data is not None:
    
    1445 1454
                     retracted_by = msg.additional_data.get_value('retracted', 'by')