Fix saving of bookmarks via bookmark manager.

Fix default settings file.
This commit is contained in:
Schimon Jehudah 2024-03-13 11:57:53 +00:00
parent 077042dd43
commit 8e76ae4506
8 changed files with 61 additions and 63 deletions

View file

@ -25,7 +25,6 @@ formatting = """
{link} {link}
{feed_title} [{ix}] {feed_title} [{ix}]
""" """
# Utilized in case of missing protocol support. # Utilized in case of missing protocol support.
@ -38,7 +37,7 @@ tor = ""
yggdrasil = "" yggdrasil = ""
[network] [network]
http_proxy = "http://localhost:8118" http_proxy = ""
user_agent = "Slixfeed/0.1" user_agent = "Slixfeed/0.1"
clearnet = 0 # Enable policed DNS system (not recommended) clearnet = 0 # Enable policed DNS system (not recommended)
i2p = 1 # Enable I2P mixnet system (safer) i2p = 1 # Enable I2P mixnet system (safer)

View file

@ -67,6 +67,8 @@ class Config:
return result return result
async def set_setting_value(settings, jid_bare, db_file, key, val): async def set_setting_value(settings, jid_bare, db_file, key, val):
print('key and val (inside)')
print(key, val)
key = key.lower() key = key.lower()
key_val = [key, val] key_val = [key, val]
settings[jid_bare][key] = val settings[jid_bare][key] = val

View file

@ -1,2 +1,2 @@
__version__ = '0.1.39' __version__ = '0.1.40'
__version_info__ = (0, 1, 39) __version_info__ = (0, 1, 40)

View file

@ -41,11 +41,11 @@ class XmppBookmark:
conferences = result['private']['bookmarks']['conferences'] conferences = result['private']['bookmarks']['conferences']
groupchats = [] groupchats = []
for conference in conferences: for conference in conferences:
if conference['jid'] != properties['jid']:
groupchats.extend([conference]) groupchats.extend([conference])
if properties: if properties:
properties['jid'] = properties['room'] + '@' + properties['host'] properties['jid'] = properties['room'] + '@' + properties['host']
if not properties['alias']: properties['alias'] = self.alias if not properties['alias']: properties['alias'] = self.alias
else: else:
properties = { properties = {
'jid' : jid, 'jid' : jid,
@ -62,7 +62,7 @@ class XmppBookmark:
# if groupchat['jid'] == groupchat['name']: # if groupchat['jid'] == groupchat['name']:
# groupchat['name'] = groupchat['name'].split('@')[0] # groupchat['name'] = groupchat['name'].split('@')[0]
bookmarks.add_conference(groupchat['jid'], bookmarks.add_conference(groupchat['jid'],
groupchat['alias'], groupchat['nick'],
name=groupchat['name'], name=groupchat['name'],
autojoin=groupchat['autojoin'], autojoin=groupchat['autojoin'],
password=groupchat['password']) password=groupchat['password'])
@ -71,7 +71,8 @@ class XmppBookmark:
name=properties['name'], name=properties['name'],
autojoin=properties['autojoin'], autojoin=properties['autojoin'],
password=properties['password']) 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() # bookmarks = Bookmarks()
# await self.plugin['xep_0048'].set_bookmarks(bookmarks) # await self.plugin['xep_0048'].set_bookmarks(bookmarks)
# print(await self.plugin['xep_0048'].get_bookmarks()) # print(await self.plugin['xep_0048'].get_bookmarks())

View file

@ -1985,16 +1985,17 @@ class Slixfeed(slixmpp.ClientXMPP):
options = form.add_field(var='option', options = form.add_field(var='option',
ftype='list-single', ftype='list-single',
label='Choose', 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('Activity', 'activity')
# options.addOption('Filters', 'filter') # options.addOption('Filters', 'filter')
# options.addOption('Statistics', 'statistics') # options.addOption('Statistics', 'statistics')
# options.addOption('Scheduler', 'scheduler') # options.addOption('Scheduler', 'scheduler')
options.addOption('Import', 'import') options.addOption('Import', 'import')
options.addOption('Export', 'export') options.addOption('Export', 'export')
jid = session['from'].bare
if is_operator(self, jid):
options.addOption('Administration', 'admin')
session['payload'] = form session['payload'] = form
session['next'] = self._handle_advanced_result session['next'] = self._handle_advanced_result
session['has_next'] = True session['has_next'] = True
@ -2626,6 +2627,11 @@ class Slixfeed(slixmpp.ClientXMPP):
label='Jabber ID', label='Jabber ID',
value=jid_bare) value=jid_bare)
options.addOption(jid_bare, 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', form.addField(var='name',
ftype='text-single', ftype='text-single',
label='Name', label='Name',
@ -2641,11 +2647,6 @@ class Slixfeed(slixmpp.ClientXMPP):
label='Host', label='Host',
value=host, value=host,
required=True) required=True)
form.addField(var='alias',
ftype='text-single',
label='Alias',
value=properties['nick'],
required=True)
form.addField(var='password', form.addField(var='password',
ftype='text-private', ftype='text-private',
label='Password', label='Password',
@ -2679,24 +2680,24 @@ class Slixfeed(slixmpp.ClientXMPP):
function_name = sys._getframe().f_code.co_name function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid_full: {}' logger.debug('{}: jid_full: {}'
.format(function_name, jid_full)) .format(function_name, jid_full))
# form = self['xep_0004'].make_form('result', 'Done') form = self['xep_0004'].make_form('result', 'Done')
# form['instructions'] = ('✅️ Bookmark has been saved') form['instructions'] = ('Bookmark has been saved')
# # In this case (as is typical), the payload is a form
values = payload['values'] values = payload['values']
await XmppBookmark.add(self, properties=values) await XmppBookmark.add(self, properties=values)
# for value in values: for i in values:
# key = str(value) key = str(i)
# val = str(values[value]) val = str(values[i])
# if not val: val = 'None' # '(empty)' if val and key == 'password': val = '**********'
# form.add_field(var=key, # if not val: val = 'None'
# ftype='text-single', # form_type = 'text-single' if key != 'password' else 'text-private'
# label=key.capitalize(), if val:
# value=val) form.add_field(var=key,
form = payload ftype='text-single',
form['title'] = 'Done' label=key.capitalize(),
form['instructions'] = 'has been completed!' value=val)
session['next'] = None session['next'] = None
session['payload'] = form session['payload'] = form
# session['notes'] = [['warn', text_warn]]
return session return session

View file

@ -1946,16 +1946,17 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
options = form.add_field(var='option', options = form.add_field(var='option',
ftype='list-single', ftype='list-single',
label='Choose', 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('Activity', 'activity')
# options.addOption('Filters', 'filter') # options.addOption('Filters', 'filter')
# options.addOption('Statistics', 'statistics') # options.addOption('Statistics', 'statistics')
# options.addOption('Scheduler', 'scheduler') # options.addOption('Scheduler', 'scheduler')
options.addOption('Import', 'import') options.addOption('Import', 'import')
options.addOption('Export', 'export') options.addOption('Export', 'export')
jid = session['from'].bare
if is_operator(self, jid):
options.addOption('Administration', 'admin')
session['payload'] = form session['payload'] = form
session['next'] = self._handle_advanced_result session['next'] = self._handle_advanced_result
session['has_next'] = True session['has_next'] = True
@ -2587,6 +2588,11 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
label='Jabber ID', label='Jabber ID',
value=jid_bare) value=jid_bare)
options.addOption(jid_bare, 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', form.addField(var='name',
ftype='text-single', ftype='text-single',
label='Name', label='Name',
@ -2602,11 +2608,6 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
label='Host', label='Host',
value=host, value=host,
required=True) required=True)
form.addField(var='alias',
ftype='text-single',
label='Alias',
value=properties['nick'],
required=True)
form.addField(var='password', form.addField(var='password',
ftype='text-private', ftype='text-private',
label='Password', label='Password',
@ -2640,24 +2641,24 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
function_name = sys._getframe().f_code.co_name function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid_full: {}' logger.debug('{}: jid_full: {}'
.format(function_name, jid_full)) .format(function_name, jid_full))
# form = self['xep_0004'].make_form('result', 'Done') form = self['xep_0004'].make_form('result', 'Done')
# form['instructions'] = ('✅️ Bookmark has been saved') form['instructions'] = ('Bookmark has been saved')
# # In this case (as is typical), the payload is a form
values = payload['values'] values = payload['values']
await XmppBookmark.add(self, properties=values) await XmppBookmark.add(self, properties=values)
# for value in values: for i in values:
# key = str(value) key = str(i)
# val = str(values[value]) val = str(values[i])
# if not val: val = 'None' # '(empty)' if val and key == 'password': val = '**********'
# form.add_field(var=key, # if not val: val = 'None'
# ftype='text-single', # form_type = 'text-single' if key != 'password' else 'text-private'
# label=key.capitalize(), if val:
# value=val) form.add_field(var=key,
form = payload ftype='text-single',
form['title'] = 'Done' label=key.capitalize(),
form['instructions'] = 'has been completed!' value=val)
session['next'] = None session['next'] = None
session['payload'] = form session['payload'] = form
# session['notes'] = [['warn', text_warn]]
return session return session

View file

@ -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: <iq id="8e4e60ae0d894b40a2fc465268d46d0b" type="get" to="rss.simon.goodbytes.im"><ping xmlns="urn:xmpp:ping"></ping></iq>
TODO TODO
1) Check interval, and if no connection is establish after 30 seconds 1) Check interval, and if no connection is establish after 30 seconds

View file

@ -822,6 +822,7 @@ async def message(self, message):
db_file = config.get_pathname_to_database(jid_file) db_file = config.get_pathname_to_database(jid_file)
key = 'old' key = 'old'
val = 0 val = 0
print('key and val (outside)')
await Config.set_setting_value(self.settings, jid_bare, await Config.set_setting_value(self.settings, jid_bare,
db_file, key, val) db_file, key, val)
response = 'Only new items of newly added feeds be delivered.' response = 'Only new items of newly added feeds be delivered.'