forked from indymedia/epicyon
Remove bookmark from index first
parent
a87072e130
commit
949f52ae9b
44
bookmarks.py
44
bookmarks.py
|
@ -42,6 +42,28 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
|
# remove from the index
|
||||||
|
bookmarksIndexFilename = baseDir + '/accounts/' + \
|
||||||
|
nickname + '@' + domain + '/bookmarks.index'
|
||||||
|
if not os.path.isfile(bookmarksIndexFilename):
|
||||||
|
return
|
||||||
|
if '/' in postFilename:
|
||||||
|
bookmarkIndex = postFilename.split('/')[-1].strip()
|
||||||
|
else:
|
||||||
|
bookmarkIndex = postFilename.strip()
|
||||||
|
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
||||||
|
return
|
||||||
|
indexStr = ''
|
||||||
|
indexStrChanged = False
|
||||||
|
with open(bookmarksIndexFilename, 'r') as indexFile:
|
||||||
|
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
||||||
|
indexStrChanged = True
|
||||||
|
if indexStrChanged:
|
||||||
|
bookmarksIndexFile = open(bookmarksIndexFilename, 'w')
|
||||||
|
if bookmarksIndexFile:
|
||||||
|
bookmarksIndexFile.write(indexStr)
|
||||||
|
bookmarksIndexFile.close()
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
return
|
return
|
||||||
if postJsonObject['type'] != 'Create':
|
if postJsonObject['type'] != 'Create':
|
||||||
|
@ -85,28 +107,6 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
postJsonObject['object']['bookmarks']['totalItems'] = bmItLen
|
postJsonObject['object']['bookmarks']['totalItems'] = bmItLen
|
||||||
saveJson(postJsonObject, postFilename)
|
saveJson(postJsonObject, postFilename)
|
||||||
|
|
||||||
# remove from the index
|
|
||||||
bookmarksIndexFilename = baseDir + '/accounts/' + \
|
|
||||||
nickname + '@' + domain + '/bookmarks.index'
|
|
||||||
if not os.path.isfile(bookmarksIndexFilename):
|
|
||||||
return
|
|
||||||
if '/' in postFilename:
|
|
||||||
bookmarkIndex = postFilename.split('/')[-1].strip()
|
|
||||||
else:
|
|
||||||
bookmarkIndex = postFilename.strip()
|
|
||||||
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
|
||||||
return
|
|
||||||
indexStr = ''
|
|
||||||
indexStrChanged = False
|
|
||||||
with open(bookmarksIndexFilename, 'r') as indexFile:
|
|
||||||
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
|
||||||
indexStrChanged = True
|
|
||||||
if indexStrChanged:
|
|
||||||
bookmarksIndexFile = open(bookmarksIndexFilename, 'w')
|
|
||||||
if bookmarksIndexFile:
|
|
||||||
bookmarksIndexFile.write(indexStr)
|
|
||||||
bookmarksIndexFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def bookmarkedByPerson(postJsonObject: {}, nickname: str, domain: str) -> bool:
|
def bookmarkedByPerson(postJsonObject: {}, nickname: str, domain: str) -> bool:
|
||||||
"""Returns True if the given post is bookmarked by the given person
|
"""Returns True if the given post is bookmarked by the given person
|
||||||
|
|
Loading…
Reference in New Issue