Check admin status when saving peertube sites list

merge-requests/8/head
Bob Mottram 2020-12-24 11:49:32 +00:00
parent 3d16d93d86
commit f16ae830b0
1 changed files with 21 additions and 15 deletions

View File

@ -4566,24 +4566,30 @@ class PubServer(BaseHTTPRequestHandler):
os.remove(allowedInstancesFilename) os.remove(allowedInstancesFilename)
# save peertube instances list # save peertube instances list
peertubeInstancesFilename = \ peertubeInstancesFile = \
baseDir + '/accounts/peertube.txt' baseDir + '/accounts/peertube.txt'
if fields.get('ptInstances'): if fields.get('ptInstances'):
self.server.peertubeInstances.clear() adminNickname = \
with open(peertubeInstancesFilename, 'w+') as aFile: getConfigParam(baseDir, 'admin')
aFile.write(fields['ptInstances']) if adminNickname and \
ptInstancesList = fields['ptInstances'].split('\n') path.startswith('/users/' +
if ptInstancesList: adminNickname + '/'):
for url in ptInstancesList: self.server.peertubeInstances.clear()
url = url.strip() with open(peertubeInstancesFile, 'w+') as aFile:
if not url: aFile.write(fields['ptInstances'])
continue ptInstancesList = \
if url in self.server.peertubeInstances: fields['ptInstances'].split('\n')
continue if ptInstancesList:
self.server.peertubeInstances.append(url) for url in ptInstancesList:
url = url.strip()
if not url:
continue
if url in self.server.peertubeInstances:
continue
self.server.peertubeInstances.append(url)
else: else:
if os.path.isfile(peertubeInstancesFilename): if os.path.isfile(peertubeInstancesFile):
os.remove(peertubeInstancesFilename) os.remove(peertubeInstancesFile)
self.server.peertubeInstances.clear() self.server.peertubeInstances.clear()
# save git project names list # save git project names list