From bb44cd925c9eaed6a2b7020a2cac69580d6acdac Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Fri, 16 Feb 2024 12:33:07 +0000 Subject: [PATCH] Fix error upon attempt to edit filter via form while another form is not set --- slixfeed/sqlite.py | 3 +-- slixfeed/version.py | 4 ++-- slixfeed/xmpp/client.py | 4 +++- slixfeed/xmpp/process.py | 4 ++++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/slixfeed/sqlite.py b/slixfeed/sqlite.py index 2fb523d..3fbf1ff 100644 --- a/slixfeed/sqlite.py +++ b/slixfeed/sqlite.py @@ -2078,8 +2078,7 @@ def get_filter_value(db_file, key): """ ) par = (key,) - value = cur.execute(sql, par).fetchone()[0] - value = str(value) + value = cur.execute(sql, par).fetchone() return value diff --git a/slixfeed/version.py b/slixfeed/version.py index 420c0cd..1b4c92b 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.8' -__version_info__ = (0, 1, 8) +__version__ = '0.1.9' +__version_info__ = (0, 1, 9) diff --git a/slixfeed/xmpp/client.py b/slixfeed/xmpp/client.py index 4b6a0c2..41bcf0e 100644 --- a/slixfeed/xmpp/client.py +++ b/slixfeed/xmpp/client.py @@ -551,12 +551,14 @@ class Slixfeed(slixmpp.ClientXMPP): form = self['xep_0004'].make_form('form', 'Filters') form['instructions'] = '🛡️ Manage filters' # 🪄️ value = sqlite.get_filter_value(db_file, 'allow') + if value: value = str(value[0]) form.add_field(var='allow', ftype='text-single', label='Allow list', value=value, desc=('Keywords to allow (comma-separated keywords).')) value = sqlite.get_filter_value(db_file, 'deny') + if value: value = str(value[0]) form.add_field(var='deny', ftype='text-single', label='Deny list', @@ -599,7 +601,7 @@ class Slixfeed(slixmpp.ClientXMPP): # an empty form instead of editing a form. # keywords = sqlite.get_filter_value(db_file, key) keywords = '' - val = await config.add_to_list(val, keywords) + val = await config.add_to_list(val, keywords) if val else '' if sqlite.is_filter_key(db_file, key): await sqlite.update_filter_value(db_file, [key, val]) elif val: diff --git a/slixfeed/xmpp/process.py b/slixfeed/xmpp/process.py index cbf18b1..32fef71 100644 --- a/slixfeed/xmpp/process.py +++ b/slixfeed/xmpp/process.py @@ -328,6 +328,7 @@ async def message(self, message): if val: db_file = config.get_pathname_to_database(jid_file) keywords = sqlite.get_filter_value(db_file, key) + if keywords: keywords = str(keywords[0]) val = await config.add_to_list(val, keywords) if sqlite.is_filter_key(db_file, key): await sqlite.update_filter_value(db_file, @@ -346,6 +347,7 @@ async def message(self, message): if val: db_file = config.get_pathname_to_database(jid_file) keywords = sqlite.get_filter_value(db_file, key) + if keywords: keywords = str(keywords[0]) val = await config.remove_from_list(val, keywords) if sqlite.is_filter_key(db_file, key): await sqlite.update_filter_value(db_file, @@ -434,6 +436,7 @@ async def message(self, message): if val: db_file = config.get_pathname_to_database(jid_file) keywords = sqlite.get_filter_value(db_file, key) + if keywords: keywords = str(keywords[0]) val = await config.add_to_list(val, keywords) if sqlite.is_filter_key(db_file, key): await sqlite.update_filter_value(db_file, @@ -452,6 +455,7 @@ async def message(self, message): if val: db_file = config.get_pathname_to_database(jid_file) keywords = sqlite.get_filter_value(db_file, key) + if keywords: keywords = str(keywords[0]) val = await config.remove_from_list(val, keywords) if sqlite.is_filter_key(db_file, key): await sqlite.update_filter_value(db_file,