mirror of https://gitlab.com/bashrc2/epicyon
Command option for low bandwidth images
parent
5278d8c946
commit
e91e4a0727
36
daemon.py
36
daemon.py
|
@ -446,7 +446,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
eventTime,
|
eventTime,
|
||||||
location, False,
|
location, False,
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
conversationId)
|
conversationId,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
# name field contains the answer
|
# name field contains the answer
|
||||||
messageJson['object']['name'] = answer
|
messageJson['object']['name'] = answer
|
||||||
|
@ -13957,7 +13958,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fields['eventDate'], fields['eventTime'],
|
fields['eventDate'], fields['eventTime'],
|
||||||
fields['location'], False,
|
fields['location'], False,
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
conversationId)
|
conversationId,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -14036,7 +14038,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
conversationId)
|
conversationId,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -14120,7 +14123,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
filename,
|
filename,
|
||||||
attachmentMediaType,
|
attachmentMediaType,
|
||||||
imgDescription,
|
imgDescription,
|
||||||
city)
|
city,
|
||||||
|
self.server.lowBandwidth)
|
||||||
|
|
||||||
replaceYouTube(postJsonObject,
|
replaceYouTube(postJsonObject,
|
||||||
self.server.YTReplacementDomain,
|
self.server.YTReplacementDomain,
|
||||||
|
@ -14174,7 +14178,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
conversationId)
|
conversationId,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -14222,7 +14227,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
conversationId)
|
conversationId,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -14274,7 +14280,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
conversationId)
|
conversationId,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -14324,7 +14331,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
conversationId)
|
conversationId,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -14357,7 +14365,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fields['imageDescription'],
|
fields['imageDescription'],
|
||||||
city,
|
city,
|
||||||
self.server.debug, fields['subject'],
|
self.server.debug, fields['subject'],
|
||||||
self.server.systemLanguage)
|
self.server.systemLanguage,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if self._postToOutbox(messageJson, __version__, nickname):
|
if self._postToOutbox(messageJson, __version__, nickname):
|
||||||
return 1
|
return 1
|
||||||
|
@ -14395,7 +14404,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
city,
|
city,
|
||||||
fields['subject'],
|
fields['subject'],
|
||||||
intDuration,
|
intDuration,
|
||||||
self.server.systemLanguage)
|
self.server.systemLanguage,
|
||||||
|
self.server.lowBandwidth)
|
||||||
if messageJson:
|
if messageJson:
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: new Question')
|
print('DEBUG: new Question')
|
||||||
|
@ -15592,7 +15602,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def runDaemon(maxLikeCount: int,
|
def runDaemon(lowBandwidth: bool,
|
||||||
|
maxLikeCount: int,
|
||||||
sharedItemsFederatedDomains: [],
|
sharedItemsFederatedDomains: [],
|
||||||
userAgentsBlocked: [],
|
userAgentsBlocked: [],
|
||||||
logLoginFailures: bool,
|
logLoginFailures: bool,
|
||||||
|
@ -15722,6 +15733,9 @@ def runDaemon(maxLikeCount: int,
|
||||||
httpd.keyShortcuts = {}
|
httpd.keyShortcuts = {}
|
||||||
loadAccessKeysForAccounts(baseDir, httpd.keyShortcuts, httpd.accessKeys)
|
loadAccessKeysForAccounts(baseDir, httpd.keyShortcuts, httpd.accessKeys)
|
||||||
|
|
||||||
|
# wheither to use low bandwidth images
|
||||||
|
httpd.lowBandwidth = lowBandwidth
|
||||||
|
|
||||||
# list of blocked user agent types within the User-Agent header
|
# list of blocked user agent types within the User-Agent header
|
||||||
httpd.userAgentsBlocked = userAgentsBlocked
|
httpd.userAgentsBlocked = userAgentsBlocked
|
||||||
|
|
||||||
|
|
|
@ -416,7 +416,8 @@ def _desktopReplyToPost(session, postId: str,
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
debug: bool, subject: str,
|
debug: bool, subject: str,
|
||||||
screenreader: str, systemLanguage: str,
|
screenreader: str, systemLanguage: str,
|
||||||
espeak, conversationId: str) -> None:
|
espeak, conversationId: str,
|
||||||
|
lowBandwidth: bool) -> None:
|
||||||
"""Use the desktop client to send a reply to the most recent post
|
"""Use the desktop client to send a reply to the most recent post
|
||||||
"""
|
"""
|
||||||
if '://' not in postId:
|
if '://' not in postId:
|
||||||
|
@ -469,7 +470,8 @@ def _desktopReplyToPost(session, postId: str,
|
||||||
commentsEnabled, attach, mediaType,
|
commentsEnabled, attach, mediaType,
|
||||||
attachedImageDescription, city,
|
attachedImageDescription, city,
|
||||||
cachedWebfingers, personCache, isArticle,
|
cachedWebfingers, personCache, isArticle,
|
||||||
systemLanguage, debug, postId, postId,
|
systemLanguage, lowBandwidth,
|
||||||
|
debug, postId, postId,
|
||||||
conversationId, subject) == 0:
|
conversationId, subject) == 0:
|
||||||
sayStr = 'Reply sent'
|
sayStr = 'Reply sent'
|
||||||
else:
|
else:
|
||||||
|
@ -483,7 +485,7 @@ def _desktopNewPost(session,
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
debug: bool,
|
debug: bool,
|
||||||
screenreader: str, systemLanguage: str,
|
screenreader: str, systemLanguage: str,
|
||||||
espeak) -> None:
|
espeak, lowBandwidth: bool) -> None:
|
||||||
"""Use the desktop client to create a new post
|
"""Use the desktop client to create a new post
|
||||||
"""
|
"""
|
||||||
conversationId = None
|
conversationId = None
|
||||||
|
@ -532,7 +534,8 @@ def _desktopNewPost(session,
|
||||||
commentsEnabled, attach, mediaType,
|
commentsEnabled, attach, mediaType,
|
||||||
attachedImageDescription, city,
|
attachedImageDescription, city,
|
||||||
cachedWebfingers, personCache, isArticle,
|
cachedWebfingers, personCache, isArticle,
|
||||||
systemLanguage, debug, None, None,
|
systemLanguage, lowBandwidth,
|
||||||
|
debug, None, None,
|
||||||
conversationId, subject) == 0:
|
conversationId, subject) == 0:
|
||||||
sayStr = 'Post sent'
|
sayStr = 'Post sent'
|
||||||
else:
|
else:
|
||||||
|
@ -1108,7 +1111,7 @@ def _desktopNewDM(session, toHandle: str,
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
debug: bool,
|
debug: bool,
|
||||||
screenreader: str, systemLanguage: str,
|
screenreader: str, systemLanguage: str,
|
||||||
espeak) -> None:
|
espeak, lowBandwidth: bool) -> None:
|
||||||
"""Use the desktop client to create a new direct message
|
"""Use the desktop client to create a new direct message
|
||||||
which can include multiple destination handles
|
which can include multiple destination handles
|
||||||
"""
|
"""
|
||||||
|
@ -1129,7 +1132,7 @@ def _desktopNewDM(session, toHandle: str,
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers, personCache,
|
||||||
debug,
|
debug,
|
||||||
screenreader, systemLanguage,
|
screenreader, systemLanguage,
|
||||||
espeak)
|
espeak, lowBandwidth)
|
||||||
|
|
||||||
|
|
||||||
def _desktopNewDMbase(session, toHandle: str,
|
def _desktopNewDMbase(session, toHandle: str,
|
||||||
|
@ -1138,7 +1141,7 @@ def _desktopNewDMbase(session, toHandle: str,
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
debug: bool,
|
debug: bool,
|
||||||
screenreader: str, systemLanguage: str,
|
screenreader: str, systemLanguage: str,
|
||||||
espeak) -> None:
|
espeak, lowBandwidth: bool) -> None:
|
||||||
"""Use the desktop client to create a new direct message
|
"""Use the desktop client to create a new direct message
|
||||||
"""
|
"""
|
||||||
conversationId = None
|
conversationId = None
|
||||||
|
@ -1226,7 +1229,8 @@ def _desktopNewDMbase(session, toHandle: str,
|
||||||
commentsEnabled, attach, mediaType,
|
commentsEnabled, attach, mediaType,
|
||||||
attachedImageDescription, city,
|
attachedImageDescription, city,
|
||||||
cachedWebfingers, personCache, isArticle,
|
cachedWebfingers, personCache, isArticle,
|
||||||
systemLanguage, debug, None, None,
|
systemLanguage, lowBandwidth,
|
||||||
|
debug, None, None,
|
||||||
conversationId, subject) == 0:
|
conversationId, subject) == 0:
|
||||||
sayStr = 'Direct message sent'
|
sayStr = 'Direct message sent'
|
||||||
else:
|
else:
|
||||||
|
@ -1292,7 +1296,7 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
storeInboxPosts: bool,
|
storeInboxPosts: bool,
|
||||||
showNewPosts: bool,
|
showNewPosts: bool,
|
||||||
language: str,
|
language: str,
|
||||||
debug: bool) -> None:
|
debug: bool, lowBandwidth: bool) -> None:
|
||||||
"""Runs the desktop and screen reader client,
|
"""Runs the desktop and screen reader client,
|
||||||
which announces new inbox items
|
which announces new inbox items
|
||||||
"""
|
"""
|
||||||
|
@ -1683,7 +1687,8 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers, personCache,
|
||||||
debug, subject,
|
debug, subject,
|
||||||
screenreader, systemLanguage,
|
screenreader, systemLanguage,
|
||||||
espeak, conversationId)
|
espeak, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
refreshTimeline = True
|
refreshTimeline = True
|
||||||
print('')
|
print('')
|
||||||
elif (commandStr == 'post' or commandStr == 'p' or
|
elif (commandStr == 'post' or commandStr == 'p' or
|
||||||
|
@ -1717,7 +1722,7 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers, personCache,
|
||||||
debug,
|
debug,
|
||||||
screenreader, systemLanguage,
|
screenreader, systemLanguage,
|
||||||
espeak)
|
espeak, lowBandwidth)
|
||||||
refreshTimeline = True
|
refreshTimeline = True
|
||||||
else:
|
else:
|
||||||
# public post
|
# public post
|
||||||
|
@ -1727,7 +1732,7 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers, personCache,
|
||||||
debug,
|
debug,
|
||||||
screenreader, systemLanguage,
|
screenreader, systemLanguage,
|
||||||
espeak)
|
espeak, lowBandwidth)
|
||||||
refreshTimeline = True
|
refreshTimeline = True
|
||||||
print('')
|
print('')
|
||||||
elif commandStr == 'like' or commandStr.startswith('like '):
|
elif commandStr == 'like' or commandStr.startswith('like '):
|
||||||
|
|
36
epicyon.py
36
epicyon.py
|
@ -331,6 +331,11 @@ parser.add_argument("--rssIconAtTop",
|
||||||
const=True, default=True,
|
const=True, default=True,
|
||||||
help="Whether to show the rss icon at teh top or bottom" +
|
help="Whether to show the rss icon at teh top or bottom" +
|
||||||
"of the timeline")
|
"of the timeline")
|
||||||
|
parser.add_argument("--lowBandwidth",
|
||||||
|
dest='lowBandwidth',
|
||||||
|
type=str2bool, nargs='?',
|
||||||
|
const=True, default=True,
|
||||||
|
help="Whether to use low bandwidth images")
|
||||||
parser.add_argument("--publishButtonAtTop",
|
parser.add_argument("--publishButtonAtTop",
|
||||||
dest='publishButtonAtTop',
|
dest='publishButtonAtTop',
|
||||||
type=str2bool, nargs='?',
|
type=str2bool, nargs='?',
|
||||||
|
@ -1190,7 +1195,7 @@ if args.message:
|
||||||
args.commentsEnabled, attach, mediaType,
|
args.commentsEnabled, attach, mediaType,
|
||||||
attachedImageDescription, city,
|
attachedImageDescription, city,
|
||||||
cachedWebfingers, personCache, isArticle,
|
cachedWebfingers, personCache, isArticle,
|
||||||
args.language, args.debug,
|
args.language, args.lowBandwidth, args.debug,
|
||||||
replyTo, replyTo, args.conversationId, subject)
|
replyTo, replyTo, args.conversationId, subject)
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
# TODO detect send success/fail
|
# TODO detect send success/fail
|
||||||
|
@ -2265,7 +2270,7 @@ if args.desktop:
|
||||||
storeInboxPosts,
|
storeInboxPosts,
|
||||||
args.notifyShowNewPosts,
|
args.notifyShowNewPosts,
|
||||||
args.language,
|
args.language,
|
||||||
args.debug)
|
args.debug, args.lowBandwidth)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if federationList:
|
if federationList:
|
||||||
|
@ -2515,6 +2520,7 @@ if args.testdata:
|
||||||
testLocation = None
|
testLocation = None
|
||||||
testIsArticle = False
|
testIsArticle = False
|
||||||
conversationId = None
|
conversationId = None
|
||||||
|
lowBandwidth = False
|
||||||
|
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"like this is totally just a #test man",
|
"like this is totally just a #test man",
|
||||||
|
@ -2527,7 +2533,8 @@ if args.testdata:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"Zoiks!!!",
|
"Zoiks!!!",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -2539,7 +2546,8 @@ if args.testdata:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"Hey scoob we need like a hundred more #milkshakes",
|
"Hey scoob we need like a hundred more #milkshakes",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -2551,7 +2559,8 @@ if args.testdata:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"Getting kinda spooky around here",
|
"Getting kinda spooky around here",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -2563,7 +2572,8 @@ if args.testdata:
|
||||||
'someone', testInReplyToAtomUri,
|
'someone', testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"And they would have gotten away with it too" +
|
"And they would have gotten away with it too" +
|
||||||
"if it wasn't for those pesky hackers",
|
"if it wasn't for those pesky hackers",
|
||||||
|
@ -2576,7 +2586,8 @@ if args.testdata:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"man these centralized sites are like the worst!",
|
"man these centralized sites are like the worst!",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -2588,7 +2599,8 @@ if args.testdata:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"another mystery solved #test",
|
"another mystery solved #test",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -2600,7 +2612,8 @@ if args.testdata:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
"let's go bowling",
|
"let's go bowling",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -2612,7 +2625,8 @@ if args.testdata:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId)
|
testIsArticle, args.language, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
domainFull = domain + ':' + str(port)
|
domainFull = domain + ':' + str(port)
|
||||||
clearFollows(baseDir, nickname, domain)
|
clearFollows(baseDir, nickname, domain)
|
||||||
followPerson(baseDir, nickname, domain, 'maxboardroom', domainFull,
|
followPerson(baseDir, nickname, domain, 'maxboardroom', domainFull,
|
||||||
|
@ -2815,7 +2829,7 @@ if args.defaultCurrency:
|
||||||
print('Default currency set to ' + args.defaultCurrency)
|
print('Default currency set to ' + args.defaultCurrency)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runDaemon(args.maxLikeCount,
|
runDaemon(args.lowBandwidth, args.maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
args.logLoginFailures,
|
args.logLoginFailures,
|
||||||
|
|
3
inbox.py
3
inbox.py
|
@ -2100,6 +2100,7 @@ def _bounceDM(senderPostId: str, session, httpPrefix: str,
|
||||||
eventTime = None
|
eventTime = None
|
||||||
location = None
|
location = None
|
||||||
conversationId = None
|
conversationId = None
|
||||||
|
lowBandwidth = False
|
||||||
postJsonObject = \
|
postJsonObject = \
|
||||||
createDirectMessagePost(baseDir, nickname, domain, port,
|
createDirectMessagePost(baseDir, nickname, domain, port,
|
||||||
httpPrefix, content, followersOnly,
|
httpPrefix, content, followersOnly,
|
||||||
|
@ -2110,7 +2111,7 @@ def _bounceDM(senderPostId: str, session, httpPrefix: str,
|
||||||
inReplyTo, inReplyToAtomUri,
|
inReplyTo, inReplyToAtomUri,
|
||||||
subject, debug, schedulePost,
|
subject, debug, schedulePost,
|
||||||
eventDate, eventTime, location,
|
eventDate, eventTime, location,
|
||||||
systemLanguage, conversationId)
|
systemLanguage, conversationId, lowBandwidth)
|
||||||
if not postJsonObject:
|
if not postJsonObject:
|
||||||
print('WARN: unable to create bounce message to ' + sendingHandle)
|
print('WARN: unable to create bounce message to ' + sendingHandle)
|
||||||
return False
|
return False
|
||||||
|
|
14
media.py
14
media.py
|
@ -114,6 +114,16 @@ def _spoofMetaData(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def _convertImageToLowBandwidth(imageFilename: str) -> None:
|
||||||
|
"""Converts an image to a low bandwidth version
|
||||||
|
"""
|
||||||
|
cmd = \
|
||||||
|
'/usr/bin/convert -resize 50% +noise Multiplicative ' + \
|
||||||
|
'-evaluate median 10% -dither Floyd-Steinberg ' + \
|
||||||
|
'-monochrome ' + imageFilename + ' ' + imageFilename
|
||||||
|
subprocess.call(cmd, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def processMetaData(baseDir: str, nickname: str, domain: str,
|
def processMetaData(baseDir: str, nickname: str, domain: str,
|
||||||
imageFilename: str, outputFilename: str,
|
imageFilename: str, outputFilename: str,
|
||||||
city: str) -> None:
|
city: str) -> None:
|
||||||
|
@ -209,7 +219,7 @@ def attachMedia(baseDir: str, httpPrefix: str,
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
postJson: {}, imageFilename: str,
|
postJson: {}, imageFilename: str,
|
||||||
mediaType: str, description: str,
|
mediaType: str, description: str,
|
||||||
city: str) -> {}:
|
city: str, lowBandwidth: bool) -> {}:
|
||||||
"""Attaches media to a json object post
|
"""Attaches media to a json object post
|
||||||
The description can be None
|
The description can be None
|
||||||
"""
|
"""
|
||||||
|
@ -262,6 +272,8 @@ def attachMedia(baseDir: str, httpPrefix: str,
|
||||||
|
|
||||||
if baseDir:
|
if baseDir:
|
||||||
if mediaType.startswith('image/'):
|
if mediaType.startswith('image/'):
|
||||||
|
if lowBandwidth:
|
||||||
|
_convertImageToLowBandwidth(imageFilename)
|
||||||
processMetaData(baseDir, nickname, domain,
|
processMetaData(baseDir, nickname, domain,
|
||||||
imageFilename, mediaFilename, city)
|
imageFilename, mediaFilename, city)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -520,7 +520,8 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
sendThreads: [], postLog: [],
|
sendThreads: [], postLog: [],
|
||||||
maxMirroredArticles: int,
|
maxMirroredArticles: int,
|
||||||
allowLocalNetworkAccess: bool,
|
allowLocalNetworkAccess: bool,
|
||||||
systemLanguage: str) -> None:
|
systemLanguage: str,
|
||||||
|
lowBandwidth: bool) -> None:
|
||||||
"""Converts rss items in a newswire into posts
|
"""Converts rss items in a newswire into posts
|
||||||
"""
|
"""
|
||||||
if not newswire:
|
if not newswire:
|
||||||
|
@ -602,7 +603,7 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city,
|
imageDescription, city,
|
||||||
rssTitle, systemLanguage,
|
rssTitle, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
if not blog:
|
if not blog:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -782,7 +783,8 @@ def runNewswireDaemon(baseDir: str, httpd,
|
||||||
httpd.postLog,
|
httpd.postLog,
|
||||||
httpd.maxMirroredArticles,
|
httpd.maxMirroredArticles,
|
||||||
httpd.allowLocalNetworkAccess,
|
httpd.allowLocalNetworkAccess,
|
||||||
httpd.systemLanguage)
|
httpd.systemLanguage,
|
||||||
|
httpd.lowBandwidth)
|
||||||
print('Newswire feed converted to ActivityPub')
|
print('Newswire feed converted to ActivityPub')
|
||||||
|
|
||||||
if httpd.maxNewsPosts > 0:
|
if httpd.maxNewsPosts > 0:
|
||||||
|
|
55
posts.py
55
posts.py
|
@ -916,7 +916,7 @@ def _createPostS2S(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
mediaType: str, imageDescription: str, city: str,
|
mediaType: str, imageDescription: str, city: str,
|
||||||
postObjectType: str, summary: str,
|
postObjectType: str, summary: str,
|
||||||
inReplyToAtomUri: str, systemLanguage: str,
|
inReplyToAtomUri: str, systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
"""Creates a new server-to-server post
|
"""Creates a new server-to-server post
|
||||||
"""
|
"""
|
||||||
actorUrl = httpPrefix + '://' + domain + '/users/' + nickname
|
actorUrl = httpPrefix + '://' + domain + '/users/' + nickname
|
||||||
|
@ -975,7 +975,7 @@ def _createPostS2S(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
newPost['object'] = \
|
newPost['object'] = \
|
||||||
attachMedia(baseDir, httpPrefix, nickname, domain, port,
|
attachMedia(baseDir, httpPrefix, nickname, domain, port,
|
||||||
newPost['object'], attachImageFilename,
|
newPost['object'], attachImageFilename,
|
||||||
mediaType, imageDescription, city)
|
mediaType, imageDescription, city, lowBandwidth)
|
||||||
return newPost
|
return newPost
|
||||||
|
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ def _createPostC2S(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
mediaType: str, imageDescription: str, city: str,
|
mediaType: str, imageDescription: str, city: str,
|
||||||
postObjectType: str, summary: str,
|
postObjectType: str, summary: str,
|
||||||
inReplyToAtomUri: str, systemLanguage: str,
|
inReplyToAtomUri: str, systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: str) -> {}:
|
||||||
"""Creates a new client-to-server post
|
"""Creates a new client-to-server post
|
||||||
"""
|
"""
|
||||||
idStr = \
|
idStr = \
|
||||||
|
@ -1036,7 +1036,7 @@ def _createPostC2S(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
newPost = \
|
newPost = \
|
||||||
attachMedia(baseDir, httpPrefix, nickname, domain, port,
|
attachMedia(baseDir, httpPrefix, nickname, domain, port,
|
||||||
newPost, attachImageFilename,
|
newPost, attachImageFilename,
|
||||||
mediaType, imageDescription, city)
|
mediaType, imageDescription, city, lowBandwidth)
|
||||||
return newPost
|
return newPost
|
||||||
|
|
||||||
|
|
||||||
|
@ -1162,7 +1162,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
anonymousParticipationEnabled: bool,
|
anonymousParticipationEnabled: bool,
|
||||||
eventStatus: str, ticketUrl: str,
|
eventStatus: str, ticketUrl: str,
|
||||||
systemLanguage: str,
|
systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
"""Creates a message
|
"""Creates a message
|
||||||
"""
|
"""
|
||||||
content = removeInvalidChars(content)
|
content = removeInvalidChars(content)
|
||||||
|
@ -1292,7 +1292,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
mediaType, imageDescription, city,
|
mediaType, imageDescription, city,
|
||||||
postObjectType, summary,
|
postObjectType, summary,
|
||||||
inReplyToAtomUri, systemLanguage,
|
inReplyToAtomUri, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
else:
|
else:
|
||||||
newPost = \
|
newPost = \
|
||||||
_createPostC2S(baseDir, nickname, domain, port,
|
_createPostC2S(baseDir, nickname, domain, port,
|
||||||
|
@ -1304,7 +1304,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
mediaType, imageDescription, city,
|
mediaType, imageDescription, city,
|
||||||
postObjectType, summary,
|
postObjectType, summary,
|
||||||
inReplyToAtomUri, systemLanguage,
|
inReplyToAtomUri, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
|
|
||||||
_createPostMentions(ccUrl, newPost, toRecipients, tags)
|
_createPostMentions(ccUrl, newPost, toRecipients, tags)
|
||||||
|
|
||||||
|
@ -1544,7 +1544,7 @@ def createPublicPost(baseDir: str,
|
||||||
location: str,
|
location: str,
|
||||||
isArticle: bool,
|
isArticle: bool,
|
||||||
systemLanguage: str,
|
systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
"""Public post
|
"""Public post
|
||||||
"""
|
"""
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
@ -1575,7 +1575,7 @@ def createPublicPost(baseDir: str,
|
||||||
repliesModerationOption,
|
repliesModerationOption,
|
||||||
anonymousParticipationEnabled,
|
anonymousParticipationEnabled,
|
||||||
eventStatus, ticketUrl, systemLanguage,
|
eventStatus, ticketUrl, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
|
|
||||||
|
|
||||||
def _appendCitationsToBlogPost(baseDir: str,
|
def _appendCitationsToBlogPost(baseDir: str,
|
||||||
|
@ -1618,7 +1618,7 @@ def createBlogPost(baseDir: str,
|
||||||
subject: str, schedulePost: bool,
|
subject: str, schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str, systemLanguage: str,
|
location: str, systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
blogJson = \
|
blogJson = \
|
||||||
createPublicPost(baseDir,
|
createPublicPost(baseDir,
|
||||||
nickname, domain, port, httpPrefix,
|
nickname, domain, port, httpPrefix,
|
||||||
|
@ -1629,7 +1629,8 @@ def createBlogPost(baseDir: str,
|
||||||
inReplyTo, inReplyToAtomUri, subject,
|
inReplyTo, inReplyToAtomUri, subject,
|
||||||
schedulePost,
|
schedulePost,
|
||||||
eventDate, eventTime, location,
|
eventDate, eventTime, location,
|
||||||
True, systemLanguage, conversationId)
|
True, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
blogJson['object']['url'] = \
|
blogJson['object']['url'] = \
|
||||||
blogJson['object']['url'].replace('/@', '/users/')
|
blogJson['object']['url'].replace('/@', '/users/')
|
||||||
_appendCitationsToBlogPost(baseDir, nickname, domain, blogJson)
|
_appendCitationsToBlogPost(baseDir, nickname, domain, blogJson)
|
||||||
|
@ -1643,7 +1644,7 @@ def createNewsPost(baseDir: str,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
subject: str, systemLanguage: str,
|
subject: str, systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
clientToServer = False
|
clientToServer = False
|
||||||
inReplyTo = None
|
inReplyTo = None
|
||||||
inReplyToAtomUri = None
|
inReplyToAtomUri = None
|
||||||
|
@ -1661,7 +1662,8 @@ def createNewsPost(baseDir: str,
|
||||||
inReplyTo, inReplyToAtomUri, subject,
|
inReplyTo, inReplyToAtomUri, subject,
|
||||||
schedulePost,
|
schedulePost,
|
||||||
eventDate, eventTime, location,
|
eventDate, eventTime, location,
|
||||||
True, systemLanguage, conversationId)
|
True, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
blog['object']['type'] = 'Article'
|
blog['object']['type'] = 'Article'
|
||||||
return blog
|
return blog
|
||||||
|
|
||||||
|
@ -1674,7 +1676,7 @@ def createQuestionPost(baseDir: str,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
subject: str, durationDays: int,
|
subject: str, durationDays: int,
|
||||||
systemLanguage: str) -> {}:
|
systemLanguage: str, lowBandwidth: bool) -> {}:
|
||||||
"""Question post with multiple choice options
|
"""Question post with multiple choice options
|
||||||
"""
|
"""
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
@ -1691,7 +1693,7 @@ def createQuestionPost(baseDir: str,
|
||||||
False, None, None, None, None, None,
|
False, None, None, None, None, None,
|
||||||
None, None, None,
|
None, None, None,
|
||||||
None, None, None, None, None, systemLanguage,
|
None, None, None, None, None, systemLanguage,
|
||||||
None)
|
None, lowBandwidth)
|
||||||
messageJson['object']['type'] = 'Question'
|
messageJson['object']['type'] = 'Question'
|
||||||
messageJson['object']['oneOf'] = []
|
messageJson['object']['oneOf'] = []
|
||||||
messageJson['object']['votersCount'] = 0
|
messageJson['object']['votersCount'] = 0
|
||||||
|
@ -1723,7 +1725,7 @@ def createUnlistedPost(baseDir: str,
|
||||||
subject: str, schedulePost: bool,
|
subject: str, schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str, systemLanguage: str,
|
location: str, systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
"""Unlisted post. This has the #Public and followers links inverted.
|
"""Unlisted post. This has the #Public and followers links inverted.
|
||||||
"""
|
"""
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
@ -1740,7 +1742,7 @@ def createUnlistedPost(baseDir: str,
|
||||||
schedulePost, eventDate, eventTime, location,
|
schedulePost, eventDate, eventTime, location,
|
||||||
None, None, None, None, None,
|
None, None, None, None, None,
|
||||||
None, None, None, None, None, systemLanguage,
|
None, None, None, None, None, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
|
|
||||||
|
|
||||||
def createFollowersOnlyPost(baseDir: str,
|
def createFollowersOnlyPost(baseDir: str,
|
||||||
|
@ -1756,7 +1758,7 @@ def createFollowersOnlyPost(baseDir: str,
|
||||||
subject: str, schedulePost: bool,
|
subject: str, schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str, systemLanguage: str,
|
location: str, systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
"""Followers only post
|
"""Followers only post
|
||||||
"""
|
"""
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
@ -1773,7 +1775,7 @@ def createFollowersOnlyPost(baseDir: str,
|
||||||
schedulePost, eventDate, eventTime, location,
|
schedulePost, eventDate, eventTime, location,
|
||||||
None, None, None, None, None,
|
None, None, None, None, None,
|
||||||
None, None, None, None, None, systemLanguage,
|
None, None, None, None, None, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
|
|
||||||
|
|
||||||
def getMentionedPeople(baseDir: str, httpPrefix: str,
|
def getMentionedPeople(baseDir: str, httpPrefix: str,
|
||||||
|
@ -1826,7 +1828,7 @@ def createDirectMessagePost(baseDir: str,
|
||||||
schedulePost: bool,
|
schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str, systemLanguage: str,
|
location: str, systemLanguage: str,
|
||||||
conversationId: str) -> {}:
|
conversationId: str, lowBandwidth: bool) -> {}:
|
||||||
"""Direct Message post
|
"""Direct Message post
|
||||||
"""
|
"""
|
||||||
content = resolvePetnames(baseDir, nickname, domain, content)
|
content = resolvePetnames(baseDir, nickname, domain, content)
|
||||||
|
@ -1850,7 +1852,7 @@ def createDirectMessagePost(baseDir: str,
|
||||||
schedulePost, eventDate, eventTime, location,
|
schedulePost, eventDate, eventTime, location,
|
||||||
None, None, None, None, None,
|
None, None, None, None, None,
|
||||||
None, None, None, None, None, systemLanguage,
|
None, None, None, None, None, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
# mentioned recipients go into To rather than Cc
|
# mentioned recipients go into To rather than Cc
|
||||||
messageJson['to'] = messageJson['object']['cc']
|
messageJson['to'] = messageJson['object']['cc']
|
||||||
messageJson['object']['to'] = messageJson['to']
|
messageJson['object']['to'] = messageJson['to']
|
||||||
|
@ -1868,7 +1870,8 @@ def createReportPost(baseDir: str,
|
||||||
clientToServer: bool, commentsEnabled: bool,
|
clientToServer: bool, commentsEnabled: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
debug: bool, subject: str, systemLanguage: str) -> {}:
|
debug: bool, subject: str, systemLanguage: str,
|
||||||
|
lowBandwidth: bool) -> {}:
|
||||||
"""Send a report to moderators
|
"""Send a report to moderators
|
||||||
"""
|
"""
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
@ -1941,7 +1944,7 @@ def createReportPost(baseDir: str,
|
||||||
False, None, None, None, None, None,
|
False, None, None, None, None, None,
|
||||||
None, None, None,
|
None, None, None,
|
||||||
None, None, None, None, None, systemLanguage,
|
None, None, None, None, None, systemLanguage,
|
||||||
None)
|
None, lowBandwidth)
|
||||||
if not postJsonObject:
|
if not postJsonObject:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -2032,6 +2035,7 @@ def sendPost(projectVersion: str,
|
||||||
isArticle: bool, systemLanguage: str,
|
isArticle: bool, systemLanguage: str,
|
||||||
sharedItemsFederatedDomains: [],
|
sharedItemsFederatedDomains: [],
|
||||||
sharedItemFederationTokens: {},
|
sharedItemFederationTokens: {},
|
||||||
|
lowBandwidth: bool,
|
||||||
debug: bool = False, inReplyTo: str = None,
|
debug: bool = False, inReplyTo: str = None,
|
||||||
inReplyToAtomUri: str = None, subject: str = None) -> int:
|
inReplyToAtomUri: str = None, subject: str = None) -> int:
|
||||||
"""Post to another inbox. Used by unit tests.
|
"""Post to another inbox. Used by unit tests.
|
||||||
|
@ -2094,7 +2098,7 @@ def sendPost(projectVersion: str,
|
||||||
False, None, None, None, None, None,
|
False, None, None, None, None, None,
|
||||||
None, None, None,
|
None, None, None,
|
||||||
None, None, None, None, None, systemLanguage,
|
None, None, None, None, None, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
|
|
||||||
# get the senders private key
|
# get the senders private key
|
||||||
privateKeyPem = _getPersonKey(nickname, domain, baseDir, 'private')
|
privateKeyPem = _getPersonKey(nickname, domain, baseDir, 'private')
|
||||||
|
@ -2174,6 +2178,7 @@ def sendPostViaServer(projectVersion: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
isArticle: bool, systemLanguage: str,
|
isArticle: bool, systemLanguage: str,
|
||||||
|
lowBandwidth: bool,
|
||||||
debug: bool = False,
|
debug: bool = False,
|
||||||
inReplyTo: str = None,
|
inReplyTo: str = None,
|
||||||
inReplyToAtomUri: str = None,
|
inReplyToAtomUri: str = None,
|
||||||
|
@ -2257,7 +2262,7 @@ def sendPostViaServer(projectVersion: str,
|
||||||
False, None, None, None, None, None,
|
False, None, None, None, None, None,
|
||||||
None, None, None,
|
None, None, None,
|
||||||
None, None, None, None, None, systemLanguage,
|
None, None, None, None, None, systemLanguage,
|
||||||
conversationId)
|
conversationId, lowBandwidth)
|
||||||
|
|
||||||
authHeader = createBasicAuthHeader(fromNickname, password)
|
authHeader = createBasicAuthHeader(fromNickname, password)
|
||||||
|
|
||||||
|
|
62
tests.py
62
tests.py
|
@ -491,6 +491,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
domainMaxPostsPerDay = 1000
|
domainMaxPostsPerDay = 1000
|
||||||
accountMaxPostsPerDay = 1000
|
accountMaxPostsPerDay = 1000
|
||||||
allowDeletion = True
|
allowDeletion = True
|
||||||
|
lowBandwidth = True
|
||||||
privateKeyPem, publicKeyPem, person, wfEndpoint = \
|
privateKeyPem, publicKeyPem, person, wfEndpoint = \
|
||||||
createPerson(path, nickname, domain, port, httpPrefix, True,
|
createPerson(path, nickname, domain, port, httpPrefix, True,
|
||||||
False, password)
|
False, password)
|
||||||
|
@ -533,7 +534,8 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||||
"Curiouser and curiouser!",
|
"Curiouser and curiouser!",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -546,7 +548,8 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||||
"In the gardens of memory, in the palace " +
|
"In the gardens of memory, in the palace " +
|
||||||
"of dreams, that is where you and I shall meet",
|
"of dreams, that is where you and I shall meet",
|
||||||
|
@ -560,7 +563,8 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
||||||
global testServerAliceRunning
|
global testServerAliceRunning
|
||||||
testServerAliceRunning = True
|
testServerAliceRunning = True
|
||||||
|
@ -582,7 +586,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
userAgentsBlocked = []
|
userAgentsBlocked = []
|
||||||
maxLikeCount = 10
|
maxLikeCount = 10
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
runDaemon(maxLikeCount,
|
runDaemon(lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
|
@ -626,6 +630,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
domainMaxPostsPerDay = 1000
|
domainMaxPostsPerDay = 1000
|
||||||
accountMaxPostsPerDay = 1000
|
accountMaxPostsPerDay = 1000
|
||||||
allowDeletion = True
|
allowDeletion = True
|
||||||
|
lowBandwidth = True
|
||||||
privateKeyPem, publicKeyPem, person, wfEndpoint = \
|
privateKeyPem, publicKeyPem, person, wfEndpoint = \
|
||||||
createPerson(path, nickname, domain, port, httpPrefix, True,
|
createPerson(path, nickname, domain, port, httpPrefix, True,
|
||||||
False, password)
|
False, password)
|
||||||
|
@ -665,7 +670,8 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||||
"One of the things I've realised is that " +
|
"One of the things I've realised is that " +
|
||||||
"I am very simple",
|
"I am very simple",
|
||||||
|
@ -679,7 +685,8 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||||
"Quantum physics is a bit of a passion of mine",
|
"Quantum physics is a bit of a passion of mine",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
|
@ -692,7 +699,8 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
||||||
global testServerBobRunning
|
global testServerBobRunning
|
||||||
testServerBobRunning = True
|
testServerBobRunning = True
|
||||||
|
@ -714,7 +722,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
userAgentsBlocked = []
|
userAgentsBlocked = []
|
||||||
maxLikeCount = 10
|
maxLikeCount = 10
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
runDaemon(maxLikeCount,
|
runDaemon(lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
|
@ -777,8 +785,9 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
logLoginFailures = False
|
logLoginFailures = False
|
||||||
userAgentsBlocked = []
|
userAgentsBlocked = []
|
||||||
maxLikeCount = 10
|
maxLikeCount = 10
|
||||||
|
lowBandwidth = True
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
runDaemon(maxLikeCount,
|
runDaemon(lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
|
@ -843,8 +852,9 @@ def createServerGroup(path: str, domain: str, port: int,
|
||||||
logLoginFailures = False
|
logLoginFailures = False
|
||||||
userAgentsBlocked = []
|
userAgentsBlocked = []
|
||||||
maxLikeCount = 10
|
maxLikeCount = 10
|
||||||
|
lowBandwidth = True
|
||||||
print('Server running: Group')
|
print('Server running: Group')
|
||||||
runDaemon(maxLikeCount,
|
runDaemon(lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
|
@ -967,7 +977,7 @@ def testPostMessageBetweenServers():
|
||||||
outboxPath = aliceDir + '/accounts/alice@' + aliceDomain + '/outbox'
|
outboxPath = aliceDir + '/accounts/alice@' + aliceDomain + '/outbox'
|
||||||
assert len([name for name in os.listdir(outboxPath)
|
assert len([name for name in os.listdir(outboxPath)
|
||||||
if os.path.isfile(os.path.join(outboxPath, name))]) == 0
|
if os.path.isfile(os.path.join(outboxPath, name))]) == 0
|
||||||
|
lowBandwidth = False
|
||||||
sendResult = \
|
sendResult = \
|
||||||
sendPost(__version__,
|
sendPost(__version__,
|
||||||
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
||||||
|
@ -981,7 +991,7 @@ def testPostMessageBetweenServers():
|
||||||
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
||||||
alicePersonCache, isArticle, systemLanguage,
|
alicePersonCache, isArticle, systemLanguage,
|
||||||
aliceSharedItemsFederatedDomains,
|
aliceSharedItemsFederatedDomains,
|
||||||
aliceSharedItemFederationTokens,
|
aliceSharedItemFederationTokens, lowBandwidth,
|
||||||
inReplyTo, inReplyToAtomUri, subject)
|
inReplyTo, inReplyToAtomUri, subject)
|
||||||
print('sendResult: ' + str(sendResult))
|
print('sendResult: ' + str(sendResult))
|
||||||
|
|
||||||
|
@ -1304,6 +1314,7 @@ def testFollowBetweenServers():
|
||||||
alicePostLog = []
|
alicePostLog = []
|
||||||
isArticle = False
|
isArticle = False
|
||||||
city = 'London, England'
|
city = 'London, England'
|
||||||
|
lowBandwidth = False
|
||||||
sendResult = \
|
sendResult = \
|
||||||
sendPost(__version__,
|
sendPost(__version__,
|
||||||
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
||||||
|
@ -1314,7 +1325,7 @@ def testFollowBetweenServers():
|
||||||
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
||||||
alicePersonCache, isArticle, systemLanguage,
|
alicePersonCache, isArticle, systemLanguage,
|
||||||
aliceSharedItemsFederatedDomains,
|
aliceSharedItemsFederatedDomains,
|
||||||
aliceSharedItemFederationTokens,
|
aliceSharedItemFederationTokens, lowBandwidth,
|
||||||
inReplyTo, inReplyToAtomUri, subject)
|
inReplyTo, inReplyToAtomUri, subject)
|
||||||
print('sendResult: ' + str(sendResult))
|
print('sendResult: ' + str(sendResult))
|
||||||
|
|
||||||
|
@ -1621,6 +1632,7 @@ def testSharedItemsFederation():
|
||||||
alicePostLog = []
|
alicePostLog = []
|
||||||
isArticle = False
|
isArticle = False
|
||||||
city = 'London, England'
|
city = 'London, England'
|
||||||
|
lowBandwidth = False
|
||||||
sendResult = \
|
sendResult = \
|
||||||
sendPost(__version__,
|
sendPost(__version__,
|
||||||
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
||||||
|
@ -1631,7 +1643,7 @@ def testSharedItemsFederation():
|
||||||
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
||||||
alicePersonCache, isArticle, systemLanguage,
|
alicePersonCache, isArticle, systemLanguage,
|
||||||
aliceSharedItemsFederatedDomains,
|
aliceSharedItemsFederatedDomains,
|
||||||
aliceSharedItemFederationTokens, True,
|
aliceSharedItemFederationTokens, lowBandwidth, True,
|
||||||
inReplyTo, inReplyToAtomUri, subject)
|
inReplyTo, inReplyToAtomUri, subject)
|
||||||
print('sendResult: ' + str(sendResult))
|
print('sendResult: ' + str(sendResult))
|
||||||
|
|
||||||
|
@ -2012,6 +2024,7 @@ def testGroupFollow():
|
||||||
alicePostLog = []
|
alicePostLog = []
|
||||||
isArticle = False
|
isArticle = False
|
||||||
city = 'London, England'
|
city = 'London, England'
|
||||||
|
lowBandwidth = False
|
||||||
sendResult = \
|
sendResult = \
|
||||||
sendPost(__version__,
|
sendPost(__version__,
|
||||||
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
sessionAlice, aliceDir, 'alice', aliceDomain, alicePort,
|
||||||
|
@ -2022,7 +2035,7 @@ def testGroupFollow():
|
||||||
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
aliceSendThreads, alicePostLog, aliceCachedWebfingers,
|
||||||
alicePersonCache, isArticle, systemLanguage,
|
alicePersonCache, isArticle, systemLanguage,
|
||||||
aliceSharedItemsFederatedDomains,
|
aliceSharedItemsFederatedDomains,
|
||||||
aliceSharedItemFederationTokens,
|
aliceSharedItemFederationTokens, lowBandwidth,
|
||||||
inReplyTo, inReplyToAtomUri, subject)
|
inReplyTo, inReplyToAtomUri, subject)
|
||||||
print('sendResult: ' + str(sendResult))
|
print('sendResult: ' + str(sendResult))
|
||||||
|
|
||||||
|
@ -2363,6 +2376,7 @@ def _testCreatePerson():
|
||||||
attachImageFilename = None
|
attachImageFilename = None
|
||||||
mediaType = None
|
mediaType = None
|
||||||
conversationId = None
|
conversationId = None
|
||||||
|
lowBandwidth = True
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
content, followersOnly, saveToFile, clientToServer,
|
content, followersOnly, saveToFile, clientToServer,
|
||||||
commentsEnabled, attachImageFilename, mediaType,
|
commentsEnabled, attachImageFilename, mediaType,
|
||||||
|
@ -2370,7 +2384,8 @@ def _testCreatePerson():
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
|
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir)
|
||||||
|
@ -2428,6 +2443,7 @@ def testClientToServer():
|
||||||
httpPrefix = 'http'
|
httpPrefix = 'http'
|
||||||
proxyType = None
|
proxyType = None
|
||||||
federationList = []
|
federationList = []
|
||||||
|
lowBandwidth = False
|
||||||
|
|
||||||
baseDir = os.getcwd()
|
baseDir = os.getcwd()
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
|
@ -2522,7 +2538,8 @@ def testClientToServer():
|
||||||
attachedImageFilename, mediaType,
|
attachedImageFilename, mediaType,
|
||||||
attachedImageDescription, city,
|
attachedImageDescription, city,
|
||||||
cachedWebfingers, personCache, isArticle,
|
cachedWebfingers, personCache, isArticle,
|
||||||
systemLanguage, True, None, None,
|
systemLanguage, lowBandwidth,
|
||||||
|
True, None, None,
|
||||||
conversationId, None)
|
conversationId, None)
|
||||||
print('sendResult: ' + str(sendResult))
|
print('sendResult: ' + str(sendResult))
|
||||||
|
|
||||||
|
@ -3766,6 +3783,7 @@ def _testReplyToPublicPost() -> None:
|
||||||
testLocation = None
|
testLocation = None
|
||||||
testIsArticle = False
|
testIsArticle = False
|
||||||
conversationId = None
|
conversationId = None
|
||||||
|
lowBandwidth = True
|
||||||
reply = \
|
reply = \
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
content, followersOnly, saveToFile,
|
content, followersOnly, saveToFile,
|
||||||
|
@ -3775,7 +3793,8 @@ def _testReplyToPublicPost() -> None:
|
||||||
testInReplyToAtomUri,
|
testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
# print(str(reply))
|
# print(str(reply))
|
||||||
assert reply['object']['content'] == \
|
assert reply['object']['content'] == \
|
||||||
'<p><span class=\"h-card\">' + \
|
'<p><span class=\"h-card\">' + \
|
||||||
|
@ -4297,6 +4316,7 @@ def _testLinksWithinPost() -> None:
|
||||||
testLocation = None
|
testLocation = None
|
||||||
testIsArticle = False
|
testIsArticle = False
|
||||||
conversationId = None
|
conversationId = None
|
||||||
|
lowBandwidth = True
|
||||||
|
|
||||||
postJsonObject = \
|
postJsonObject = \
|
||||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||||
|
@ -4307,7 +4327,8 @@ def _testLinksWithinPost() -> None:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
|
|
||||||
assert postJsonObject['object']['content'] == \
|
assert postJsonObject['object']['content'] == \
|
||||||
'<p>This is a test post with links.<br><br>' + \
|
'<p>This is a test post with links.<br><br>' + \
|
||||||
|
@ -4343,7 +4364,8 @@ def _testLinksWithinPost() -> None:
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, systemLanguage, conversationId)
|
testIsArticle, systemLanguage, conversationId,
|
||||||
|
lowBandwidth)
|
||||||
assert postJsonObject['object']['content'] == content
|
assert postJsonObject['object']['content'] == content
|
||||||
assert postJsonObject['object']['contentMap'][systemLanguage] == content
|
assert postJsonObject['object']['contentMap'][systemLanguage] == content
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue