From f16ae830b0ee11cf3240f8e02914de58b93fbf55 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 24 Dec 2020 11:49:32 +0000 Subject: [PATCH] Check admin status when saving peertube sites list --- daemon.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/daemon.py b/daemon.py index 17572f92f..0899d2cbb 100644 --- a/daemon.py +++ b/daemon.py @@ -4566,24 +4566,30 @@ class PubServer(BaseHTTPRequestHandler): os.remove(allowedInstancesFilename) # save peertube instances list - peertubeInstancesFilename = \ + peertubeInstancesFile = \ baseDir + '/accounts/peertube.txt' if fields.get('ptInstances'): - self.server.peertubeInstances.clear() - with open(peertubeInstancesFilename, 'w+') as aFile: - aFile.write(fields['ptInstances']) - ptInstancesList = fields['ptInstances'].split('\n') - if ptInstancesList: - for url in ptInstancesList: - url = url.strip() - if not url: - continue - if url in self.server.peertubeInstances: - continue - self.server.peertubeInstances.append(url) + adminNickname = \ + getConfigParam(baseDir, 'admin') + if adminNickname and \ + path.startswith('/users/' + + adminNickname + '/'): + self.server.peertubeInstances.clear() + with open(peertubeInstancesFile, 'w+') as aFile: + aFile.write(fields['ptInstances']) + ptInstancesList = \ + fields['ptInstances'].split('\n') + if ptInstancesList: + for url in ptInstancesList: + url = url.strip() + if not url: + continue + if url in self.server.peertubeInstances: + continue + self.server.peertubeInstances.append(url) else: - if os.path.isfile(peertubeInstancesFilename): - os.remove(peertubeInstancesFilename) + if os.path.isfile(peertubeInstancesFile): + os.remove(peertubeInstancesFile) self.server.peertubeInstances.clear() # save git project names list