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}
{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)

View file

@ -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

View file

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

View file

@ -41,11 +41,11 @@ class XmppBookmark:
conferences = result['private']['bookmarks']['conferences']
groupchats = []
for conference in conferences:
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())

View file

@ -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

View file

@ -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

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
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)
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.'