Make operation_download() and operation_hostKey() return response body

This is more consistent, as all other handlers do the same.
This commit is contained in:
flan 2017-11-02 18:40:26 +01:00
parent 6e84242cc5
commit a52c213088

View File

@ -420,7 +420,7 @@ class SyncApp(object):
session = self.create_session(username, user_path) session = self.create_session(username, user_path)
self.session_manager.save(hkey, session) self.session_manager.save(hkey, session)
return hkey return {'key': hkey}
def operation_upload(self, col, data, session): def operation_upload(self, col, data, session):
# Verify integrity of the received database file before replacing our # Verify integrity of the received database file before replacing our
@ -451,7 +451,7 @@ class SyncApp(object):
if self.hook_upload is not None: if self.hook_upload is not None:
self.hook_upload(col, session) self.hook_upload(col, session)
return True return "OK"
def operation_download(self, col, session): def operation_download(self, col, session):
# run hook_download if one is defined # run hook_download if one is defined
@ -503,12 +503,12 @@ class SyncApp(object):
raise HTTPNotFound() raise HTTPNotFound()
if url == 'hostKey': if url == 'hostKey':
hkey = self.operation_hostKey(data.get("u"), data.get("p")) result = self.operation_hostKey(data.get("u"), data.get("p"))
if hkey: if result:
return Response( return Response(
status='200 OK', status='200 OK',
content_type='application/json', content_type='application/json',
body=json.dumps({'key': hkey})) body=json.dumps(result))
else: else:
# TODO: do I have to pass 'null' for the client to receive None? # TODO: do I have to pass 'null' for the client to receive None?
raise HTTPForbidden('null') raise HTTPForbidden('null')
@ -577,7 +577,7 @@ class SyncApp(object):
return Response( return Response(
status='200 OK', status='200 OK',
content_type='text/plain', content_type='text/plain',
body='OK' if result else 'Error') body=result)
elif url == 'download': elif url == 'download':
thread = session.get_thread() thread = session.get_thread()