mirror of https://gitlab.com/bashrc2/epicyon
Option to set a maximum number of followers per account
parent
d6b2360860
commit
fa419cf995
|
@ -11981,7 +11981,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
|
||||||
tokensLookup[token] = nickname
|
tokensLookup[token] = nickname
|
||||||
|
|
||||||
|
|
||||||
def runDaemon(allowNewsFollowers: bool,
|
def runDaemon(maxFollowers: int,
|
||||||
|
allowNewsFollowers: bool,
|
||||||
maxNewsPosts: int,
|
maxNewsPosts: int,
|
||||||
maxMirroredArticles: int,
|
maxMirroredArticles: int,
|
||||||
maxNewswireFeedSizeKb: int,
|
maxNewswireFeedSizeKb: int,
|
||||||
|
@ -12132,6 +12133,9 @@ def runDaemon(allowNewsFollowers: bool,
|
||||||
# attached to RSS feeds pulled in via the newswire
|
# attached to RSS feeds pulled in via the newswire
|
||||||
httpd.maxTags = 32
|
httpd.maxTags = 32
|
||||||
|
|
||||||
|
# maximum number of followers per account
|
||||||
|
httpd.maxFollowers = maxFollowers
|
||||||
|
|
||||||
if registration == 'open':
|
if registration == 'open':
|
||||||
httpd.registration = True
|
httpd.registration = True
|
||||||
else:
|
else:
|
||||||
|
@ -12274,7 +12278,8 @@ def runDaemon(allowNewsFollowers: bool,
|
||||||
httpd.translate, unitTest,
|
httpd.translate, unitTest,
|
||||||
httpd.YTReplacementDomain,
|
httpd.YTReplacementDomain,
|
||||||
httpd.showPublishedDateOnly,
|
httpd.showPublishedDateOnly,
|
||||||
httpd.allowNewsFollowers), daemon=True)
|
httpd.allowNewsFollowers,
|
||||||
|
httpd.maxFollowers), daemon=True)
|
||||||
|
|
||||||
print('Creating scheduled post thread')
|
print('Creating scheduled post thread')
|
||||||
httpd.thrPostSchedule = \
|
httpd.thrPostSchedule = \
|
||||||
|
|
13
epicyon.py
13
epicyon.py
|
@ -130,6 +130,11 @@ parser.add_argument('--maxNewsPosts',
|
||||||
default=0,
|
default=0,
|
||||||
help='Maximum number of news timeline posts to keep. ' +
|
help='Maximum number of news timeline posts to keep. ' +
|
||||||
'Zero for no expiry.')
|
'Zero for no expiry.')
|
||||||
|
parser.add_argument('--maxFollowers',
|
||||||
|
dest='maxFollowers', type=int,
|
||||||
|
default=2000,
|
||||||
|
help='Maximum number of followers per account. ' +
|
||||||
|
'Zero for no limit.')
|
||||||
parser.add_argument('--postcache', dest='maxRecentPosts', type=int,
|
parser.add_argument('--postcache', dest='maxRecentPosts', type=int,
|
||||||
default=512,
|
default=512,
|
||||||
help='The maximum number of recent posts to store in RAM')
|
help='The maximum number of recent posts to store in RAM')
|
||||||
|
@ -1970,6 +1975,11 @@ maxNewsPosts = \
|
||||||
if maxNewsPosts is not None:
|
if maxNewsPosts is not None:
|
||||||
args.maxNewsPosts = int(maxNewsPosts)
|
args.maxNewsPosts = int(maxNewsPosts)
|
||||||
|
|
||||||
|
maxFollowers = \
|
||||||
|
getConfigParam(baseDir, 'maxFollowers')
|
||||||
|
if maxFollowers is not None:
|
||||||
|
args.maxFollowers = int(maxFollowers)
|
||||||
|
|
||||||
allowNewsFollowers = \
|
allowNewsFollowers = \
|
||||||
getConfigParam(baseDir, 'allowNewsFollowers')
|
getConfigParam(baseDir, 'allowNewsFollowers')
|
||||||
if allowNewsFollowers is not None:
|
if allowNewsFollowers is not None:
|
||||||
|
@ -1988,7 +1998,8 @@ if setTheme(baseDir, themeName, domain):
|
||||||
print('Theme set to ' + themeName)
|
print('Theme set to ' + themeName)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runDaemon(args.allowNewsFollowers,
|
runDaemon(args.maxFollowers,
|
||||||
|
args.allowNewsFollowers,
|
||||||
args.maxNewsPosts,
|
args.maxNewsPosts,
|
||||||
args.maxMirroredArticles,
|
args.maxMirroredArticles,
|
||||||
args.maxNewswireFeedSizeKb,
|
args.maxNewswireFeedSizeKb,
|
||||||
|
|
25
follow.py
25
follow.py
|
@ -253,13 +253,14 @@ def getNoOfFollows(baseDir: str, nickname: str, domain: str,
|
||||||
with open(filename, "r") as f:
|
with open(filename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if '#' not in line:
|
if '#' in line:
|
||||||
if '@' in line and \
|
continue
|
||||||
'.' in line and \
|
if '@' in line and \
|
||||||
not line.startswith('http'):
|
'.' in line and \
|
||||||
ctr += 1
|
not line.startswith('http'):
|
||||||
elif line.startswith('http') and '/users/' in line:
|
ctr += 1
|
||||||
ctr += 1
|
elif line.startswith('http') and '/users/' in line:
|
||||||
|
ctr += 1
|
||||||
return ctr
|
return ctr
|
||||||
|
|
||||||
|
|
||||||
|
@ -521,7 +522,8 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
messageJson: {}, federationList: [],
|
messageJson: {}, federationList: [],
|
||||||
debug: bool, projectVersion: str,
|
debug: bool, projectVersion: str,
|
||||||
allowNewsFollowers: bool) -> bool:
|
allowNewsFollowers: bool,
|
||||||
|
maxFollowers: int) -> bool:
|
||||||
"""Receives a follow request within the POST section of HTTPServer
|
"""Receives a follow request within the POST section of HTTPServer
|
||||||
"""
|
"""
|
||||||
if not messageJson['type'].startswith('Follow'):
|
if not messageJson['type'].startswith('Follow'):
|
||||||
|
@ -588,6 +590,13 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
print('DEBUG: Cannot follow system account - ' +
|
print('DEBUG: Cannot follow system account - ' +
|
||||||
nicknameToFollow)
|
nicknameToFollow)
|
||||||
return True
|
return True
|
||||||
|
if maxFollowers > 0:
|
||||||
|
if getNoOfFollowers(baseDir,
|
||||||
|
nicknameToFollow, domainToFollow,
|
||||||
|
True) > maxFollowers:
|
||||||
|
print('WARN: ' + nicknameToFollow +
|
||||||
|
' has reached their maximum number of followers')
|
||||||
|
return True
|
||||||
handleToFollow = nicknameToFollow + '@' + domainToFollow
|
handleToFollow = nicknameToFollow + '@' + domainToFollow
|
||||||
if domainToFollow == domain:
|
if domainToFollow == domain:
|
||||||
if not os.path.isdir(baseDir + '/accounts/' + handleToFollow):
|
if not os.path.isdir(baseDir + '/accounts/' + handleToFollow):
|
||||||
|
|
6
inbox.py
6
inbox.py
|
@ -2437,7 +2437,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
maxEmoji: int, translate: {}, unitTest: bool,
|
maxEmoji: int, translate: {}, unitTest: bool,
|
||||||
YTReplacementDomain: str,
|
YTReplacementDomain: str,
|
||||||
showPublishedDateOnly: bool,
|
showPublishedDateOnly: bool,
|
||||||
allowNewsFollowers: bool) -> None:
|
allowNewsFollowers: bool,
|
||||||
|
maxFollowers: int) -> None:
|
||||||
"""Processes received items and moves them to the appropriate
|
"""Processes received items and moves them to the appropriate
|
||||||
directories
|
directories
|
||||||
"""
|
"""
|
||||||
|
@ -2724,7 +2725,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
queueJson['post'],
|
queueJson['post'],
|
||||||
federationList,
|
federationList,
|
||||||
debug, projectVersion,
|
debug, projectVersion,
|
||||||
allowNewsFollowers):
|
allowNewsFollowers,
|
||||||
|
maxFollowers):
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
|
|
6
tests.py
6
tests.py
|
@ -290,7 +290,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
runDaemon(False, 0, 100, 1024, 5, False,
|
runDaemon(10, False, 0, 100, 1024, 5, False,
|
||||||
0, False, 1, False, False, False,
|
0, False, 1, False, False, False,
|
||||||
5, True, True, 'en', __version__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
|
@ -354,7 +354,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
runDaemon(False, 0, 100, 1024, 5, False, 0,
|
runDaemon(10, False, 0, 100, 1024, 5, False, 0,
|
||||||
False, 1, False, False, False,
|
False, 1, False, False, False,
|
||||||
5, True, True, 'en', __version__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
|
@ -392,7 +392,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
runDaemon(False, 0, 100, 1024, 5, False, 0,
|
runDaemon(10, False, 0, 100, 1024, 5, False, 0,
|
||||||
False, 1, False, False, False,
|
False, 1, False, False, False,
|
||||||
5, True, True, 'en', __version__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
|
|
Loading…
Reference in New Issue