mirror of https://gitlab.com/bashrc2/epicyon
Less indentation
parent
cd14cc2775
commit
e8d45565b4
92
utils.py
92
utils.py
|
@ -1977,54 +1977,56 @@ 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:
|
||||||
# remove any cached version of this announce so that the announce
|
return
|
||||||
# icon is changed
|
# remove any cached version of this announce so that the announce
|
||||||
nickname = getNicknameFromActor(actor)
|
# icon is changed
|
||||||
cachedPostFilename = getCachedPostFilename(baseDir, nickname, domain,
|
nickname = getNicknameFromActor(actor)
|
||||||
postJsonObject)
|
cachedPostFilename = getCachedPostFilename(baseDir, nickname, domain,
|
||||||
if cachedPostFilename:
|
postJsonObject)
|
||||||
if os.path.isfile(cachedPostFilename):
|
if cachedPostFilename:
|
||||||
os.remove(cachedPostFilename)
|
if os.path.isfile(cachedPostFilename):
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
os.remove(cachedPostFilename)
|
||||||
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
return
|
return
|
||||||
if postJsonObject['type'] != 'Create':
|
if postJsonObject['type'] != 'Create':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
if debug:
|
if debug:
|
||||||
pprint(postJsonObject)
|
pprint(postJsonObject)
|
||||||
print('DEBUG: post has no object')
|
print('DEBUG: post has no object')
|
||||||
return
|
return
|
||||||
if not postJsonObject['object'].get('shares'):
|
if not postJsonObject['object'].get('shares'):
|
||||||
return
|
return
|
||||||
if not postJsonObject['object']['shares'].get('items'):
|
if not postJsonObject['object']['shares'].get('items'):
|
||||||
return
|
return
|
||||||
totalItems = 0
|
totalItems = 0
|
||||||
if postJsonObject['object']['shares'].get('totalItems'):
|
if postJsonObject['object']['shares'].get('totalItems'):
|
||||||
totalItems = postJsonObject['object']['shares']['totalItems']
|
totalItems = postJsonObject['object']['shares']['totalItems']
|
||||||
itemFound = False
|
itemFound = False
|
||||||
for announceItem in postJsonObject['object']['shares']['items']:
|
for announceItem in postJsonObject['object']['shares']['items']:
|
||||||
if announceItem.get('actor'):
|
if announceItem.get('actor'):
|
||||||
if announceItem['actor'] == actor:
|
if announceItem['actor'] == actor:
|
||||||
if debug:
|
|
||||||
print('DEBUG: Announce was removed for ' + actor)
|
|
||||||
anIt = announceItem
|
|
||||||
postJsonObject['object']['shares']['items'].remove(anIt)
|
|
||||||
itemFound = True
|
|
||||||
break
|
|
||||||
if itemFound:
|
|
||||||
if totalItems == 1:
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: shares (announcements) ' +
|
print('DEBUG: Announce was removed for ' + actor)
|
||||||
'was removed from post')
|
anIt = announceItem
|
||||||
del postJsonObject['object']['shares']
|
postJsonObject['object']['shares']['items'].remove(anIt)
|
||||||
else:
|
itemFound = True
|
||||||
itlen = len(postJsonObject['object']['shares']['items'])
|
break
|
||||||
postJsonObject['object']['shares']['totalItems'] = itlen
|
if not itemFound:
|
||||||
|
return
|
||||||
|
if totalItems == 1:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: shares (announcements) ' +
|
||||||
|
'was removed from post')
|
||||||
|
del postJsonObject['object']['shares']
|
||||||
|
else:
|
||||||
|
itlen = len(postJsonObject['object']['shares']['items'])
|
||||||
|
postJsonObject['object']['shares']['totalItems'] = itlen
|
||||||
|
|
||||||
saveJson(postJsonObject, postFilename)
|
saveJson(postJsonObject, postFilename)
|
||||||
|
|
||||||
|
|
||||||
def updateAnnounceCollection(recentPostsCache: {},
|
def updateAnnounceCollection(recentPostsCache: {},
|
||||||
|
|
Loading…
Reference in New Issue