Fix OPML export (OMEMO is not yet supported);

Add commands blacklist/whitelist to command list.
This commit is contained in:
Schimon Jehudah, Adv. 2024-12-05 12:06:57 +02:00
parent d3dbcb0cdb
commit 5104919588
8 changed files with 28 additions and 9 deletions

View file

@ -248,6 +248,24 @@ stats = """
stats stats
Show general statistics. Show general statistics.
""" """
[list]
blacklist = """
blacklist
List all blacklisted JIDs.
"""
blacklist_action = """
blacklist [add|delete] <jid>
Manage allowed list.
"""
whitelist = """
whitelist
List all whitelisted JIDs.
"""
whitelist_action = """
whitelist [add|delete] <jid>
Manage denied list.
"""
# analyses = """ # analyses = """
# analyses # analyses
# Show report and statistics of feeds. # Show report and statistics of feeds.

View file

@ -43,7 +43,7 @@ logger = Logger(__name__)
class Feed: class Feed:
# NOTE Consider removal of MD (and any other option HTML and XBEL) # NOTE Consider removal of MD (and any other option HTML and XBEL)
def export_feeds(dir_cache, jid_bare, ext): def export_feeds(dir_data, dir_cache, jid_bare, ext):
function_name = sys._getframe().f_code.co_name function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid_bare: {}: ext: {}'.format(function_name, jid_bare, ext)) logger.debug('{}: jid_bare: {}: ext: {}'.format(function_name, jid_bare, ext))
if not os.path.isdir(dir_cache): if not os.path.isdir(dir_cache):
@ -52,7 +52,7 @@ class Feed:
os.mkdir(dir_cache + '/' + ext) os.mkdir(dir_cache + '/' + ext)
filename = os.path.join( filename = os.path.join(
dir_cache, ext, 'slixfeed_' + DateAndTime.timestamp() + '.' + ext) dir_cache, ext, 'slixfeed_' + DateAndTime.timestamp() + '.' + ext)
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db') db_file = os.path.join(dir_data, 'sqlite', f'{jid_bare}.db')
results = sqlite.get_feeds(db_file) results = sqlite.get_feeds(db_file)
match ext: match ext:
# case 'html': # case 'html':

View file

@ -551,6 +551,7 @@ class Url:
else: else:
proxies_obsolete_file = os.path.join(configuration_directory, 'proxies_obsolete.toml') proxies_obsolete_file = os.path.join(configuration_directory, 'proxies_obsolete.toml')
proxies_file = os.path.join(configuration_directory, 'proxies.toml') proxies_file = os.path.join(configuration_directory, 'proxies.toml')
breakpoint()
proxies_obsolete = Toml.open_file(proxies_obsolete_file) proxies_obsolete = Toml.open_file(proxies_obsolete_file)
proxies_obsolete['proxies'][proxy_name][proxy_type].append(proxy_url) proxies_obsolete['proxies'][proxy_name][proxy_type].append(proxy_url)
Toml.save_file(proxies_obsolete_file, proxies_obsolete) Toml.save_file(proxies_obsolete_file, proxies_obsolete)

View file

@ -1,2 +1,2 @@
__version__ = '0.1.103' __version__ = '0.1.104'
__version_info__ = (0, 1, 103) __version_info__ = (0, 1, 104)

View file

@ -288,7 +288,7 @@ class XmppChat:
XmppPresence.send(self, jid_bare, status_message, XmppPresence.send(self, jid_bare, status_message,
status_type=status_type) status_type=status_type)
pathname, response = XmppCommands.export_feeds( pathname, response = XmppCommands.export_feeds(
self.dir_cache, jid_bare, ext) self.dir_data, self.dir_cache, jid_bare, ext)
encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo') encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo')
encrypted = True if encrypt_omemo else False encrypted = True if encrypt_omemo else False
url = await XmppUpload.start(self, jid_bare, Path(pathname), encrypted=encrypted) url = await XmppUpload.start(self, jid_bare, Path(pathname), encrypted=encrypted)

View file

@ -2984,7 +2984,7 @@ class XmppClient(slixmpp.ClientXMPP):
# form['instructions'] = ('✅️ Feeds have been exported') # form['instructions'] = ('✅️ Feeds have been exported')
exts = values['filetype'] exts = values['filetype']
for ext in exts: for ext in exts:
filename = Feed.export_feeds(self.dir_cache, jid_bare, ext) filename = Feed.export_feeds(self.dir_data, self.dir_cache, jid_bare, ext)
encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo') encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo')
encrypted = True if encrypt_omemo else False encrypted = True if encrypt_omemo else False
url = await XmppUpload.start( url = await XmppUpload.start(

View file

@ -324,8 +324,8 @@ class XmppCommands:
await sqlite.set_filter_value(db_file, ['deny', val]) await sqlite.set_filter_value(db_file, ['deny', val])
def export_feeds(dir_cache, jid_bare, ext): def export_feeds(dir_data, dir_cache, jid_bare, ext):
pathname = Feed.export_feeds(dir_cache, jid_bare, ext) pathname = Feed.export_feeds(dir_data, dir_cache, jid_bare, ext)
message = f'Feeds successfuly exported to {ext}.' message = f'Feeds successfuly exported to {ext}.'
return pathname, message return pathname, message

View file

@ -176,7 +176,7 @@ class XmppIpcServer:
ext = command[7:] ext = command[7:]
if ext in ('md', 'opml'): if ext in ('md', 'opml'):
filename, result = XmppCommands.export_feeds( filename, result = XmppCommands.export_feeds(
self.dir_cache, jid_bare, ext) self.dir_data, self.dir_cache, jid_bare, ext)
response = result + ' : ' + filename response = result + ' : ' + filename
else: else:
response = 'Unsupported filetype. Try: md or opml' response = 'Unsupported filetype. Try: md or opml'