From b704e27abcb831f0ad2cc9d5d743352f4ee7aa96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Wed, 6 Mar 2019 23:03:45 +0100 Subject: [PATCH] Write correct show values to database Since the refactor we wrote accidentally string instead of int --- gajim/common/helpers.py | 4 ++++ gajim/common/modules/presence.py | 7 +++---- gajim/history_manager.py | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py index 4144488f7..cfafadf29 100644 --- a/gajim/common/helpers.py +++ b/gajim/common/helpers.py @@ -56,6 +56,7 @@ from gajim.common import configpaths from gajim.common.i18n import Q_ from gajim.common.i18n import _ from gajim.common.i18n import ngettext +from gajim.common.const import ShowConstant log = logging.getLogger('gajim.c.helpers') @@ -246,6 +247,9 @@ def get_uf_show(show, use_mnemonic=False): If use_mnemonic is True, it adds _ so GUI should call with True for accessibility issues """ + if isinstance(show, ShowConstant): + show = show.name.lower() + if show == 'dnd': if use_mnemonic: uf_show = _('_Busy') diff --git a/gajim/common/modules/presence.py b/gajim/common/modules/presence.py index 4cc644583..7773c6e7e 100644 --- a/gajim/common/modules/presence.py +++ b/gajim/common/modules/presence.py @@ -25,6 +25,7 @@ from gajim.common import app from gajim.common.i18n import _ from gajim.common.nec import NetworkEvent from gajim.common.const import KindConstant +from gajim.common.const import ShowConstant from gajim.common.helpers import prepare_and_validate_gpg_keyID log = logging.getLogger('gajim.c.m.presence') @@ -236,11 +237,9 @@ class Presence: if not app.config.should_log(self._account, properties.jid.getBare()): return - # TODO: Refactor + show = ShowConstant[properties.show.name] if properties.type.is_unavailable: - show = 'offline' - else: - show = properties.show.value + show = ShowConstant.OFFLINE app.logger.insert_into_logs(self._account, properties.jid.getBare(), diff --git a/gajim/history_manager.py b/gajim/history_manager.py index f5bf8fdf7..ea72e21f0 100644 --- a/gajim/history_manager.py +++ b/gajim/history_manager.py @@ -50,6 +50,7 @@ from gajim.common.i18n import _ from gajim.common.const import StyleAttr from gajim.common.const import JIDConstant from gajim.common.const import KindConstant +from gajim.common.const import ShowConstant def is_standalone(): # Determine if we are in standalone mode @@ -398,7 +399,8 @@ class HistoryManager: message = '' else: message = ' : ' + message - message = helpers.get_uf_show(show) + message + + message = helpers.get_uf_show(ShowConstant(show)) + message message_ = '