Use federation list for followers

master
Bob Mottram 2019-06-29 21:34:41 +01:00
parent 0765d21b24
commit c2983c5217
3 changed files with 17 additions and 15 deletions

View File

@ -36,7 +36,7 @@ maxMessageLength=5000
maxPostsInFeed=20 maxPostsInFeed=20
# number of follows/followers per page # number of follows/followers per page
followsPerPage=2 followsPerPage=12
# Whether to use https # Whether to use https
useHttps=True useHttps=True

View File

@ -31,7 +31,7 @@ from follow import followerOfPerson
from follow import unfollowPerson from follow import unfollowPerson
from follow import unfollowerOfPerson from follow import unfollowerOfPerson
federationList=['mastodon.social'] federationList=['mastodon.social','wild.com','trees.com']
username='testuser' username='testuser'
#domain=socket.gethostname() #domain=socket.gethostname()
domain='mydomain.com' domain='mydomain.com'
@ -41,18 +41,18 @@ useTor=False
session = createSession(useTor) session = createSession(useTor)
clearFollows(username,domain) clearFollows(username,domain)
followPerson(username,domain,'badger','wild.com') followPerson(username,domain,'badger','wild.com',federationList)
followPerson(username,domain,'squirrel','secret.com') followPerson(username,domain,'squirrel','secret.com',federationList)
followPerson(username,domain,'rodent','drainpipe.com') followPerson(username,domain,'rodent','drainpipe.com',federationList)
followPerson(username,domain,'batman','mesh.com') followPerson(username,domain,'batman','mesh.com',federationList)
followPerson(username,domain,'giraffe','trees.com') followPerson(username,domain,'giraffe','trees.com',federationList)
clearFollowers(username,domain) clearFollowers(username,domain)
followerOfPerson(username,domain,'badger','wild.com') followerOfPerson(username,domain,'badger','wild.com',federationList)
followerOfPerson(username,domain,'squirrel','secret.com') followerOfPerson(username,domain,'squirrel','secret.com',federationList)
followerOfPerson(username,domain,'rodent','drainpipe.com') followerOfPerson(username,domain,'rodent','drainpipe.com',federationList)
followerOfPerson(username,domain,'batman','mesh.com') followerOfPerson(username,domain,'batman','mesh.com',federationList)
followerOfPerson(username,domain,'giraffe','trees.com') followerOfPerson(username,domain,'giraffe','trees.com',federationList)
#unfollowPerson(username,domain,'squirrel','secret.com') #unfollowPerson(username,domain,'squirrel','secret.com')
#sys.exit() #sys.exit()

View File

@ -12,9 +12,11 @@ import os
import sys import sys
from person import validUsername from person import validUsername
def followPerson(username: str, domain: str, followUsername: str, followDomain: str, followFile='following.txt') -> None: def followPerson(username: str, domain: str, followUsername: str, followDomain: str, federationList, followFile='following.txt') -> None:
"""Adds a person to the follow list """Adds a person to the follow list
""" """
if followDomain.lower().replace('\n','') not in federationList:
return
handle=username.lower()+'@'+domain.lower() handle=username.lower()+'@'+domain.lower()
handleToFollow=followUsername.lower()+'@'+followDomain.lower() handleToFollow=followUsername.lower()+'@'+followDomain.lower()
baseDir=os.getcwd() baseDir=os.getcwd()
@ -30,8 +32,8 @@ def followPerson(username: str, domain: str, followUsername: str, followDomain:
with open(filename, "w") as followfile: with open(filename, "w") as followfile:
followfile.write(handleToFollow+'\n') followfile.write(handleToFollow+'\n')
def followerOfPerson(username: str, domain: str, followerUsername: str, followerDomain: str) -> None: def followerOfPerson(username: str, domain: str, followerUsername: str, followerDomain: str, federationList) -> None:
followPerson(username, domain, followerUsername, followerDomain,'followers.txt') followPerson(username, domain, followerUsername, followerDomain, federationList, 'followers.txt')
def unfollowPerson(username: str, domain: str, followUsername: str, followDomain: str,followFile='following.txt') -> None: def unfollowPerson(username: str, domain: str, followUsername: str, followDomain: str,followFile='following.txt') -> None:
"""Removes a person to the follow list """Removes a person to the follow list