Federation lists for individual accounts

master
Bob Mottram 2019-08-02 13:11:32 +01:00
parent bf3ef893aa
commit 08233c0dff
3 changed files with 27 additions and 4 deletions

View File

@ -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):

View File

@ -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:

View File

@ -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:
' </div>' \
' <div class="container">' \
' <input type="checkbox" class=profilecheckbox" name="approveFollowers" '+manuallyApprovesFollowers+'>Approve follower requests<br>' \
' <br>Filtered words' \
' <textarea id="message" name="filteredWords" placeholder="Filtered words or phrases (one per line)" style="height:200px">'+filterStr+'</textarea>' \
' <br>Blocked accounts' \
' <textarea id="message" name="blocked" placeholder="Blocked accounts, one per line, in the form nickname@domain or *@blockeddomain" style="height:200px">'+blockedStr+'</textarea>' \
' <br><b>Filtered words</b>' \
' <br>One per line' \
' <textarea id="message" name="filteredWords" placeholder="" style="height:200px">'+filterStr+'</textarea>' \
' <br><b>Blocked accounts</b>' \
' <br>Blocked accounts, one per line, in the form <i>nickname@domain</i> or <i>*@blockeddomain</i>' \
' <textarea id="message" name="blocked" placeholder="" style="height:200px">'+blockedStr+'</textarea>' \
' <br><b>Allowed instances</b>' \
' <br>Federate only with a defined set of instances. One domain name per line.' \
' <textarea id="message" name="allowedInstances" placeholder="" style="height:200px">'+allowedInstancesStr+'</textarea>' \
' </div>' \
' <div class="container">' \
' <input type="submit" name="submitProfile" value="Submit">' \