Question votes use name field

main
Bob Mottram 2020-01-30 10:11:08 +00:00
parent 3870d15ed6
commit ecef571e6f
2 changed files with 6 additions and 4 deletions

View File

@ -231,6 +231,8 @@ class PubServer(BaseHTTPRequestHandler):
messageId,messageId,None, \ messageId,messageId,None, \
False,None,None,None) False,None,None,None)
if messageJson: if messageJson:
# name field contains the answer
messageJson['object']['name']=answer
if self._postToOutbox(messageJson,__version__,nickname): if self._postToOutbox(messageJson,__version__,nickname):
postFilename= \ postFilename= \
locatePost(self.server.baseDir,nickname, \ locatePost(self.server.baseDir,nickname, \

View File

@ -23,7 +23,7 @@ def questionUpdateVotes(baseDir: str,nickname: str,domain: str,replyJson: {}) ->
return None return None
if not replyJson['object']['inReplyTo']: if not replyJson['object']['inReplyTo']:
return None return None
if not replyJson['object'].get('content'): if not replyJson['object'].get('name'):
return None return None
inReplyTo=replyJson['object']['inReplyTo'] inReplyTo=replyJson['object']['inReplyTo']
questionPostFilename=locatePost(baseDir,nickname,domain,inReplyTo) questionPostFilename=locatePost(baseDir,nickname,domain,inReplyTo)
@ -46,13 +46,13 @@ def questionUpdateVotes(baseDir: str,nickname: str,domain: str,replyJson: {}) ->
return None return None
if not questionJson['object'].get('content'): if not questionJson['object'].get('content'):
return None return None
content=replyJson['object']['content'] replyVote=replyJson['object']['name']
# does the reply content match any possible question option? # does the reply name field match any possible question option?
foundAnswer=None foundAnswer=None
for possibleAnswer in questionJson['object']['oneOf']: for possibleAnswer in questionJson['object']['oneOf']:
if not possibleAnswer.get('name'): if not possibleAnswer.get('name'):
continue continue
if possibleAnswer['name'] in content: if possibleAnswer['name'] == replyVote:
foundAnswer=possibleAnswer foundAnswer=possibleAnswer
break break
if not foundAnswer: if not foundAnswer: