Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon

main
Bob Mottram 2021-05-19 22:40:32 +01:00
commit 75cb2dbbaf
6 changed files with 22 additions and 19 deletions

View File

@ -48,7 +48,8 @@ def outboxAnnounce(recentPostsCache: {},
messageJson['object']) messageJson['object'])
if postFilename: if postFilename:
updateAnnounceCollection(recentPostsCache, baseDir, postFilename, updateAnnounceCollection(recentPostsCache, baseDir, postFilename,
messageJson['actor'], domain, debug) messageJson['actor'],
nickname, domain, debug)
return True return True
elif messageJson['type'] == 'Undo': elif messageJson['type'] == 'Undo':
if not isinstance(messageJson['object'], dict): if not isinstance(messageJson['object'], dict):

View File

@ -6721,7 +6721,8 @@ class PubServer(BaseHTTPRequestHandler):
updateLikesCollection(self.server.recentPostsCache, updateLikesCollection(self.server.recentPostsCache,
baseDir, baseDir,
likedPostFilename, likeUrl, likedPostFilename, likeUrl,
likeActor, domain, likeActor,
self.postToNickname, domain,
debug) debug)
# clear the icon from the cache so that it gets updated # clear the icon from the cache so that it gets updated
if self.server.iconsCache.get('like.png'): if self.server.iconsCache.get('like.png'):

View File

@ -991,12 +991,12 @@ def _receiveLike(recentPostsCache: {},
# if this post in the outbox of the person? # if this post in the outbox of the person?
handleName = handle.split('@')[0] handleName = handle.split('@')[0]
handleDom = handle.split('@')[1] handleDom = handle.split('@')[1]
postFilename = locatePost(baseDir, handleName, handleDom, postLikedId = messageJson['object']
messageJson['object']) postFilename = locatePost(baseDir, handleName, handleDom, postLikedId)
if not postFilename: if not postFilename:
if debug: if debug:
print('DEBUG: post not found in inbox or outbox') print('DEBUG: post not found in inbox or outbox')
print(messageJson['object']) print(postLikedId)
return True return True
if debug: if debug:
print('DEBUG: liked post found in inbox') print('DEBUG: liked post found in inbox')
@ -1005,13 +1005,13 @@ def _receiveLike(recentPostsCache: {},
handleDom = handle.split('@')[1] handleDom = handle.split('@')[1]
if not _alreadyLiked(baseDir, if not _alreadyLiked(baseDir,
handleName, handleDom, handleName, handleDom,
messageJson['object'], postLikedId,
messageJson['actor']): messageJson['actor']):
_likeNotify(baseDir, domain, onionDomain, handle, _likeNotify(baseDir, domain, onionDomain, handle,
messageJson['actor'], messageJson['object']) messageJson['actor'], postLikedId)
updateLikesCollection(recentPostsCache, baseDir, postFilename, updateLikesCollection(recentPostsCache, baseDir, postFilename,
messageJson['object'], postLikedId, messageJson['actor'],
messageJson['actor'], domain, debug) handleName, domain, debug)
return True return True
@ -1398,7 +1398,7 @@ def _receiveAnnounce(recentPostsCache: {},
print(messageJson['object']) print(messageJson['object'])
return True return True
updateAnnounceCollection(recentPostsCache, baseDir, postFilename, updateAnnounceCollection(recentPostsCache, baseDir, postFilename,
messageJson['actor'], domain, debug) messageJson['actor'], nickname, domain, debug)
if debug: if debug:
print('DEBUG: Downloading announce post ' + messageJson['actor'] + print('DEBUG: Downloading announce post ' + messageJson['actor'] +
' -> ' + messageJson['object']) ' -> ' + messageJson['object'])

View File

@ -103,7 +103,8 @@ def _like(recentPostsCache: {},
updateLikesCollection(recentPostsCache, updateLikesCollection(recentPostsCache,
baseDir, postFilename, objectUrl, baseDir, postFilename, objectUrl,
newLikeJson['actor'], domain, debug) newLikeJson['actor'],
nickname, domain, debug)
sendSignedJson(newLikeJson, session, baseDir, sendSignedJson(newLikeJson, session, baseDir,
nickname, domain, port, nickname, domain, port,
@ -334,7 +335,8 @@ def outboxLike(recentPostsCache: {},
return True return True
updateLikesCollection(recentPostsCache, updateLikesCollection(recentPostsCache,
baseDir, postFilename, messageId, baseDir, postFilename, messageId,
messageJson['actor'], domain, debug) messageJson['actor'],
nickname, domain, debug)
if debug: if debug:
print('DEBUG: post liked via c2s - ' + postFilename) print('DEBUG: post liked via c2s - ' + postFilename)

View File

@ -1886,8 +1886,8 @@ def undoLikesCollectionEntry(recentPostsCache: {},
def updateLikesCollection(recentPostsCache: {}, def updateLikesCollection(recentPostsCache: {},
baseDir: str, postFilename: str, baseDir: str, postFilename: str,
objectUrl: str, objectUrl: str, actor: str,
actor: str, domain: str, debug: bool) -> None: nickname: str, domain: str, debug: bool) -> None:
"""Updates the likes collection within a post """Updates the likes collection within a post
""" """
postJsonObject = loadJson(postFilename) postJsonObject = loadJson(postFilename)
@ -1895,13 +1895,12 @@ def updateLikesCollection(recentPostsCache: {},
return return
# remove any cached version of this post so that the # remove any cached version of this post so that the
# like icon is changed # like icon is changed
nickname = getNicknameFromActor(actor) removePostFromCache(postJsonObject, recentPostsCache)
cachedPostFilename = getCachedPostFilename(baseDir, nickname, cachedPostFilename = getCachedPostFilename(baseDir, nickname,
domain, postJsonObject) domain, postJsonObject)
if cachedPostFilename: if cachedPostFilename:
if os.path.isfile(cachedPostFilename): if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename) os.remove(cachedPostFilename)
removePostFromCache(postJsonObject, recentPostsCache)
if not postJsonObject.get('object'): if not postJsonObject.get('object'):
if debug: if debug:
@ -2011,7 +2010,8 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
def updateAnnounceCollection(recentPostsCache: {}, def updateAnnounceCollection(recentPostsCache: {},
baseDir: str, postFilename: str, baseDir: str, postFilename: str,
actor: str, domain: str, debug: bool) -> None: actor: str,
nickname: str, domain: str, debug: bool) -> None:
"""Updates the announcements collection within a post """Updates the announcements collection within a post
Confusingly this is known as "shares", but isn't the Confusingly this is known as "shares", but isn't the
same as shared items within shares.py same as shared items within shares.py
@ -2022,7 +2022,6 @@ def updateAnnounceCollection(recentPostsCache: {},
return return
# remove any cached version of this announce so that the announce # remove any cached version of this announce so that the announce
# icon is changed # icon is changed
nickname = getNicknameFromActor(actor)
cachedPostFilename = getCachedPostFilename(baseDir, nickname, domain, cachedPostFilename = getCachedPostFilename(baseDir, nickname, domain,
postJsonObject) postJsonObject)
if cachedPostFilename: if cachedPostFilename:

View File

@ -1320,7 +1320,7 @@ def individualPostAsHtml(allowDownloads: bool,
if announceFilename: if announceFilename:
updateAnnounceCollection(recentPostsCache, updateAnnounceCollection(recentPostsCache,
baseDir, announceFilename, baseDir, announceFilename,
postActor, domainFull, False) postActor, nickname, domainFull, False)
# create a file for use by text-to-speech # create a file for use by text-to-speech
if isRecentPost(postJsonObject): if isRecentPost(postJsonObject):