From 8e76ae4506b438459bcbc5859b2604a1d019df2c Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Wed, 13 Mar 2024 11:57:53 +0000 Subject: [PATCH] Fix saving of bookmarks via bookmark manager. Fix default settings file. --- slixfeed/assets/settings.toml | 7 +++--- slixfeed/config.py | 2 ++ slixfeed/version.py | 4 +-- slixfeed/xmpp/bookmark.py | 9 ++++--- slixfeed/xmpp/client.py | 47 ++++++++++++++++++----------------- slixfeed/xmpp/component.py | 47 ++++++++++++++++++----------------- slixfeed/xmpp/connect.py | 7 ------ slixfeed/xmpp/process.py | 1 + 8 files changed, 61 insertions(+), 63 deletions(-) diff --git a/slixfeed/assets/settings.toml b/slixfeed/assets/settings.toml index 0a8698c..58a59a6 100644 --- a/slixfeed/assets/settings.toml +++ b/slixfeed/assets/settings.toml @@ -4,8 +4,8 @@ [default] archive = 50 # Maximum items to archive (0 - 500) check = 120 # Source check interval (recommended 90; minimum 10) -enabled = 1# Work status (Value 0 to disable) -filter = 0 # Enable filters (Value 1 to enable) +enabled = 1 # Work status (Value 0 to disable) +filter = 0 # Enable filters (Value 1 to enable) interval = 300 # Update interval (Minimum value 10) length = 300 # Maximum length of summary (Value 0 to disable) media = 0 # Display media (audio, image, video) when available @@ -25,7 +25,6 @@ formatting = """ {link} {feed_title} [{ix}] - """ # Utilized in case of missing protocol support. @@ -38,7 +37,7 @@ tor = "" yggdrasil = "" [network] -http_proxy = "http://localhost:8118" +http_proxy = "" user_agent = "Slixfeed/0.1" clearnet = 0 # Enable policed DNS system (not recommended) i2p = 1 # Enable I2P mixnet system (safer) diff --git a/slixfeed/config.py b/slixfeed/config.py index 1a58344..97337fc 100644 --- a/slixfeed/config.py +++ b/slixfeed/config.py @@ -67,6 +67,8 @@ class Config: return result async def set_setting_value(settings, jid_bare, db_file, key, val): + print('key and val (inside)') + print(key, val) key = key.lower() key_val = [key, val] settings[jid_bare][key] = val diff --git a/slixfeed/version.py b/slixfeed/version.py index 119e538..bf78382 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.39' -__version_info__ = (0, 1, 39) +__version__ = '0.1.40' +__version_info__ = (0, 1, 40) diff --git a/slixfeed/xmpp/bookmark.py b/slixfeed/xmpp/bookmark.py index f68cdaa..d61f560 100644 --- a/slixfeed/xmpp/bookmark.py +++ b/slixfeed/xmpp/bookmark.py @@ -41,11 +41,11 @@ class XmppBookmark: conferences = result['private']['bookmarks']['conferences'] groupchats = [] for conference in conferences: - groupchats.extend([conference]) + if conference['jid'] != properties['jid']: + groupchats.extend([conference]) if properties: properties['jid'] = properties['room'] + '@' + properties['host'] if not properties['alias']: properties['alias'] = self.alias - else: properties = { 'jid' : jid, @@ -62,7 +62,7 @@ class XmppBookmark: # if groupchat['jid'] == groupchat['name']: # groupchat['name'] = groupchat['name'].split('@')[0] bookmarks.add_conference(groupchat['jid'], - groupchat['alias'], + groupchat['nick'], name=groupchat['name'], autojoin=groupchat['autojoin'], password=groupchat['password']) @@ -71,7 +71,8 @@ class XmppBookmark: name=properties['name'], autojoin=properties['autojoin'], password=properties['password']) - await self.plugin['xep_0048'].set_bookmarks(bookmarks) + # await self.plugin['xep_0048'].set_bookmarks(bookmarks) + self.plugin['xep_0048'].set_bookmarks(bookmarks) # bookmarks = Bookmarks() # await self.plugin['xep_0048'].set_bookmarks(bookmarks) # print(await self.plugin['xep_0048'].get_bookmarks()) diff --git a/slixfeed/xmpp/client.py b/slixfeed/xmpp/client.py index 0bd575f..be09e8f 100644 --- a/slixfeed/xmpp/client.py +++ b/slixfeed/xmpp/client.py @@ -1985,16 +1985,17 @@ class Slixfeed(slixmpp.ClientXMPP): options = form.add_field(var='option', ftype='list-single', label='Choose', - required=True) + required=True, + value='admin') + jid = session['from'].bare + if is_operator(self, jid): + options.addOption('Administration', 'admin') # options.addOption('Activity', 'activity') # options.addOption('Filters', 'filter') # options.addOption('Statistics', 'statistics') # options.addOption('Scheduler', 'scheduler') options.addOption('Import', 'import') options.addOption('Export', 'export') - jid = session['from'].bare - if is_operator(self, jid): - options.addOption('Administration', 'admin') session['payload'] = form session['next'] = self._handle_advanced_result session['has_next'] = True @@ -2626,6 +2627,11 @@ class Slixfeed(slixmpp.ClientXMPP): label='Jabber ID', value=jid_bare) options.addOption(jid_bare, jid_bare) + form.addField(var='alias', + ftype='text-single', + label='Alias', + value=properties['nick'], + required=True) form.addField(var='name', ftype='text-single', label='Name', @@ -2641,11 +2647,6 @@ class Slixfeed(slixmpp.ClientXMPP): label='Host', value=host, required=True) - form.addField(var='alias', - ftype='text-single', - label='Alias', - value=properties['nick'], - required=True) form.addField(var='password', ftype='text-private', label='Password', @@ -2679,24 +2680,24 @@ class Slixfeed(slixmpp.ClientXMPP): function_name = sys._getframe().f_code.co_name logger.debug('{}: jid_full: {}' .format(function_name, jid_full)) - # form = self['xep_0004'].make_form('result', 'Done') - # form['instructions'] = ('✅️ Bookmark has been saved') - # # In this case (as is typical), the payload is a form + form = self['xep_0004'].make_form('result', 'Done') + form['instructions'] = ('Bookmark has been saved') values = payload['values'] await XmppBookmark.add(self, properties=values) - # for value in values: - # key = str(value) - # val = str(values[value]) - # if not val: val = 'None' # '(empty)' - # form.add_field(var=key, - # ftype='text-single', - # label=key.capitalize(), - # value=val) - form = payload - form['title'] = 'Done' - form['instructions'] = 'has been completed!' + for i in values: + key = str(i) + val = str(values[i]) + if val and key == 'password': val = '**********' + # if not val: val = 'None' + # form_type = 'text-single' if key != 'password' else 'text-private' + if val: + form.add_field(var=key, + ftype='text-single', + label=key.capitalize(), + value=val) session['next'] = None session['payload'] = form + # session['notes'] = [['warn', text_warn]] return session diff --git a/slixfeed/xmpp/component.py b/slixfeed/xmpp/component.py index 27a21a0..0bf8f8c 100644 --- a/slixfeed/xmpp/component.py +++ b/slixfeed/xmpp/component.py @@ -1946,16 +1946,17 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): options = form.add_field(var='option', ftype='list-single', label='Choose', - required=True) + required=True, + value='admin') + jid = session['from'].bare + if is_operator(self, jid): + options.addOption('Administration', 'admin') # options.addOption('Activity', 'activity') # options.addOption('Filters', 'filter') # options.addOption('Statistics', 'statistics') # options.addOption('Scheduler', 'scheduler') options.addOption('Import', 'import') options.addOption('Export', 'export') - jid = session['from'].bare - if is_operator(self, jid): - options.addOption('Administration', 'admin') session['payload'] = form session['next'] = self._handle_advanced_result session['has_next'] = True @@ -2587,6 +2588,11 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): label='Jabber ID', value=jid_bare) options.addOption(jid_bare, jid_bare) + form.addField(var='alias', + ftype='text-single', + label='Alias', + value=properties['nick'], + required=True) form.addField(var='name', ftype='text-single', label='Name', @@ -2602,11 +2608,6 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): label='Host', value=host, required=True) - form.addField(var='alias', - ftype='text-single', - label='Alias', - value=properties['nick'], - required=True) form.addField(var='password', ftype='text-private', label='Password', @@ -2640,24 +2641,24 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): function_name = sys._getframe().f_code.co_name logger.debug('{}: jid_full: {}' .format(function_name, jid_full)) - # form = self['xep_0004'].make_form('result', 'Done') - # form['instructions'] = ('✅️ Bookmark has been saved') - # # In this case (as is typical), the payload is a form + form = self['xep_0004'].make_form('result', 'Done') + form['instructions'] = ('Bookmark has been saved') values = payload['values'] await XmppBookmark.add(self, properties=values) - # for value in values: - # key = str(value) - # val = str(values[value]) - # if not val: val = 'None' # '(empty)' - # form.add_field(var=key, - # ftype='text-single', - # label=key.capitalize(), - # value=val) - form = payload - form['title'] = 'Done' - form['instructions'] = 'has been completed!' + for i in values: + key = str(i) + val = str(values[i]) + if val and key == 'password': val = '**********' + # if not val: val = 'None' + # form_type = 'text-single' if key != 'password' else 'text-private' + if val: + form.add_field(var=key, + ftype='text-single', + label=key.capitalize(), + value=val) session['next'] = None session['payload'] = form + # session['notes'] = [['warn', text_warn]] return session diff --git a/slixfeed/xmpp/connect.py b/slixfeed/xmpp/connect.py index 0d8af4a..d85bad1 100644 --- a/slixfeed/xmpp/connect.py +++ b/slixfeed/xmpp/connect.py @@ -3,13 +3,6 @@ """ -FIXME - -Message from OpenFire server log. - -2024.03.12 14:21:22.518 ERROR [nioEventLoopGroup-3-2]: org.jivesoftware.openfire.IQRouter - Unable to process a stanza that has no 'from' attribute, addressed to a remote entity. Stanza is being dropped: - - TODO 1) Check interval, and if no connection is establish after 30 seconds diff --git a/slixfeed/xmpp/process.py b/slixfeed/xmpp/process.py index 6a4c6b0..0325527 100644 --- a/slixfeed/xmpp/process.py +++ b/slixfeed/xmpp/process.py @@ -822,6 +822,7 @@ async def message(self, message): db_file = config.get_pathname_to_database(jid_file) key = 'old' val = 0 + print('key and val (outside)') await Config.set_setting_value(self.settings, jid_bare, db_file, key, val) response = 'Only new items of newly added feeds be delivered.'