Handle first and last post on votes

main
Bob Mottram 2023-01-08 10:51:27 +00:00
parent 7aec0daf66
commit 8bbd7b1383
1 changed files with 34 additions and 3 deletions

View File

@ -4851,6 +4851,36 @@ class PubServer(BaseHTTPRequestHandler):
curr_session, proxy_type: str) -> None: curr_session, proxy_type: str) -> None:
"""Receive a vote via POST """Receive a vote via POST
""" """
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
path = path.split('?firstpost=')[0]
if ';firstpost=' in path:
first_post_id = path.split(';firstpost=')[1]
path = path.split(';firstpost=')[0]
if first_post_id:
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
if ';' in first_post_id:
first_post_id = first_post_id.split(';')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
last_post_id = ''
if '?lastpost=' in path:
last_post_id = path.split('?lastpost=')[1]
path = path.split('?lastpost=')[0]
if ';lastpost=' in path:
last_post_id = path.split(';lastpost=')[1]
path = path.split(';lastpost=')[0]
if last_post_id:
if '?' in last_post_id:
last_post_id = last_post_id.split('?')[0]
if ';' in last_post_id:
last_post_id = last_post_id.split(';')[0]
last_post_id = last_post_id.replace('/', '--')
last_post_id = ';lastpost=' + last_post_id.replace('#', '--')
page_number = 1 page_number = 1
if '?page=' in path: if '?page=' in path:
page_number_str = path.split('?page=')[1] page_number_str = path.split('?page=')[1]
@ -4860,7 +4890,6 @@ class PubServer(BaseHTTPRequestHandler):
page_number_str = "1" page_number_str = "1"
if page_number_str.isdigit(): if page_number_str.isdigit():
page_number = int(page_number_str) page_number = int(page_number_str)
path = path.split('?page=')[0]
# the actor who votes # the actor who votes
users_path = path.replace('/question', '') users_path = path.replace('/question', '')
@ -4926,7 +4955,7 @@ class PubServer(BaseHTTPRequestHandler):
actor = 'http://' + i2p_domain + users_path actor = 'http://' + i2p_domain + users_path
actor_path_str = \ actor_path_str = \
actor + '/' + self.server.default_timeline + \ actor + '/' + self.server.default_timeline + \
'?page=' + str(page_number) '?page=' + str(page_number) + first_post_id + last_post_id
self._redirect_headers(actor_path_str, cookie, self._redirect_headers(actor_path_str, cookie,
calling_domain) calling_domain)
self.server.postreq_busy = False self.server.postreq_busy = False
@ -21998,7 +22027,9 @@ class PubServer(BaseHTTPRequestHandler):
else: else:
# a vote/question/poll is posted # a vote/question/poll is posted
if self.path.endswith('/question') or \ if self.path.endswith('/question') or \
'/question?page=' in self.path: '/question?page=' in self.path or \
'/question?firstpost=' in self.path or \
'/question?lastpost=' in self.path:
self._receive_vote(calling_domain, cookie, self._receive_vote(calling_domain, cookie,
self.path, self.path,
self.server.http_prefix, self.server.http_prefix,