delete redis cache on post deletion/removal/undeletion/unremoval

pull/173/head
Aevann 2023-07-29 01:45:45 +03:00
parent c415430888
commit 0a9b19bb15
2 changed files with 13 additions and 0 deletions

View File

@ -1352,6 +1352,10 @@ def remove_post(post_id, v):
v.pay_account('coins', 1)
g.db.add(v)
for sort in COMMENT_SORTS:
cache.delete(f'post_{post.id}_{sort}')
return {"message": "Post removed!"}
@ -1386,6 +1390,9 @@ def approve_post(post_id, v):
v.charge_account('coins', 1)
g.db.add(v)
for sort in COMMENT_SORTS:
cache.delete(f'post_{post.id}_{sort}')
return {"message": "Post approved!"}

View File

@ -777,6 +777,9 @@ def delete_post_pid(pid, v):
v.post_count = g.db.query(Post).filter_by(author_id=v.id, deleted_utc=0).count()
g.db.add(v)
for sort in COMMENT_SORTS:
cache.delete(f'post_{p.id}_{sort}')
return {"message": "Post deleted!"}
@app.post("/undelete_post/<int:pid>")
@ -799,6 +802,9 @@ def undelete_post_pid(pid, v):
v.post_count = g.db.query(Post).filter_by(author_id=v.id, deleted_utc=0).count()
g.db.add(v)
for sort in COMMENT_SORTS:
cache.delete(f'post_{p.id}_{sort}')
return {"message": "Post undeleted!"}