mirror of https://gitlab.com/bashrc2/epicyon
Keep track of votes
parent
4ed9020883
commit
71fb0285b3
12
daemon.py
12
daemon.py
|
@ -4235,6 +4235,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
answer=questionParams.split('answer=')[1]
|
||||
if '&' in answer:
|
||||
answer=answer.split('&')[0]
|
||||
votesFilename=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'/votes.txt'
|
||||
# have we already voted on this?
|
||||
if messageId in open(votesFilename).read():
|
||||
print('Already voted on message '+messageId)
|
||||
self._redirect_headers(actor+'/inbox?page='+str(pageNumber),cookie)
|
||||
self.server.POSTbusy=False
|
||||
return
|
||||
print('Voting on message '+messageId)
|
||||
print('Vote for: '+answer)
|
||||
messageJson= \
|
||||
|
@ -4255,6 +4262,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
messageJson, \
|
||||
self.server.maxReplies, \
|
||||
self.server.debug)
|
||||
# record the vote
|
||||
votesFile=open(votesFilename,'a+')
|
||||
if votesFile:
|
||||
votesFile.write(messageId+'\n')
|
||||
votesFile.close()
|
||||
else:
|
||||
print('ERROR: unable to post vote to outbox')
|
||||
else:
|
||||
|
|
|
@ -1765,12 +1765,15 @@ def insertQuestion(translate: {}, \
|
|||
return content
|
||||
if len(postJsonObject['object']['oneOf'])==0:
|
||||
return content
|
||||
messageId=postJsonObject['id'].replace('/activity','')
|
||||
if '#' in messageId:
|
||||
messageId=messageId.split('#',1)[0]
|
||||
pageNumberStr=''
|
||||
if pageNumber:
|
||||
pageNumberStr='?page='+str(pageNumber)
|
||||
content+='<div class="question">'
|
||||
content+='<form method="POST" action="/users/'+nickname+'/question'+pageNumberStr+'">'
|
||||
content+='<input type="hidden" name="messageId" value="'+postJsonObject['id']+'"><br>'
|
||||
content+='<input type="hidden" name="messageId" value="'+messageId+'"><br>'
|
||||
for choice in postJsonObject['object']['oneOf']:
|
||||
if not choice.get('type'):
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue