diff --git a/blocking.py b/blocking.py index 1a669fba..b565ec61 100644 --- a/blocking.py +++ b/blocking.py @@ -49,6 +49,10 @@ def isBlocked(baseDir: str,nickname: str,domain: str, \ blockNickname: str,blockDomain: str) -> bool: """Is the given nickname blocked? """ + allowFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/allowedinstances.txt' + if os.path.isfile(allowFilename): + if blockDomain not in open(allowFilename).read(): + return True blockingFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt' blockHandle=blockNickname+'@'+blockDomain if os.path.isfile(blockingFilename): diff --git a/daemon.py b/daemon.py index a573be04..6d1f21ac 100644 --- a/daemon.py +++ b/daemon.py @@ -1743,6 +1743,14 @@ class PubServer(BaseHTTPRequestHandler): else: if os.path.isfile(blockedFilename): os.remove(blockedFilename) + # save allowed instances list + allowedInstancesFilename=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'/allowedinstances.txt' + if fields.get('allowedInstances'): + with open(allowedInstancesFilename, "w") as allowedInstancesFile: + allowedInstancesFile.write(fields['allowedInstances']) + else: + if os.path.isfile(allowedInstancesFilename): + os.remove(allowedInstancesFilename) # save actor json file within accounts if actorChanged: with open(actorFilename, 'w') as fp: diff --git a/webinterface.py b/webinterface.py index 12f56880..76765e3b 100644 --- a/webinterface.py +++ b/webinterface.py @@ -68,6 +68,12 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: with open(blockedFilename, 'r') as blockedfile: blockedStr=blockedfile.read() + allowedInstancesStr='' + allowedInstancesFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/allowedinstances.txt' + if os.path.isfile(allowedInstancesFilename): + with open(allowedInstancesFilename, 'r') as allowedInstancesFile: + allowedInstancesStr=allowedInstancesFile.read() + with open(baseDir+'/epicyon-profile.css', 'r') as cssFile: newPostCSS = cssFile.read() @@ -93,10 +99,15 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: ' ' \ '