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