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

main
Bob Mottram 2020-09-24 23:44:32 +01:00
commit 5bd95384dd
1 changed files with 25 additions and 47 deletions

View File

@ -54,15 +54,11 @@ def removeShare(baseDir: str, nickname: str, domain: str,
# remove any image for the item
itemIDfile = baseDir + '/sharefiles/' + nickname + '/' + itemID
if sharesJson[itemID]['imageUrl']:
if sharesJson[itemID]['imageUrl'].endswith('.png'):
if os.path.isfile(itemIDfile + '.png'):
os.remove(itemIDfile + '.png')
if sharesJson[itemID]['imageUrl'].endswith('.jpg'):
if os.path.isfile(itemIDfile + '.jpg'):
os.remove(itemIDfile + '.jpg')
if sharesJson[itemID]['imageUrl'].endswith('.gif'):
if os.path.isfile(itemIDfile + '.gif'):
os.remove(itemIDfile + '.gif')
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
for ext in formats:
if sharesJson[itemID]['imageUrl'].endswith('.' + ext):
if os.path.isfile(itemIDfile + '.' + ext):
os.remove(itemIDfile + '.' + ext)
# remove the item itself
del sharesJson[itemID]
saveJson(sharesJson, sharesFilename)
@ -76,7 +72,7 @@ def addShare(baseDir: str,
displayName: str, summary: str, imageFilename: str,
itemType: str, itemCategory: str, location: str,
duration: str, debug: bool) -> None:
"""Updates the likes collection within a post
"""Adds a new share
"""
sharesFilename = baseDir + '/accounts/' + \
nickname + '@' + domain + '/shares.json'
@ -112,15 +108,11 @@ def addShare(baseDir: str,
if not imageFilename:
sharesImageFilename = \
baseDir + '/accounts/' + nickname + '@' + domain + '/upload'
if os.path.isfile(sharesImageFilename + '.png'):
imageFilename = sharesImageFilename + '.png'
moveImage = True
elif os.path.isfile(sharesImageFilename + '.jpg'):
imageFilename = sharesImageFilename + '.jpg'
moveImage = True
elif os.path.isfile(sharesImageFilename + '.gif'):
imageFilename = sharesImageFilename + '.gif'
moveImage = True
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
for ext in formats:
if os.path.isfile(sharesImageFilename + '.' + ext):
imageFilename = sharesImageFilename + '.' + ext
moveImage = True
domainFull = domain
if port:
@ -136,27 +128,15 @@ def addShare(baseDir: str,
if not os.path.isdir(baseDir + '/sharefiles/' + nickname):
os.mkdir(baseDir + '/sharefiles/' + nickname)
itemIDfile = baseDir + '/sharefiles/' + nickname + '/' + itemID
if imageFilename.endswith('.png'):
removeMetaData(imageFilename, itemIDfile + '.png')
if moveImage:
os.remove(imageFilename)
imageUrl = \
httpPrefix + '://' + domainFull + \
'/sharefiles/' + nickname + '/' + itemID + '.png'
if imageFilename.endswith('.jpg'):
removeMetaData(imageFilename, itemIDfile + '.jpg')
if moveImage:
os.remove(imageFilename)
imageUrl = \
httpPrefix + '://' + domainFull + \
'/sharefiles/' + nickname + '/' + itemID + '.jpg'
if imageFilename.endswith('.gif'):
removeMetaData(imageFilename, itemIDfile + '.gif')
if moveImage:
os.remove(imageFilename)
imageUrl = \
httpPrefix + '://' + domainFull + \
'/sharefiles/' + nickname + '/' + itemID + '.gif'
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
for ext in formats:
if imageFilename.endswith('.' + ext):
removeMetaData(imageFilename, itemIDfile + '.' + ext)
if moveImage:
os.remove(imageFilename)
imageUrl = \
httpPrefix + '://' + domainFull + \
'/sharefiles/' + nickname + '/' + itemID + '.' + ext
sharesJson[itemID] = {
"displayName": displayName,
@ -201,7 +181,7 @@ def expireShares(baseDir: str) -> None:
def expireSharesForAccount(baseDir: str, nickname: str, domain: str) -> None:
"""Removes expired items from shares
"""Removes expired items from shares for a particular account
"""
handleDomain = domain
if ':' in handleDomain:
@ -222,12 +202,10 @@ def expireSharesForAccount(baseDir: str, nickname: str, domain: str) -> None:
# remove any associated images
itemIDfile = \
baseDir + '/sharefiles/' + nickname + '/' + itemID
if os.path.isfile(itemIDfile + '.png'):
os.remove(itemIDfile + '.png')
if os.path.isfile(itemIDfile + '.jpg'):
os.remove(itemIDfile + '.jpg')
if os.path.isfile(itemIDfile + '.gif'):
os.remove(itemIDfile + '.gif')
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
for ext in formats:
if os.path.isfile(itemIDfile + '.' + ext):
os.remove(itemIDfile + '.' + ext)
saveJson(sharesJson, sharesFilename)