forked from indymedia/epicyon
Optionally allow the news account to be followed
parent
b8e45c868a
commit
b5d492b668
|
@ -11981,7 +11981,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
|
||||||
tokensLookup[token] = nickname
|
tokensLookup[token] = nickname
|
||||||
|
|
||||||
|
|
||||||
def runDaemon(maxNewsPosts: int,
|
def runDaemon(allowNewsFollowers: bool,
|
||||||
|
maxNewsPosts: int,
|
||||||
maxMirroredArticles: int,
|
maxMirroredArticles: int,
|
||||||
maxNewswireFeedSizeKb: int,
|
maxNewswireFeedSizeKb: int,
|
||||||
maxNewswirePostsPerSource: int,
|
maxNewswirePostsPerSource: int,
|
||||||
|
@ -12124,6 +12125,9 @@ def runDaemon(maxNewsPosts: int,
|
||||||
# maximum number of posts in the news timeline/outbox
|
# maximum number of posts in the news timeline/outbox
|
||||||
httpd.maxNewsPosts = maxNewsPosts
|
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
|
# The maximum number of tags per post which can be
|
||||||
# attached to RSS feeds pulled in via the newswire
|
# attached to RSS feeds pulled in via the newswire
|
||||||
httpd.maxTags = 32
|
httpd.maxTags = 32
|
||||||
|
@ -12269,7 +12273,8 @@ def runDaemon(maxNewsPosts: int,
|
||||||
allowDeletion, debug, maxMentions, maxEmoji,
|
allowDeletion, debug, maxMentions, maxEmoji,
|
||||||
httpd.translate, unitTest,
|
httpd.translate, unitTest,
|
||||||
httpd.YTReplacementDomain,
|
httpd.YTReplacementDomain,
|
||||||
httpd.showPublishedDateOnly), daemon=True)
|
httpd.showPublishedDateOnly,
|
||||||
|
httpd.allowNewsFollowers), daemon=True)
|
||||||
|
|
||||||
print('Creating scheduled post thread')
|
print('Creating scheduled post thread')
|
||||||
httpd.thrPostSchedule = \
|
httpd.thrPostSchedule = \
|
||||||
|
|
13
epicyon.py
13
epicyon.py
|
@ -204,6 +204,11 @@ parser.add_argument("--repliesEnabled", "--commentsEnabled",
|
||||||
type=str2bool, nargs='?',
|
type=str2bool, nargs='?',
|
||||||
const=True, default=True,
|
const=True, default=True,
|
||||||
help="Enable replies to a post")
|
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='?',
|
parser.add_argument("--noapproval", type=str2bool, nargs='?',
|
||||||
const=True, default=False,
|
const=True, default=False,
|
||||||
help="Allow followers without approval")
|
help="Allow followers without approval")
|
||||||
|
@ -1965,6 +1970,11 @@ maxNewsPosts = \
|
||||||
if maxNewsPosts is not None:
|
if maxNewsPosts is not None:
|
||||||
args.maxNewsPosts = int(maxNewsPosts)
|
args.maxNewsPosts = int(maxNewsPosts)
|
||||||
|
|
||||||
|
allowNewsFollowers = \
|
||||||
|
getConfigParam(baseDir, 'allowNewsFollowers')
|
||||||
|
if allowNewsFollowers is not None:
|
||||||
|
args.allowNewsFollowers = bool(allowNewsFollowers)
|
||||||
|
|
||||||
YTDomain = getConfigParam(baseDir, 'youtubedomain')
|
YTDomain = getConfigParam(baseDir, 'youtubedomain')
|
||||||
if YTDomain:
|
if YTDomain:
|
||||||
if '://' in YTDomain:
|
if '://' in YTDomain:
|
||||||
|
@ -1978,7 +1988,8 @@ if setTheme(baseDir, themeName, domain):
|
||||||
print('Theme set to ' + themeName)
|
print('Theme set to ' + themeName)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runDaemon(args.maxNewsPosts,
|
runDaemon(args.allowNewsFollowers,
|
||||||
|
args.maxNewsPosts,
|
||||||
args.maxMirroredArticles,
|
args.maxMirroredArticles,
|
||||||
args.maxNewswireFeedSizeKb,
|
args.maxNewswireFeedSizeKb,
|
||||||
args.maxNewswirePostsPerSource,
|
args.maxNewswirePostsPerSource,
|
||||||
|
|
11
follow.py
11
follow.py
|
@ -514,7 +514,8 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
port: int, sendThreads: [], postLog: [],
|
port: int, sendThreads: [], postLog: [],
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
messageJson: {}, federationList: [],
|
messageJson: {}, federationList: [],
|
||||||
debug: bool, projectVersion: str) -> bool:
|
debug: bool, projectVersion: str,
|
||||||
|
allowNewsFollowers: bool) -> 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'):
|
||||||
|
@ -576,9 +577,11 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
'nickname for the account followed')
|
'nickname for the account followed')
|
||||||
return True
|
return True
|
||||||
if isSystemAccount(nicknameToFollow):
|
if isSystemAccount(nicknameToFollow):
|
||||||
if debug:
|
if not (nicknameToFollow == 'news' and allowNewsFollowers):
|
||||||
print('DEBUG: Cannot follow system account - ' + nicknameToFollow)
|
if debug:
|
||||||
return True
|
print('DEBUG: Cannot follow system account - ' +
|
||||||
|
nicknameToFollow)
|
||||||
|
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
|
@ -2436,7 +2436,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
allowDeletion: bool, debug: bool, maxMentions: int,
|
allowDeletion: bool, debug: bool, maxMentions: int,
|
||||||
maxEmoji: int, translate: {}, unitTest: bool,
|
maxEmoji: int, translate: {}, unitTest: bool,
|
||||||
YTReplacementDomain: str,
|
YTReplacementDomain: str,
|
||||||
showPublishedDateOnly: bool) -> None:
|
showPublishedDateOnly: bool,
|
||||||
|
allowNewsFollowers: bool) -> None:
|
||||||
"""Processes received items and moves them to the appropriate
|
"""Processes received items and moves them to the appropriate
|
||||||
directories
|
directories
|
||||||
"""
|
"""
|
||||||
|
@ -2722,7 +2723,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
personCache,
|
personCache,
|
||||||
queueJson['post'],
|
queueJson['post'],
|
||||||
federationList,
|
federationList,
|
||||||
debug, projectVersion):
|
debug, projectVersion,
|
||||||
|
allowNewsFollowers):
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
|
|
9
tests.py
9
tests.py
|
@ -290,7 +290,8 @@ 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(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__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
|
@ -353,7 +354,8 @@ 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(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__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
|
@ -390,7 +392,8 @@ 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(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__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
|
|
Loading…
Reference in New Issue