mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon
commit
328984bb98
|
|
@ -995,11 +995,8 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
if os.path.isfile(possibleOtherFormat):
|
if os.path.isfile(possibleOtherFormat):
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
|
|
||||||
fd = open(filename, 'wb')
|
with open(filename, 'wb') as fp:
|
||||||
if not fd:
|
fp.write(mediaBytes[startPos:])
|
||||||
return None, None
|
|
||||||
fd.write(mediaBytes[startPos:])
|
|
||||||
fd.close()
|
|
||||||
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
print('WARN: Media file could not be written to file: ' + filename)
|
print('WARN: Media file could not be written to file: ' + filename)
|
||||||
|
|
|
||||||
4
posts.py
4
posts.py
|
|
@ -1348,11 +1348,9 @@ def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
||||||
pinnedPostJson = {}
|
pinnedPostJson = {}
|
||||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||||
if os.path.isfile(pinnedFilename):
|
if os.path.isfile(pinnedFilename):
|
||||||
pinFile = open(pinnedFilename, "r")
|
|
||||||
pinnedContent = None
|
pinnedContent = None
|
||||||
if pinFile:
|
with open(pinnedFilename, "r") as pinFile:
|
||||||
pinnedContent = pinFile.read()
|
pinnedContent = pinFile.read()
|
||||||
pinFile.close()
|
|
||||||
if pinnedContent:
|
if pinnedContent:
|
||||||
pinnedPostJson = {
|
pinnedPostJson = {
|
||||||
'atomUri': actor + '/pinned',
|
'atomUri': actor + '/pinned',
|
||||||
|
|
|
||||||
19
utils.py
19
utils.py
|
|
@ -1517,11 +1517,7 @@ def noOfAccounts(baseDir: str) -> bool:
|
||||||
accountCtr = 0
|
accountCtr = 0
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for account in dirs:
|
for account in dirs:
|
||||||
if '@' in account:
|
if isAccountDir(account):
|
||||||
if account.startswith('inbox@'):
|
|
||||||
continue
|
|
||||||
elif account.startswith('news@'):
|
|
||||||
continue
|
|
||||||
accountCtr += 1
|
accountCtr += 1
|
||||||
break
|
break
|
||||||
return accountCtr
|
return accountCtr
|
||||||
|
|
@ -1804,6 +1800,7 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
containing matching strings
|
containing matching strings
|
||||||
"""
|
"""
|
||||||
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
||||||
|
# is this a virtual box, such as direct messages?
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
if os.path.isfile(path + '.index'):
|
if os.path.isfile(path + '.index'):
|
||||||
return _searchVirtualBoxPosts(baseDir, nickname, domain,
|
return _searchVirtualBoxPosts(baseDir, nickname, domain,
|
||||||
|
|
@ -1858,7 +1855,8 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
||||||
"""Undoes a like for a particular actor
|
"""Undoes a like for a particular actor
|
||||||
"""
|
"""
|
||||||
postJsonObject = loadJson(postFilename)
|
postJsonObject = loadJson(postFilename)
|
||||||
if postJsonObject:
|
if not postJsonObject:
|
||||||
|
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)
|
nickname = getNicknameFromActor(actor)
|
||||||
|
|
@ -1896,7 +1894,8 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
||||||
postJsonObject['object']['likes']['items'].remove(likeItem)
|
postJsonObject['object']['likes']['items'].remove(likeItem)
|
||||||
itemFound = True
|
itemFound = True
|
||||||
break
|
break
|
||||||
if itemFound:
|
if not itemFound:
|
||||||
|
return
|
||||||
if totalItems == 1:
|
if totalItems == 1:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: likes was removed from post')
|
print('DEBUG: likes was removed from post')
|
||||||
|
|
@ -1978,7 +1977,8 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
|
||||||
shares of posts, not shares of physical objects.
|
shares of posts, not shares of physical objects.
|
||||||
"""
|
"""
|
||||||
postJsonObject = loadJson(postFilename)
|
postJsonObject = loadJson(postFilename)
|
||||||
if postJsonObject:
|
if not postJsonObject:
|
||||||
|
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)
|
nickname = getNicknameFromActor(actor)
|
||||||
|
|
@ -2015,7 +2015,8 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
|
||||||
postJsonObject['object']['shares']['items'].remove(anIt)
|
postJsonObject['object']['shares']['items'].remove(anIt)
|
||||||
itemFound = True
|
itemFound = True
|
||||||
break
|
break
|
||||||
if itemFound:
|
if not itemFound:
|
||||||
|
return
|
||||||
if totalItems == 1:
|
if totalItems == 1:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: shares (announcements) ' +
|
print('DEBUG: shares (announcements) ' +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue