forked from sch/Slixfeed
Fix error upon attempt to edit filter via form while another form is not set
This commit is contained in:
parent
10762a69e4
commit
bb44cd925c
4 changed files with 10 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
__version__ = '0.1.8'
|
||||
__version_info__ = (0, 1, 8)
|
||||
__version__ = '0.1.9'
|
||||
__version_info__ = (0, 1, 9)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue