mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
5b5efce7f9
commit
396edbcc79
50
daemon.py
50
daemon.py
|
@ -7368,7 +7368,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actorLiked = actorLiked.split('?')[0]
|
||||
|
||||
# if this is an announce then send the like to the original post
|
||||
origActor, origPostUrl = \
|
||||
origActor, origPostUrl, origFilename = \
|
||||
getOriginalPostFromAnnounceUrl(likeUrl, baseDir,
|
||||
self.postToNickname, domain)
|
||||
likeUrl2 = likeUrl
|
||||
|
@ -7394,25 +7394,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if likedPostFilename:
|
||||
recentPostsCache = self.server.recentPostsCache
|
||||
likedPostJson = loadJson(likedPostFilename, 0, 1)
|
||||
if likedPostJson:
|
||||
if likedPostJson.get('type'):
|
||||
if likedPostJson['type'] == 'Announce' and \
|
||||
likedPostJson.get('object'):
|
||||
if isinstance(likedPostJson['object'], str):
|
||||
announceLikeUrl = likedPostJson['object']
|
||||
announceLikedFilename = \
|
||||
locatePost(baseDir, self.postToNickname,
|
||||
domain, announceLikeUrl)
|
||||
if announceLikedFilename:
|
||||
if origFilename and origPostUrl:
|
||||
updateLikesCollection(recentPostsCache,
|
||||
baseDir,
|
||||
likedPostFilename,
|
||||
likeUrl,
|
||||
likeActor,
|
||||
self.postToNickname,
|
||||
baseDir, likedPostFilename,
|
||||
likeUrl, likeActor, self.postToNickname,
|
||||
domain, debug)
|
||||
likeUrl = announceLikeUrl
|
||||
likedPostFilename = announceLikedFilename
|
||||
likeUrl = origPostUrl
|
||||
likedPostFilename = origFilename
|
||||
if debug:
|
||||
print('Updating likes for ' + likedPostFilename)
|
||||
updateLikesCollection(recentPostsCache,
|
||||
|
@ -7545,7 +7533,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actorLiked = actorLiked.split('?')[0]
|
||||
|
||||
# if this is an announce then send the like to the original post
|
||||
origActor, origPostUrl = \
|
||||
origActor, origPostUrl, origFilename = \
|
||||
getOriginalPostFromAnnounceUrl(likeUrl, baseDir,
|
||||
self.postToNickname, domain)
|
||||
likeUrl2 = likeUrl
|
||||
|
@ -7574,26 +7562,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.postToNickname,
|
||||
domain, likeUrl)
|
||||
if likedPostFilename:
|
||||
likedPostJson = loadJson(likedPostFilename, 0, 1)
|
||||
recentPostsCache = self.server.recentPostsCache
|
||||
if likedPostJson:
|
||||
if likedPostJson.get('type'):
|
||||
if likedPostJson['type'] == 'Announce' and \
|
||||
likedPostJson.get('object'):
|
||||
if isinstance(likedPostJson['object'], str):
|
||||
announceLikeUrl = likedPostJson['object']
|
||||
announceLikedFilename = \
|
||||
locatePost(baseDir, self.postToNickname,
|
||||
domain, announceLikeUrl)
|
||||
if announceLikedFilename:
|
||||
likedPostJson = loadJson(likedPostFilename, 0, 1)
|
||||
if origFilename and origPostUrl:
|
||||
undoLikesCollectionEntry(recentPostsCache,
|
||||
baseDir,
|
||||
likedPostFilename,
|
||||
likeUrl,
|
||||
undoActor, domain,
|
||||
debug)
|
||||
likeUrl = announceLikeUrl
|
||||
likedPostFilename = announceLikedFilename
|
||||
baseDir, likedPostFilename,
|
||||
likeUrl, undoActor, domain, debug)
|
||||
likeUrl = origPostUrl
|
||||
likedPostFilename = origFilename
|
||||
if debug:
|
||||
print('Removing likes for ' + likedPostFilename)
|
||||
undoLikesCollectionEntry(recentPostsCache,
|
||||
|
|
21
posts.py
21
posts.py
|
@ -5043,24 +5043,25 @@ def editedPostFilename(baseDir: str, nickname: str, domain: str,
|
|||
|
||||
|
||||
def getOriginalPostFromAnnounceUrl(announceUrl: str, baseDir: str,
|
||||
nickname: str, domain: str) -> (str, str):
|
||||
"""From the url of an announce this returns the actor and url
|
||||
of the original post being announced
|
||||
nickname: str,
|
||||
domain: str) -> (str, str, str):
|
||||
"""From the url of an announce this returns the actor, url and
|
||||
filename (if available) of the original post being announced
|
||||
"""
|
||||
postFilename = locatePost(baseDir, nickname, domain, announceUrl)
|
||||
if not postFilename:
|
||||
return None, None
|
||||
return None, None, None
|
||||
announcePostJson = loadJson(postFilename, 0, 1)
|
||||
if not announcePostJson:
|
||||
return None, None
|
||||
return None, None, None
|
||||
if not announcePostJson.get('type'):
|
||||
return None, None
|
||||
return None, None, None
|
||||
if announcePostJson['type'] != 'Announce':
|
||||
return None, None
|
||||
return None, None, None
|
||||
if not announcePostJson.get('object'):
|
||||
return None, None
|
||||
return None, None, None
|
||||
if not isinstance(announcePostJson['object'], str):
|
||||
return None, None
|
||||
return None, None, None
|
||||
# do we have the original post?
|
||||
origPostId = announcePostJson['object']
|
||||
origFilename = locatePost(baseDir, nickname, domain, origPostId)
|
||||
|
@ -5088,4 +5089,4 @@ def getOriginalPostFromAnnounceUrl(announceUrl: str, baseDir: str,
|
|||
origPostId.split('/' + origNick + '/')[0] + \
|
||||
'/' + origNick
|
||||
url = origPostId
|
||||
return actor, url
|
||||
return actor, url, origFilename
|
||||
|
|
Loading…
Reference in New Issue