mirror of https://gitlab.com/bashrc2/epicyon
Check if post was deleted
parent
fbc5439eb5
commit
bdce3e1e35
7
posts.py
7
posts.py
|
|
@ -5420,9 +5420,10 @@ def _expire_posts_for_person(http_prefix: str, nickname: str, domain: str,
|
|||
if is_dm(post_json_object):
|
||||
continue
|
||||
print('DEBUG: published_str ' + published_str + ' ' + str(max_age_days))
|
||||
delete_post(base_dir, http_prefix, nickname, domain,
|
||||
full_filename, debug, recent_posts_cache, True)
|
||||
expired_post_count += 1
|
||||
debug = True
|
||||
if delete_post(base_dir, http_prefix, nickname, domain,
|
||||
full_filename, debug, recent_posts_cache, True):
|
||||
expired_post_count += 1
|
||||
|
||||
return expired_post_count
|
||||
|
||||
|
|
|
|||
18
utils.py
18
utils.py
|
|
@ -2204,8 +2204,9 @@ def _is_remote_dm(domain_full: str, post_json_object: {}) -> bool:
|
|||
def delete_post(base_dir: str, http_prefix: str,
|
||||
nickname: str, domain: str, post_filename: str,
|
||||
debug: bool, recent_posts_cache: {},
|
||||
manual: bool) -> None:
|
||||
manual: bool) -> bool:
|
||||
"""Recursively deletes a post and its replies and attachments
|
||||
Returns True if deleted
|
||||
"""
|
||||
post_json_object = load_json(post_filename)
|
||||
if not post_json_object:
|
||||
|
|
@ -2216,27 +2217,32 @@ def delete_post(base_dir: str, http_prefix: str,
|
|||
# finally, remove the post itself
|
||||
try:
|
||||
os.remove(post_filename)
|
||||
return True
|
||||
except OSError:
|
||||
if debug:
|
||||
print('EX: delete_post unable to delete post ' +
|
||||
str(post_filename))
|
||||
return
|
||||
return False
|
||||
|
||||
# don't allow DMs to be deleted if they came from a different instance
|
||||
# otherwise this breaks expectations about how DMs should operate
|
||||
# i.e. DMs should only be removed if they are manually deleted
|
||||
if not manual:
|
||||
if _is_remote_dm(domain, post_json_object):
|
||||
return
|
||||
print('DEBUG: remote DM not deleted ' + post_filename)
|
||||
return False
|
||||
|
||||
# don't allow deletion of bookmarked posts
|
||||
if _is_bookmarked(base_dir, nickname, domain, post_filename):
|
||||
return
|
||||
if debug:
|
||||
print('DEBUG: bookmarked post not deleted ' + post_filename)
|
||||
return False
|
||||
|
||||
# don't remove replies to blog posts
|
||||
if _is_reply_to_blog_post(base_dir, nickname, domain,
|
||||
post_json_object):
|
||||
return
|
||||
print('DEBUG: reply to blog post not deleted ' + post_filename)
|
||||
return False
|
||||
|
||||
# remove from recent posts cache in memory
|
||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||
|
|
@ -2294,10 +2300,12 @@ def delete_post(base_dir: str, http_prefix: str,
|
|||
# finally, remove the post itself
|
||||
try:
|
||||
os.remove(post_filename)
|
||||
return True
|
||||
except OSError:
|
||||
if debug:
|
||||
print('EX: delete_post unable to delete post ' +
|
||||
str(post_filename))
|
||||
return False
|
||||
|
||||
|
||||
def _is_valid_language(text: str) -> bool:
|
||||
|
|
|
|||
Loading…
Reference in New Issue