From 2cfd87d802aceecadd6f649502afb0555d87544b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 26 Jul 2021 12:13:59 +0100 Subject: [PATCH] Load shared items federation tokens from file --- daemon.py | 8 ++++++++ epicyon.py | 27 +++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/daemon.py b/daemon.py index cba31349b..16a108a4e 100644 --- a/daemon.py +++ b/daemon.py @@ -15072,7 +15072,15 @@ def runDaemon(sharedItemsFederatedDomains: [], httpd.httpPrefix = httpPrefix httpd.debug = debug httpd.federationList = fedList.copy() + if not sharedItemsFederatedDomains: + sharedItemsTokensFilename = \ + baseDir + '/accounts/sharedItemsFederationTokens.json' + if os.path.isfile(sharedItemsTokensFilename): + sharedItemsFederatedDomains = loadJson(sharedItemsTokensFilename) httpd.sharedItemsFederatedDomains = sharedItemsFederatedDomains.copy() + if httpd.sharedItemsFederatedDomains: + if domain not in httpd.sharedItemsFederatedDomains: + httpd.sharedItemsFederatedDomains.append(domain) httpd.baseDir = baseDir httpd.instanceId = instanceId httpd.personCache = {} diff --git a/epicyon.py b/epicyon.py index 6c8fa6c3f..91a4b36b4 100644 --- a/epicyon.py +++ b/epicyon.py @@ -1028,16 +1028,6 @@ else: if configFederationList: federationList = configFederationList -sharedItemsFederatedDomains = [] -if args.sharedItemsFederatedDomains: - setConfigParam(baseDir, 'sharedItemsFederatedDomains', - sharedItemsFederatedDomains) -else: - configSharedItemsFederatedDomains = \ - getConfigParam(baseDir, 'sharedItemsFederatedDomains') - if configSharedItemsFederatedDomains: - sharedItemsFederatedDomains = configSharedItemsFederatedDomains - proxyType = None if args.tor or domain.endswith('.onion'): proxyType = 'tor' @@ -2156,9 +2146,22 @@ if args.desktop: if federationList: print('Federating with: ' + str(federationList)) -if sharedItemsFederatedDomains: +if args.sharedItemsFederatedDomains: print('Federating shared items with: ' + - str(sharedItemsFederatedDomains)) + args.sharedItemsFederatedDomains) + +sharedItemsFederatedDomains = [] +if args.sharedItemsFederatedDomains: + sharedItemsFederatedDomainsStr = args.sharedItemsFederatedDomains + setConfigParam(baseDir, 'sharedItemsFederatedDomains', + sharedItemsFederatedDomainsStr) +else: + sharedItemsFederatedDomainsStr = \ + getConfigParam(baseDir, 'sharedItemsFederatedDomains') +if sharedItemsFederatedDomainsStr: + sharedItemsFederatedDomainsList = sharedItemsFederatedDomainsStr.split(',') + for sharedFederatedDomain in sharedItemsFederatedDomainsList: + sharedItemsFederatedDomains.append(sharedFederatedDomain.strip()) if args.block: if not nickname: