From 3a9bdea0f7dbd49324959ec3ecb3230d704a81f3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Aug 2019 12:43:14 +0100 Subject: [PATCH] Blocking controls on profile screen --- daemon.py | 19 +++++++++++++++++-- webinterface.py | 20 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/daemon.py b/daemon.py index 20b1e4d35..a573be040 100644 --- a/daemon.py +++ b/daemon.py @@ -1702,8 +1702,6 @@ class PubServer(BaseHTTPRequestHandler): removeMetaData(filename,filename.replace('.temp','')) os.remove(filename) lastImageLocation=imageLocation+1 - print('**********************************************************') - pprint(fields) actorFilename=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'.json' if os.path.isfile(actorFilename): @@ -1729,6 +1727,23 @@ class PubServer(BaseHTTPRequestHandler): if approveFollowers!=actorJson['manuallyApprovesFollowers']: actorJson['manuallyApprovesFollowers']=approveFollowers actorChanged=True + # save filtered words list + filterFilename=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'/filters.txt' + if fields.get('filteredWords'): + with open(filterFilename, "w") as filterfile: + filterfile.write(fields['filteredWords']) + else: + if os.path.isfile(filterFilename): + os.remove(filterFilename) + # save blocked accounts list + blockedFilename=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'/blocking.txt' + if fields.get('blocked'): + with open(blockedFilename, "w") as blockedfile: + blockedfile.write(fields['blocked']) + else: + if os.path.isfile(blockedFilename): + os.remove(blockedFilename) + # save actor json file within accounts if actorChanged: with open(actorFilename, 'w') as fp: commentjson.dump(actorJson, fp, indent=4, sort_keys=False) diff --git a/webinterface.py b/webinterface.py index 62fd43910..3807cdbde 100644 --- a/webinterface.py +++ b/webinterface.py @@ -55,7 +55,19 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: manuallyApprovesFollowers='checked' else: manuallyApprovesFollowers='' - + + filterStr='' + filterFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/filters.txt' + if os.path.isfile(filterFilename): + with open(filterFilename, 'r') as filterfile: + filterStr=filterfile.read() + + blockedStr='' + blockedFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt' + if os.path.isfile(blockedFilename): + with open(blockedFilename, 'r') as blockedfile: + blockedStr=blockedfile.read() + with open(baseDir+'/epicyon-profile.css', 'r') as cssFile: newPostCSS = cssFile.read() @@ -80,7 +92,11 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: ' accept=".png">' \ ' ' \ '
' \ - ' Approve follower requests
' \ + ' Approve follower requests
' \ + '
Filtered words' \ + ' ' \ + '
Blocked accounts' \ + ' ' \ '
' \ '
' \ ' ' \