Optionally allow the news account to be followed

main
Bob Mottram 2020-10-23 20:18:13 +01:00
parent b8e45c868a
commit b5d492b668
5 changed files with 36 additions and 12 deletions

View File

@ -11981,7 +11981,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
tokensLookup[token] = nickname
def runDaemon(maxNewsPosts: int,
def runDaemon(allowNewsFollowers: bool,
maxNewsPosts: int,
maxMirroredArticles: int,
maxNewswireFeedSizeKb: int,
maxNewswirePostsPerSource: int,
@ -12124,6 +12125,9 @@ def runDaemon(maxNewsPosts: int,
# maximum number of posts in the news timeline/outbox
httpd.maxNewsPosts = maxNewsPosts
# whether or not to allow followers of the news account
httpd.allowNewsFollowers = allowNewsFollowers
# The maximum number of tags per post which can be
# attached to RSS feeds pulled in via the newswire
httpd.maxTags = 32
@ -12269,7 +12273,8 @@ def runDaemon(maxNewsPosts: int,
allowDeletion, debug, maxMentions, maxEmoji,
httpd.translate, unitTest,
httpd.YTReplacementDomain,
httpd.showPublishedDateOnly), daemon=True)
httpd.showPublishedDateOnly,
httpd.allowNewsFollowers), daemon=True)
print('Creating scheduled post thread')
httpd.thrPostSchedule = \

View File

@ -204,6 +204,11 @@ parser.add_argument("--repliesEnabled", "--commentsEnabled",
type=str2bool, nargs='?',
const=True, default=True,
help="Enable replies to a post")
parser.add_argument("--allowNewsFollowers",
dest='allowNewsFollowers',
type=str2bool, nargs='?',
const=True, default=False,
help="Whether to allow the news account to be followed")
parser.add_argument("--noapproval", type=str2bool, nargs='?',
const=True, default=False,
help="Allow followers without approval")
@ -1965,6 +1970,11 @@ maxNewsPosts = \
if maxNewsPosts is not None:
args.maxNewsPosts = int(maxNewsPosts)
allowNewsFollowers = \
getConfigParam(baseDir, 'allowNewsFollowers')
if allowNewsFollowers is not None:
args.allowNewsFollowers = bool(allowNewsFollowers)
YTDomain = getConfigParam(baseDir, 'youtubedomain')
if YTDomain:
if '://' in YTDomain:
@ -1978,7 +1988,8 @@ if setTheme(baseDir, themeName, domain):
print('Theme set to ' + themeName)
if __name__ == "__main__":
runDaemon(args.maxNewsPosts,
runDaemon(args.allowNewsFollowers,
args.maxNewsPosts,
args.maxMirroredArticles,
args.maxNewswireFeedSizeKb,
args.maxNewswirePostsPerSource,

View File

@ -514,7 +514,8 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
port: int, sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {},
messageJson: {}, federationList: [],
debug: bool, projectVersion: str) -> bool:
debug: bool, projectVersion: str,
allowNewsFollowers: bool) -> bool:
"""Receives a follow request within the POST section of HTTPServer
"""
if not messageJson['type'].startswith('Follow'):
@ -576,9 +577,11 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
'nickname for the account followed')
return True
if isSystemAccount(nicknameToFollow):
if debug:
print('DEBUG: Cannot follow system account - ' + nicknameToFollow)
return True
if not (nicknameToFollow == 'news' and allowNewsFollowers):
if debug:
print('DEBUG: Cannot follow system account - ' +
nicknameToFollow)
return True
handleToFollow = nicknameToFollow + '@' + domainToFollow
if domainToFollow == domain:
if not os.path.isdir(baseDir + '/accounts/' + handleToFollow):

View File

@ -2436,7 +2436,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
allowDeletion: bool, debug: bool, maxMentions: int,
maxEmoji: int, translate: {}, unitTest: bool,
YTReplacementDomain: str,
showPublishedDateOnly: bool) -> None:
showPublishedDateOnly: bool,
allowNewsFollowers: bool) -> None:
"""Processes received items and moves them to the appropriate
directories
"""
@ -2722,7 +2723,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
personCache,
queueJson['post'],
federationList,
debug, projectVersion):
debug, projectVersion,
allowNewsFollowers):
if os.path.isfile(queueFilename):
os.remove(queueFilename)
if len(queue) > 0:

View File

@ -290,7 +290,8 @@ def createServerAlice(path: str, domain: str, port: int,
onionDomain = None
i2pDomain = None
print('Server running: Alice')
runDaemon(0, 100, 1024, 5, False, 0, False, 1, False, False, False,
runDaemon(False, 0, 100, 1024, 5, False,
0, False, 1, False, False, False,
5, True, True, 'en', __version__,
"instanceId", False, path, domain,
onionDomain, i2pDomain, None, port, port,
@ -353,7 +354,8 @@ def createServerBob(path: str, domain: str, port: int,
onionDomain = None
i2pDomain = None
print('Server running: Bob')
runDaemon(0, 100, 1024, 5, False, 0, False, 1, False, False, False,
runDaemon(False, 0, 100, 1024, 5, False, 0,
False, 1, False, False, False,
5, True, True, 'en', __version__,
"instanceId", False, path, domain,
onionDomain, i2pDomain, None, port, port,
@ -390,7 +392,8 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
onionDomain = None
i2pDomain = None
print('Server running: Eve')
runDaemon(0, 100, 1024, 5, False, 0, False, 1, False, False, False,
runDaemon(False, 0, 100, 1024, 5, False, 0,
False, 1, False, False, False,
5, True, True, 'en', __version__,
"instanceId", False, path, domain,
onionDomain, i2pDomain, None, port, port,