mirror of https://gitlab.com/bashrc2/epicyon
Simplify conditions
parent
85c75878e8
commit
c02afc7880
219
daemon.py
219
daemon.py
|
@ -2154,6 +2154,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if pageNumberStr.isdigit():
|
if pageNumberStr.isdigit():
|
||||||
pageNumber = int(pageNumberStr)
|
pageNumber = int(pageNumberStr)
|
||||||
path = path.split('?page=')[0]
|
path = path.split('?page=')[0]
|
||||||
|
|
||||||
# the actor who votes
|
# the actor who votes
|
||||||
usersPath = path.replace('/question', '')
|
usersPath = path.replace('/question', '')
|
||||||
actor = httpPrefix + '://' + domainFull + usersPath
|
actor = httpPrefix + '://' + domainFull + usersPath
|
||||||
|
@ -2169,8 +2170,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
cookie, callingDomain)
|
cookie, callingDomain)
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
# get the parameters
|
# get the parameters
|
||||||
length = int(self.headers['Content-length'])
|
length = int(self.headers['Content-length'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
questionParams = self.rfile.read(length).decode('utf-8')
|
questionParams = self.rfile.read(length).decode('utf-8')
|
||||||
except SocketError as e:
|
except SocketError as e:
|
||||||
|
@ -2189,21 +2192,25 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
questionParams = questionParams.replace('+', ' ')
|
questionParams = questionParams.replace('+', ' ')
|
||||||
questionParams = questionParams.replace('%3F', '')
|
questionParams = questionParams.replace('%3F', '')
|
||||||
questionParams = \
|
questionParams = \
|
||||||
urllib.parse.unquote_plus(questionParams.strip())
|
urllib.parse.unquote_plus(questionParams.strip())
|
||||||
|
|
||||||
# post being voted on
|
# post being voted on
|
||||||
messageId = None
|
messageId = None
|
||||||
if 'messageId=' in questionParams:
|
if 'messageId=' in questionParams:
|
||||||
messageId = questionParams.split('messageId=')[1]
|
messageId = questionParams.split('messageId=')[1]
|
||||||
if '&' in messageId:
|
if '&' in messageId:
|
||||||
messageId = messageId.split('&')[0]
|
messageId = messageId.split('&')[0]
|
||||||
|
|
||||||
answer = None
|
answer = None
|
||||||
if 'answer=' in questionParams:
|
if 'answer=' in questionParams:
|
||||||
answer = questionParams.split('answer=')[1]
|
answer = questionParams.split('answer=')[1]
|
||||||
if '&' in answer:
|
if '&' in answer:
|
||||||
answer = answer.split('&')[0]
|
answer = answer.split('&')[0]
|
||||||
|
|
||||||
self._sendReplyToQuestion(nickname, messageId, answer)
|
self._sendReplyToQuestion(nickname, messageId, answer)
|
||||||
if callingDomain.endswith('.onion') and onionDomain:
|
if callingDomain.endswith('.onion') and onionDomain:
|
||||||
actor = 'http://' + onionDomain + usersPath
|
actor = 'http://' + onionDomain + usersPath
|
||||||
|
@ -8891,21 +8898,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 5)
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 5)
|
||||||
|
|
||||||
# a vote/question/poll is posted
|
|
||||||
if (authorized and
|
|
||||||
(self.path.endswith('/question') or
|
|
||||||
'/question?page=' in self.path)):
|
|
||||||
self._receiveVote(callingDomain, cookie,
|
|
||||||
authorized, self.path,
|
|
||||||
self.server.baseDir,
|
|
||||||
self.server.httpPrefix,
|
|
||||||
self.server.domain,
|
|
||||||
self.server.domainFull,
|
|
||||||
self.server.onionDomain,
|
|
||||||
self.server.i2pDomain,
|
|
||||||
self.server.debug)
|
|
||||||
return
|
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 6)
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 6)
|
||||||
|
|
||||||
# a search was made
|
# a search was made
|
||||||
|
@ -9143,111 +9135,134 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 7)
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 7)
|
||||||
|
|
||||||
# removes a shared item
|
if authorized:
|
||||||
if authorized and self.path.endswith('/rmshare'):
|
# a vote/question/poll is posted
|
||||||
self._removeShare(callingDomain, cookie,
|
if self.path.endswith('/question') or \
|
||||||
authorized, self.path,
|
'/question?page=' in self.path:
|
||||||
self.server.baseDir,
|
self._receiveVote(callingDomain, cookie,
|
||||||
self.server.httpPrefix,
|
|
||||||
self.server.domain,
|
|
||||||
self.server.domainFull,
|
|
||||||
self.server.onionDomain,
|
|
||||||
self.server.i2pDomain,
|
|
||||||
self.server.debug)
|
|
||||||
return
|
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 8)
|
|
||||||
|
|
||||||
# removes a post
|
|
||||||
if not authorized and self.path.endswith('/rmpost'):
|
|
||||||
print('ERROR: attempt to remove post was not authorized. ' +
|
|
||||||
self.path)
|
|
||||||
self._400()
|
|
||||||
self.server.POSTbusy = False
|
|
||||||
return
|
|
||||||
if authorized and self.path.endswith('/rmpost'):
|
|
||||||
self._removePost(callingDomain, cookie,
|
|
||||||
authorized, self.path,
|
|
||||||
self.server.baseDir, self.server.httpPrefix,
|
|
||||||
self.server.domain, self.server.domainFull,
|
|
||||||
self.server.onionDomain,
|
|
||||||
self.server.i2pDomain,
|
|
||||||
self.server.debug)
|
|
||||||
return
|
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 9)
|
|
||||||
|
|
||||||
# decision to follow in the web interface is confirmed
|
|
||||||
if authorized and self.path.endswith('/followconfirm'):
|
|
||||||
self._followConfirm(callingDomain, cookie,
|
|
||||||
authorized, self.path,
|
|
||||||
self.server.baseDir,
|
|
||||||
self.server.httpPrefix,
|
|
||||||
self.server.domain,
|
|
||||||
self.server.domainFull,
|
|
||||||
self.server.port,
|
|
||||||
self.server.onionDomain,
|
|
||||||
self.server.i2pDomain,
|
|
||||||
self.server.debug)
|
|
||||||
return
|
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 10)
|
|
||||||
|
|
||||||
# decision to unfollow in the web interface is confirmed
|
|
||||||
if authorized and self.path.endswith('/unfollowconfirm'):
|
|
||||||
self._unfollowConfirm(callingDomain, cookie,
|
|
||||||
authorized, self.path,
|
authorized, self.path,
|
||||||
self.server.baseDir,
|
self.server.baseDir,
|
||||||
self.server.httpPrefix,
|
self.server.httpPrefix,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
self.server.domainFull,
|
self.server.domainFull,
|
||||||
self.server.port,
|
|
||||||
self.server.onionDomain,
|
self.server.onionDomain,
|
||||||
self.server.i2pDomain,
|
self.server.i2pDomain,
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
return
|
return
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 11)
|
# removes a shared item
|
||||||
|
if self.path.endswith('/rmshare'):
|
||||||
|
self._removeShare(callingDomain, cookie,
|
||||||
|
authorized, self.path,
|
||||||
|
self.server.baseDir,
|
||||||
|
self.server.httpPrefix,
|
||||||
|
self.server.domain,
|
||||||
|
self.server.domainFull,
|
||||||
|
self.server.onionDomain,
|
||||||
|
self.server.i2pDomain,
|
||||||
|
self.server.debug)
|
||||||
|
return
|
||||||
|
|
||||||
# decision to unblock in the web interface is confirmed
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 8)
|
||||||
if authorized and self.path.endswith('/unblockconfirm'):
|
|
||||||
self._unblockConfirm(callingDomain, cookie,
|
# removes a post
|
||||||
|
if self.path.endswith('/rmpost'):
|
||||||
|
print('ERROR: attempt to remove post was not authorized. ' +
|
||||||
|
self.path)
|
||||||
|
self._400()
|
||||||
|
self.server.POSTbusy = False
|
||||||
|
return
|
||||||
|
if self.path.endswith('/rmpost'):
|
||||||
|
self._removePost(callingDomain, cookie,
|
||||||
authorized, self.path,
|
authorized, self.path,
|
||||||
self.server.baseDir, self.server.httpPrefix,
|
self.server.baseDir,
|
||||||
self.server.domain, self.server.domainFull,
|
self.server.httpPrefix,
|
||||||
self.server.port,
|
self.server.domain,
|
||||||
|
self.server.domainFull,
|
||||||
self.server.onionDomain,
|
self.server.onionDomain,
|
||||||
self.server.i2pDomain,
|
self.server.i2pDomain,
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
return
|
return
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 12)
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 9)
|
||||||
|
|
||||||
# decision to block in the web interface is confirmed
|
# decision to follow in the web interface is confirmed
|
||||||
if authorized and self.path.endswith('/blockconfirm'):
|
if self.path.endswith('/followconfirm'):
|
||||||
self._blockConfirm(callingDomain, cookie,
|
self._followConfirm(callingDomain, cookie,
|
||||||
authorized, self.path,
|
authorized, self.path,
|
||||||
self.server.baseDir, self.server.httpPrefix,
|
self.server.baseDir,
|
||||||
self.server.domain, self.server.domainFull,
|
self.server.httpPrefix,
|
||||||
self.server.port,
|
self.server.domain,
|
||||||
self.server.onionDomain,
|
self.server.domainFull,
|
||||||
self.server.i2pDomain,
|
self.server.port,
|
||||||
self.server.debug)
|
self.server.onionDomain,
|
||||||
return
|
self.server.i2pDomain,
|
||||||
|
self.server.debug)
|
||||||
|
return
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 13)
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 10)
|
||||||
|
|
||||||
# an option was chosen from person options screen
|
# decision to unfollow in the web interface is confirmed
|
||||||
# view/follow/block/report
|
if self.path.endswith('/unfollowconfirm'):
|
||||||
if authorized and self.path.endswith('/personoptions'):
|
self._unfollowConfirm(callingDomain, cookie,
|
||||||
self._personOptions(self, self.path, callingDomain, cookie,
|
authorized, self.path,
|
||||||
self.server.baseDir, self.server.httpPrefix,
|
self.server.baseDir,
|
||||||
self.server.domain, self.server.domainFull,
|
self.server.httpPrefix,
|
||||||
self.server.port,
|
self.server.domain,
|
||||||
self.server.onionDomain,
|
self.server.domainFull,
|
||||||
self.server.i2pDomain,
|
self.server.port,
|
||||||
self.server.debug)
|
self.server.onionDomain,
|
||||||
return
|
self.server.i2pDomain,
|
||||||
|
self.server.debug)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 11)
|
||||||
|
|
||||||
|
# decision to unblock in the web interface is confirmed
|
||||||
|
if self.path.endswith('/unblockconfirm'):
|
||||||
|
self._unblockConfirm(callingDomain, cookie,
|
||||||
|
authorized, self.path,
|
||||||
|
self.server.baseDir,
|
||||||
|
self.server.httpPrefix,
|
||||||
|
self.server.domain,
|
||||||
|
self.server.domainFull,
|
||||||
|
self.server.port,
|
||||||
|
self.server.onionDomain,
|
||||||
|
self.server.i2pDomain,
|
||||||
|
self.server.debug)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 12)
|
||||||
|
|
||||||
|
# decision to block in the web interface is confirmed
|
||||||
|
if self.path.endswith('/blockconfirm'):
|
||||||
|
self._blockConfirm(callingDomain, cookie,
|
||||||
|
authorized, self.path,
|
||||||
|
self.server.baseDir,
|
||||||
|
self.server.httpPrefix,
|
||||||
|
self.server.domain,
|
||||||
|
self.server.domainFull,
|
||||||
|
self.server.port,
|
||||||
|
self.server.onionDomain,
|
||||||
|
self.server.i2pDomain,
|
||||||
|
self.server.debug)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 13)
|
||||||
|
|
||||||
|
# an option was chosen from person options screen
|
||||||
|
# view/follow/block/report
|
||||||
|
if self.path.endswith('/personoptions'):
|
||||||
|
self._personOptions(self, self.path, callingDomain, cookie,
|
||||||
|
self.server.baseDir,
|
||||||
|
self.server.httpPrefix,
|
||||||
|
self.server.domain,
|
||||||
|
self.server.domainFull,
|
||||||
|
self.server.port,
|
||||||
|
self.server.onionDomain,
|
||||||
|
self.server.i2pDomain,
|
||||||
|
self.server.debug)
|
||||||
|
return
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 14)
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 14)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue