forked from indymedia/epicyon
Test that number of function arguments match
parent
49e052d5f0
commit
3ff0866deb
|
@ -174,7 +174,8 @@ def blurhash_encode(image, components_x=4, components_y=4, linear=False):
|
|||
|
||||
# Build final blurhash
|
||||
blurhash = ""
|
||||
blurhash += _base83_encode((components_x - 1) + (components_y - 1) * 9, 1)
|
||||
blurhashValue = (components_x - 1) + (components_y - 1) * 9
|
||||
blurhash += _base83_encode(blurhashValue, 1)
|
||||
blurhash += _base83_encode(quant_max_ac_component, 1)
|
||||
blurhash += _base83_encode(dc_value, 4)
|
||||
for ac_value in ac_values:
|
||||
|
|
44
daemon.py
44
daemon.py
|
@ -58,7 +58,7 @@ from person import personBoxJson
|
|||
from person import createSharedInbox
|
||||
from person import createNewsInbox
|
||||
from person import suspendAccount
|
||||
from person import unsuspendAccount
|
||||
from person import reenableAccount
|
||||
from person import removeAccount
|
||||
from person import canRemovePost
|
||||
from person import personSnooze
|
||||
|
@ -1074,13 +1074,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
beginSaveTime = time.time()
|
||||
# save the json for later queue processing
|
||||
messageBytesDecoded = messageBytes.decode('utf-8')
|
||||
queueFilename = \
|
||||
savePostToInboxQueue(self.server.baseDir,
|
||||
self.server.httpPrefix,
|
||||
nickname,
|
||||
self.server.domainFull,
|
||||
messageJson,
|
||||
messageBytes.decode('utf-8'),
|
||||
messageBytesDecoded,
|
||||
headersDict,
|
||||
self.path,
|
||||
self.server.debug)
|
||||
|
@ -1514,7 +1515,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if moderationButton == 'suspend':
|
||||
suspendAccount(baseDir, nickname, domain)
|
||||
if moderationButton == 'unsuspend':
|
||||
unsuspendAccount(baseDir, nickname)
|
||||
reenableAccount(baseDir, nickname)
|
||||
if moderationButton == 'filter':
|
||||
addGlobalFilter(baseDir, moderationText)
|
||||
if moderationButton == 'unfilter':
|
||||
|
@ -2912,11 +2913,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self.postToNickname:
|
||||
if monthStr and yearStr:
|
||||
if monthStr.isdigit() and yearStr.isdigit():
|
||||
yearInt = int(yearStr)
|
||||
monthInt = int(monthStr)
|
||||
removeCalendarEvent(baseDir,
|
||||
self.postToNickname,
|
||||
domain,
|
||||
int(yearStr),
|
||||
int(monthStr),
|
||||
yearInt,
|
||||
monthInt,
|
||||
removeMessageId)
|
||||
self._postToOutboxThread(deleteJson)
|
||||
if callingDomain.endswith('.onion') and onionDomain:
|
||||
|
@ -6837,6 +6840,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
recentPostsCache,
|
||||
maxRecentPosts,
|
||||
translate,
|
||||
self.server.baseDir,
|
||||
self.server.session,
|
||||
cachedWebfingers,
|
||||
personCache,
|
||||
|
@ -7062,6 +7066,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'show inbox page')
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = htmlInbox(self.server.cssCache,
|
||||
defaultTimeline,
|
||||
recentPostsCache,
|
||||
|
@ -7079,7 +7084,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
allowDeletion,
|
||||
httpPrefix,
|
||||
projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -7185,6 +7190,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.votingTimeMins)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlInboxDMs(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -7203,7 +7209,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -7301,6 +7307,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.votingTimeMins)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlInboxReplies(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -7319,7 +7326,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -7417,6 +7424,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.votingTimeMins)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlInboxMedia(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -7435,7 +7443,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -7534,6 +7542,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.votingTimeMins)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlInboxBlogs(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -7552,7 +7561,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -7659,6 +7668,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
editor = isEditor(baseDir, currNickname)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlInboxNews(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -7677,7 +7687,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -7782,6 +7792,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
currNickname = currNickname.split('/')[0]
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlInboxFeatures(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -7800,7 +7811,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -7967,6 +7978,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.votingTimeMins)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlBookmarks(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -7985,7 +7997,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -8087,6 +8099,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.votingTimeMins)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlEvents(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -8105,7 +8118,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
@ -8199,6 +8212,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.votingTimeMins)
|
||||
fullWidthTimelineButtonHeader = \
|
||||
self.server.fullWidthTimelineButtonHeader
|
||||
minimalNick = self._isMinimal(nickname)
|
||||
msg = \
|
||||
htmlOutbox(self.server.cssCache,
|
||||
self.server.defaultTimeline,
|
||||
|
@ -8217,7 +8231,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.allowDeletion,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
self._isMinimal(nickname),
|
||||
minimalNick,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.newswire,
|
||||
|
|
79
epicyon.py
79
epicyon.py
|
@ -1124,7 +1124,7 @@ if args.undoItemName:
|
|||
cachedWebfingers = {}
|
||||
print('Sending undo of shared item: ' + args.undoItemName)
|
||||
|
||||
sendUndoShareViaServer(session,
|
||||
sendUndoShareViaServer(baseDir, session,
|
||||
args.nickname, args.password,
|
||||
domain, port,
|
||||
httpPrefix,
|
||||
|
@ -1931,33 +1931,88 @@ if args.testdata:
|
|||
|
||||
deleteAllPosts(baseDir, nickname, domain, 'inbox')
|
||||
deleteAllPosts(baseDir, nickname, domain, 'outbox')
|
||||
|
||||
testFollowersOnly = False
|
||||
testSaveToFile = True
|
||||
testClientToServer = False
|
||||
testCommentsEnabled = True
|
||||
testAttachImageFilename = None
|
||||
testMediaType = None
|
||||
testImageDescription = None
|
||||
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"like, this is totally just a #test, man",
|
||||
False, True, False, True, None, None, useBlurhash)
|
||||
"like this is totally just a #test man",
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType, testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"Zoiks!!!",
|
||||
False, True, False, True, None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType, testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"Hey scoob we need like a hundred more #milkshakes",
|
||||
False, True, False, True, None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType, testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"Getting kinda spooky around here",
|
||||
False, True, False, True, None, None,
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType, testImageDescription,
|
||||
useBlurhash, 'someone')
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"And they would have gotten away with it too" +
|
||||
"if it wasn't for those pesky hackers",
|
||||
False, True, False, True, 'img/logo.png',
|
||||
'Description of image', useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
'img/logo.png', 'image/png',
|
||||
'Description of image',
|
||||
useBlurhash)
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"man, these centralized sites are, like, the worst!",
|
||||
False, True, False, True, None, None, useBlurhash)
|
||||
"man these centralized sites are like the worst!",
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType, testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"another mystery solved #test",
|
||||
False, True, False, True, None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType, testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
|
||||
"let's go bowling",
|
||||
False, True, False, True, None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
testClientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType, testImageDescription,
|
||||
useBlurhash)
|
||||
|
||||
domainFull = domain + ':' + str(port)
|
||||
clearFollows(baseDir, nickname, domain)
|
||||
|
|
28
inbox.py
28
inbox.py
|
@ -959,8 +959,9 @@ def _receiveLike(recentPostsCache: {},
|
|||
if not os.path.isdir(baseDir + '/accounts/' + handle):
|
||||
print('DEBUG: unknown recipient of like - ' + handle)
|
||||
# if this post in the outbox of the person?
|
||||
postFilename = locatePost(baseDir, handle.split('@')[0],
|
||||
handle.split('@')[1],
|
||||
handleName = handle.split('@')[0]
|
||||
handleDom = handle.split('@')[1]
|
||||
postFilename = locatePost(baseDir, handleName, handleDom,
|
||||
messageJson['object'])
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -970,9 +971,10 @@ def _receiveLike(recentPostsCache: {},
|
|||
if debug:
|
||||
print('DEBUG: liked post found in inbox')
|
||||
|
||||
handleName = handle.split('@')[0]
|
||||
handleDom = handle.split('@')[1]
|
||||
if not _alreadyLiked(baseDir,
|
||||
handle.split('@')[0],
|
||||
handle.split('@')[1],
|
||||
handleName, handleDom,
|
||||
messageJson['object'],
|
||||
messageJson['actor']):
|
||||
updateLikesCollection(recentPostsCache, baseDir, postFilename,
|
||||
|
@ -1028,8 +1030,10 @@ def _receiveUndoLike(recentPostsCache: {},
|
|||
if not os.path.isdir(baseDir + '/accounts/' + handle):
|
||||
print('DEBUG: unknown recipient of undo like - ' + handle)
|
||||
# if this post in the outbox of the person?
|
||||
handleName = handle.split('@')[0]
|
||||
handleDom = handle.split('@')[1]
|
||||
postFilename = \
|
||||
locatePost(baseDir, handle.split('@')[0], handle.split('@')[1],
|
||||
locatePost(baseDir, handleName, handleDom,
|
||||
messageJson['object']['object'])
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -1446,8 +1450,9 @@ def _receiveUndoAnnounce(recentPostsCache: {},
|
|||
if not os.path.isdir(baseDir + '/accounts/' + handle):
|
||||
print('DEBUG: unknown recipient of undo announce - ' + handle)
|
||||
# if this post in the outbox of the person?
|
||||
postFilename = locatePost(baseDir, handle.split('@')[0],
|
||||
handle.split('@')[1],
|
||||
handleName = handle.split('@')[0]
|
||||
handleDom = handle.split('@')[1]
|
||||
postFilename = locatePost(baseDir, handleName, handleDom,
|
||||
messageJson['object']['object'])
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -2361,13 +2366,14 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
|||
print('Saving inbox post as html to cache')
|
||||
|
||||
htmlCacheStartTime = time.time()
|
||||
handleName = handle.split('@')[0]
|
||||
_inboxStorePostToHtmlCache(recentPostsCache,
|
||||
maxRecentPosts,
|
||||
translate, baseDir,
|
||||
httpPrefix,
|
||||
session, cachedWebfingers,
|
||||
personCache,
|
||||
handle.split('@')[0],
|
||||
handleName,
|
||||
domain, port,
|
||||
postJsonObject,
|
||||
allowDeletion,
|
||||
|
@ -2383,7 +2389,8 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
|||
|
||||
_inboxUpdateCalendar(baseDir, handle, postJsonObject)
|
||||
|
||||
storeHashTags(baseDir, handle.split('@')[0], postJsonObject)
|
||||
handleName = handle.split('@')[0]
|
||||
storeHashTags(baseDir, handleName, postJsonObject)
|
||||
|
||||
# send the post out to group members
|
||||
if isGroup:
|
||||
|
@ -2710,12 +2717,13 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
if debug:
|
||||
print('DEBUG: checking http headers')
|
||||
pprint(queueJson['httpHeaders'])
|
||||
postStr = json.dumps(queueJson['post'])
|
||||
if not verifyPostHeaders(httpPrefix,
|
||||
pubKey,
|
||||
queueJson['httpHeaders'],
|
||||
queueJson['path'], False,
|
||||
queueJson['digest'],
|
||||
json.dumps(queueJson['post']),
|
||||
postStr,
|
||||
debug):
|
||||
print('Queue: Header signature check failed')
|
||||
pprint(queueJson['httpHeaders'])
|
||||
|
|
|
@ -813,13 +813,14 @@ def _addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str,
|
|||
content = postJsonObject['object']['content']
|
||||
description = firstParagraphFromString(content)
|
||||
description = _removeCDATA(description)
|
||||
tagsFromPost = _getHashtagsFromPost(postJsonObject)
|
||||
_addNewswireDictEntry(baseDir, domain,
|
||||
newswire, published,
|
||||
postJsonObject['object']['summary'],
|
||||
postJsonObject['object']['url'],
|
||||
votes, fullPostFilename,
|
||||
description, moderated, False,
|
||||
_getHashtagsFromPost(postJsonObject),
|
||||
tagsFromPost,
|
||||
maxTags)
|
||||
|
||||
ctr += 1
|
||||
|
|
|
@ -758,7 +758,7 @@ def setBio(baseDir: str, nickname: str, domain: str, bio: str) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def unsuspendAccount(baseDir: str, nickname: str) -> None:
|
||||
def reenableAccount(baseDir: str, nickname: str) -> None:
|
||||
"""Removes an account suspention
|
||||
"""
|
||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||
|
@ -897,7 +897,7 @@ def removeAccount(baseDir: str, nickname: str,
|
|||
if moderator.strip('\n') == nickname:
|
||||
return False
|
||||
|
||||
unsuspendAccount(baseDir, nickname)
|
||||
reenableAccount(baseDir, nickname)
|
||||
handle = nickname + '@' + domain
|
||||
removePassword(baseDir, nickname)
|
||||
_removeTagsForNickname(baseDir, nickname, domain, port)
|
||||
|
|
3
posts.py
3
posts.py
|
@ -1936,8 +1936,9 @@ def sendPostViaServer(projectVersion: str,
|
|||
'Content-type': 'application/json',
|
||||
'Authorization': authHeader
|
||||
}
|
||||
postDumps = json.dumps(postJsonObject)
|
||||
postResult = \
|
||||
postJsonString(session, json.dumps(postJsonObject), [],
|
||||
postJsonString(session, postDumps, [],
|
||||
inboxUrl, headers, debug)
|
||||
if not postResult:
|
||||
if debug:
|
||||
|
|
|
@ -104,7 +104,9 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
|||
httpd.proxyType,
|
||||
httpd.projectVersion,
|
||||
httpd.debug,
|
||||
httpd.YTReplacementDomain):
|
||||
httpd.YTReplacementDomain,
|
||||
httpd.showPublishedDateOnly,
|
||||
httpd.allowLocalNetworkAccess):
|
||||
indexLines.remove(line)
|
||||
os.remove(postFilename)
|
||||
continue
|
||||
|
|
161
tests.py
161
tests.py
|
@ -274,19 +274,44 @@ def createServerAlice(path: str, domain: str, port: int,
|
|||
followerOfPerson(path, nickname, domain, 'bob', bobAddress,
|
||||
federationList, False)
|
||||
if hasPosts:
|
||||
clientToServer = False
|
||||
testFollowersOnly = False
|
||||
testSaveToFile = True
|
||||
clientToServer = False
|
||||
testCommentsEnabled = True
|
||||
testAttachImageFilename = None
|
||||
testMediaType = None
|
||||
testImageDescription = None
|
||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||
"No wise fish would go anywhere without a porpoise",
|
||||
False, True, clientToServer, True,
|
||||
None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
clientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType,
|
||||
testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||
"Curiouser and curiouser!", False, True,
|
||||
clientToServer, True, None, None, useBlurhash)
|
||||
"Curiouser and curiouser!",
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
clientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType,
|
||||
testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||
"In the gardens of memory, in the palace " +
|
||||
"of dreams, that is where you and I shall meet",
|
||||
False, True, clientToServer, True,
|
||||
None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
clientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType,
|
||||
testImageDescription,
|
||||
useBlurhash)
|
||||
global testServerAliceRunning
|
||||
testServerAliceRunning = True
|
||||
maxMentions = 10
|
||||
|
@ -346,19 +371,42 @@ def createServerBob(path: str, domain: str, port: int,
|
|||
followerOfPerson(path, nickname, domain,
|
||||
'alice', aliceAddress, federationList, False)
|
||||
if hasPosts:
|
||||
testFollowersOnly = False
|
||||
testSaveToFile = True
|
||||
testCommentsEnabled = True
|
||||
testAttachImageFilename = None
|
||||
testMediaType = None
|
||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||
"It's your life, live it your way.",
|
||||
False, True, clientToServer, True,
|
||||
None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
clientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType,
|
||||
testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||
"One of the things I've realised is that " +
|
||||
"I am very simple",
|
||||
False, True, clientToServer, True,
|
||||
None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
clientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType,
|
||||
testImageDescription,
|
||||
useBlurhash)
|
||||
createPublicPost(path, nickname, domain, port, httpPrefix,
|
||||
"Quantum physics is a bit of a passion of mine",
|
||||
False, True, clientToServer, True,
|
||||
None, None, useBlurhash)
|
||||
testFollowersOnly,
|
||||
testSaveToFile,
|
||||
clientToServer,
|
||||
testCommentsEnabled,
|
||||
testAttachImageFilename,
|
||||
testMediaType,
|
||||
testImageDescription,
|
||||
useBlurhash)
|
||||
global testServerBobRunning
|
||||
testServerBobRunning = True
|
||||
maxMentions = 10
|
||||
|
@ -601,10 +649,12 @@ def testPostMessageBetweenServers():
|
|||
print('\n\n*******************************************************')
|
||||
print("Bob likes Alice's post")
|
||||
|
||||
aliceDomainStr = aliceDomain + ':' + str(alicePort)
|
||||
followerOfPerson(bobDir, 'bob', bobDomain, 'alice',
|
||||
aliceDomain + ':' + str(alicePort), federationList, False)
|
||||
aliceDomainStr, federationList, False)
|
||||
bobDomainStr = bobDomain + ':' + str(bobPort)
|
||||
followPerson(aliceDir, 'alice', aliceDomain, 'bob',
|
||||
bobDomain + ':' + str(bobPort), federationList, False)
|
||||
bobDomainStr, federationList, False)
|
||||
|
||||
sessionBob = createSession(proxyType)
|
||||
bobPostLog = []
|
||||
|
@ -1753,7 +1803,8 @@ def testWebLinks():
|
|||
'they prefer to cling to their customs, beliefs, and traditions ' + \
|
||||
'rather than to accept the teachings of a war of each ' + \
|
||||
'against all"\n\n--Peter Kropotkin'
|
||||
resultText = removeLongWords(addWebLinks(exampleText), 40, [])
|
||||
testFnStr = addWebLinks(exampleText)
|
||||
resultText = removeLongWords(testFnStr, 40, [])
|
||||
assert resultText == exampleText
|
||||
assert 'ellipsis' not in resultText
|
||||
|
||||
|
@ -1767,7 +1818,8 @@ def testWebLinks():
|
|||
|
||||
exampleText = \
|
||||
'<p>Test1 test2 #YetAnotherExcessivelyLongwindedAndBoringHashtag</p>'
|
||||
resultText = removeLongWords(addWebLinks(exampleText), 40, [])
|
||||
testFnStr = addWebLinks(exampleText)
|
||||
resultText = removeLongWords(testFnStr, 40, [])
|
||||
assert(resultText ==
|
||||
'<p>Test1 test2 '
|
||||
'#YetAnotherExcessivelyLongwindedAndBorin\ngHashtag</p>')
|
||||
|
@ -1776,7 +1828,8 @@ def testWebLinks():
|
|||
"<p>Don't remove a p2p link " + \
|
||||
"rad:git:hwd1yrerc3mcgn8ga9rho3dqi4w33nep7kxmqezss4topyfgmexihp" + \
|
||||
"33xcw</p>"
|
||||
resultText = removeLongWords(addWebLinks(exampleText), 40, [])
|
||||
testFnStr = addWebLinks(exampleText)
|
||||
resultText = removeLongWords(testFnStr, 40, [])
|
||||
assert resultText == exampleText
|
||||
|
||||
|
||||
|
@ -2533,6 +2586,48 @@ def testReplyToPublicPost() -> None:
|
|||
httpPrefix + '://rat.site/users/ninjarodent'
|
||||
|
||||
|
||||
def getFunctionCallArgs(name: str, lines: [], startLineCtr: int) -> []:
|
||||
"""Returns the arguments of a function call given lines
|
||||
of source code and a starting line number
|
||||
"""
|
||||
argsStr = lines[startLineCtr].split(name + '(')[1]
|
||||
if ')' in argsStr:
|
||||
argsStr = argsStr.split(')')[0].replace(' ', '').split(',')
|
||||
return argsStr
|
||||
for lineCtr in range(startLineCtr + 1, len(lines)):
|
||||
if ')' not in lines[lineCtr]:
|
||||
argsStr += lines[lineCtr]
|
||||
continue
|
||||
else:
|
||||
argsStr += lines[lineCtr].split(')')[0]
|
||||
break
|
||||
return argsStr.replace('\n', '').replace(' ', '').split(',')
|
||||
|
||||
|
||||
def functionArgsMatch(callArgs: [], funcArgs: []):
|
||||
"""Do the function artuments match the function call arguments
|
||||
"""
|
||||
if len(callArgs) == len(funcArgs):
|
||||
return True
|
||||
|
||||
# count non-optional arguments
|
||||
callArgsCtr = 0
|
||||
for a in callArgs:
|
||||
if a == 'self':
|
||||
continue
|
||||
if '=' not in a:
|
||||
callArgsCtr += 1
|
||||
|
||||
funcArgsCtr = 0
|
||||
for a in funcArgs:
|
||||
if a == 'self':
|
||||
continue
|
||||
if '=' not in a:
|
||||
funcArgsCtr += 1
|
||||
|
||||
return callArgsCtr >= funcArgsCtr
|
||||
|
||||
|
||||
def testFunctions():
|
||||
print('testFunctions')
|
||||
function = {}
|
||||
|
@ -2575,18 +2670,48 @@ def testFunctions():
|
|||
}
|
||||
break
|
||||
|
||||
excludeFuncArgs = [
|
||||
'pyjsonld'
|
||||
]
|
||||
excludeFuncs = [
|
||||
'link'
|
||||
]
|
||||
# which modules is each function used within?
|
||||
for modName, modProperties in modules.items():
|
||||
print('Module: ' + modName + ' ✓')
|
||||
for name, properties in functionProperties.items():
|
||||
lineCtr = 0
|
||||
for line in modules[modName]['lines']:
|
||||
if line.startswith('def '):
|
||||
lineCtr += 1
|
||||
continue
|
||||
if name + '(' in line:
|
||||
modList = \
|
||||
functionProperties[name]['calledInModule']
|
||||
if modName not in modList:
|
||||
modList.append(modName)
|
||||
if modName in excludeFuncArgs:
|
||||
lineCtr += 1
|
||||
continue
|
||||
if name in excludeFuncs:
|
||||
lineCtr += 1
|
||||
continue
|
||||
callArgs = \
|
||||
getFunctionCallArgs(name,
|
||||
modules[modName]['lines'],
|
||||
lineCtr)
|
||||
if not functionArgsMatch(callArgs,
|
||||
functionProperties[name]['args']):
|
||||
print('Call to function ' + name +
|
||||
' does not match its arguments')
|
||||
print('def args: ' +
|
||||
str(len(functionProperties[name]['args'])) +
|
||||
'\n' + str(functionProperties[name]['args']))
|
||||
print('Call args: ' + str(len(callArgs)) + '\n' +
|
||||
str(callArgs))
|
||||
print('module ' + modName + ' line ' + str(lineCtr))
|
||||
assert False
|
||||
lineCtr += 1
|
||||
|
||||
# don't check these functions, because they are procedurally called
|
||||
exclusions = [
|
||||
|
|
2
theme.py
2
theme.py
|
@ -579,7 +579,7 @@ def setTheme(baseDir: str, name: str, domain: str,
|
|||
|
||||
if not result:
|
||||
# default
|
||||
_setThemeDefault(baseDir)
|
||||
_setThemeDefault(baseDir, allowLocalNetworkAccess)
|
||||
result = True
|
||||
|
||||
variablesFile = baseDir + '/theme/' + name + '/theme.json'
|
||||
|
|
3
utils.py
3
utils.py
|
@ -647,7 +647,8 @@ def followPerson(baseDir: str, nickname: str, domain: str,
|
|||
followFile='following.txt') -> bool:
|
||||
"""Adds a person to the follow list
|
||||
"""
|
||||
if not domainPermitted(followDomain.lower().replace('\n', ''),
|
||||
followDomainStrLower = followDomain.lower().replace('\n', '')
|
||||
if not domainPermitted(followDomainStrLower,
|
||||
federationList):
|
||||
if debug:
|
||||
print('DEBUG: follow of domain ' +
|
||||
|
|
|
@ -40,10 +40,12 @@ def _htmlFrontScreenPosts(recentPostsCache: {}, maxRecentPosts: int,
|
|||
boxName = 'tlfeatures'
|
||||
authorized = True
|
||||
while ctr < maxItems and currPage < 4:
|
||||
outboxFeedPathStr = \
|
||||
'/users/' + nickname + '/' + boxName + \
|
||||
'?page=' + str(currPage)
|
||||
outboxFeed = \
|
||||
personBoxJson({}, session, baseDir, domain, port,
|
||||
'/users/' + nickname + '/' + boxName +
|
||||
'?page=' + str(currPage),
|
||||
outboxFeedPathStr,
|
||||
httpPrefix, 10, boxName,
|
||||
authorized, 0, False, 0)
|
||||
if not outboxFeed:
|
||||
|
|
|
@ -110,8 +110,9 @@ def htmlAccountInfo(cssCache: {}, translate: {},
|
|||
urlCtr += 1
|
||||
blockedPostsHtml = ''
|
||||
if blockedPostsLinks:
|
||||
blockNoStr = 'blockNumber' + str(ctr)
|
||||
blockedPostsHtml = \
|
||||
getContentWarningButton('blockNumber' + str(ctr),
|
||||
getContentWarningButton(blockNoStr,
|
||||
translate, blockedPostsLinks)
|
||||
ctr += 1
|
||||
|
||||
|
|
|
@ -772,7 +772,7 @@ def _getPostTitleAnnounceHtml(baseDir: str,
|
|||
containerClassIcons, containerClass)
|
||||
|
||||
|
||||
def _replyToYourselfHtml(translate: {}, ) -> str:
|
||||
def _replyToYourselfHtml(translate: {}) -> str:
|
||||
"""Returns html for a title which is a reply to yourself
|
||||
"""
|
||||
return ' <img loading="lazy" title="' + \
|
||||
|
|
|
@ -685,11 +685,13 @@ def _htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
|
|||
currPage = 1
|
||||
boxName = 'outbox'
|
||||
while ctr < maxItems and currPage < 4:
|
||||
outboxFeedPathStr = \
|
||||
'/users/' + nickname + '/' + boxName + '?page=' + \
|
||||
str(currPage)
|
||||
outboxFeed = \
|
||||
personBoxJson({}, session, baseDir, domain,
|
||||
port,
|
||||
'/users/' + nickname + '/' + boxName + '?page=' +
|
||||
str(currPage),
|
||||
outboxFeedPathStr,
|
||||
httpPrefix,
|
||||
10, boxName,
|
||||
authorized, 0, False, 0)
|
||||
|
|
Loading…
Reference in New Issue