aboutsummaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
authorLibravatar neptune 2022-12-27 08:45:07 -0300
committerLibravatar neptune 2022-12-27 08:45:07 -0300
commitb318f19b4911334d1d7c3b5196d938dd64d68d90 (patch)
tree95a11a55ae60f5170d45398365fc3fb227afb011 /cgi
parentbe1daf645af908863fbb012e889979f2ef1aed48 (diff)
downloadweabot-b318f19b4911334d1d7c3b5196d938dd64d68d90.tar.gz
weabot-b318f19b4911334d1d7c3b5196d938dd64d68d90.tar.xz
weabot-b318f19b4911334d1d7c3b5196d938dd64d68d90.zip
Arreglada lógica de RSS
Diffstat (limited to 'cgi')
-rw-r--r--cgi/post.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/cgi/post.py b/cgi/post.py
index b84b753..b7efef1 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -100,7 +100,7 @@ def threadNumReplies(post):
"""
board = Settings._.BOARD
- num = FetchOne("SELECT COUNT(1) AS 'count' FROM `posts` WHERE `parentid` = %s AND `boardid` = %s" % (post, board['id']))
+ num = FetchOne("SELECT COUNT(1) AS 'count' FROM `posts` WHERE `parentid` = %s AND `boardid` = %s", (post, board['id']))
return int(num["count"]) + 1
def get_parent_post(post_id, board_id):
@@ -112,6 +112,12 @@ def get_parent_post(post_id, board_id):
else:
raise UserError(_("The ID of the parent post is invalid."))
+def getParentTimestamp(post):
+ if post['parentid']:
+ return FetchOne("SELECT `timestamp` FROM `posts` WHERE `id` = %s AND `boardid` = %s", (post['parentid'], post['boardid']))['timestamp']
+ else:
+ return None
+
def getThread(postid=0, mobile=False, timestamp=0):
board = Settings._.BOARD
total_bytes = 0
@@ -1037,7 +1043,7 @@ def getLastAge(board_type, limit):
return threads
def getNewPosts(limit, rss=False):
- sql = "SELECT posts.id, boards.name AS board_fulln, board_type, boards.dir, timestamp, posts.message FROM posts INNER JOIN boards ON posts.boardid = boards.id WHERE IS_DELETED = 0 AND boards.secret = 0 ORDER BY timestamp DESC LIMIT %s"
+ sql = "SELECT posts.id, parentid, boardid, boards.name AS board_fulln, board_type, boards.dir, timestamp, posts.message FROM posts INNER JOIN boards ON posts.boardid = boards.id WHERE IS_DELETED = 0 AND boards.secret = 0 ORDER BY timestamp DESC LIMIT %s"
posts = FetchAll(sql, (limit,))
for post in posts:
@@ -1047,9 +1053,9 @@ def getNewPosts(limit, rss=False):
post['timestamp_formatted'] = datetime.datetime.fromtimestamp(post['timestamp']).strftime('%Y-%m-%dT%H:%M:%S%Z')
if post['board_type'] == 1:
- post['url'] = '/%s/read/%d/l10' % (post['dir'], post['timestamp'])
+ post['url'] = '/%s/read/%d/l10' % (post['dir'], getParentTimestamp(post) or post['timestamp'])
else:
- post['url'] = '/%s/res/%d.html' % (post['dir'], post['id'])
+ post['url'] = '/%s/res/%d.html#%d' % (post['dir'], post['parentid'] or post['id'], post['id'])
return posts