aboutsummaryrefslogtreecommitdiff
path: root/cgi/post.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/post.py')
-rw-r--r--cgi/post.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/cgi/post.py b/cgi/post.py
index e9fe083..3b836bb 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -726,10 +726,18 @@ def deletePost(postid, password, deltype='0', imageonly=False, quick=False):
# Hard delete
if post["file"]:
deleteFile(post)
-
+
+ if post['parentid'] != '0':
+ numreplies = threadNumReplies(post["parentid"])
+ if numreplies > 2:
+ newlast = FetchOne('SELECT timestamp, email FROM posts WHERE boardid = %s AND parentid = %s AND timestamp < %d ORDER BY timestamp DESC LIMIT 1' % (board['id'], post['parentid'], int(post['timestamp'])))
+ else:
+ newlast = FetchOne('SELECT timestamp FROM posts WHERE boardid = %s AND id = %s LIMIT 1' % (board['id'], post['parentid']))
+
UpdateDb("DELETE FROM `posts` WHERE `boardid` = %s AND `id` = %s LIMIT 1" % (board["id"], post["id"]))
+
if post['parentid'] != '0':
- UpdateDb("UPDATE `posts` SET length = %d WHERE `id` = '%s' AND `boardid` = '%s'" % (threadNumReplies(post["parentid"]), post["parentid"], board["id"]))
+ UpdateDb("UPDATE `posts` SET last = %s, length = %d WHERE `id` = '%s' AND `boardid` = '%s'" % (newlast["timestamp"], threadNumReplies(post["parentid"]), post["parentid"], board["id"]))
if post['parentid'] == '0':
if board['board_type'] == '1':