mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 07:22:34 +00:00
update onlyoffice callback view
check doc key first
This commit is contained in:
@@ -32,7 +32,7 @@ def onlyoffice_editor_callback(request):
|
|||||||
logger.error('Request method if not POST.')
|
logger.error('Request method if not POST.')
|
||||||
# The document storage service must return the following response.
|
# The document storage service must return the following response.
|
||||||
# otherwise the document editor will display an error message.
|
# otherwise the document editor will display an error message.
|
||||||
return HttpResponse('{"error": 0}')
|
return HttpResponse('{"error": 1}')
|
||||||
|
|
||||||
# body info of POST rquest when open file on browser
|
# body info of POST rquest when open file on browser
|
||||||
# {u'actions': [{u'type': 1, u'userid': u'uid-1527736776860'}],
|
# {u'actions': [{u'type': 1, u'userid': u'uid-1527736776860'}],
|
||||||
@@ -77,20 +77,21 @@ def onlyoffice_editor_callback(request):
|
|||||||
post_data = json.loads(request.body)
|
post_data = json.loads(request.body)
|
||||||
status = int(post_data.get('status', -1))
|
status = int(post_data.get('status', -1))
|
||||||
|
|
||||||
|
# get doc key and file basic info from cache
|
||||||
|
doc_key = post_data.get('key')
|
||||||
|
doc_info_from_cache = cache.get("ONLYOFFICE_%s" % doc_key)
|
||||||
|
if not doc_info_from_cache:
|
||||||
|
logger.error('can not get doc_info from cache by doc_key {}'.format(doc_key))
|
||||||
|
logger.info(post_data)
|
||||||
|
return HttpResponse('{"error": 1}')
|
||||||
|
|
||||||
if status == 1:
|
if status == 1:
|
||||||
logger.info('status {}'.format(status))
|
logger.info(post_data)
|
||||||
return HttpResponse('{"error": 0}')
|
return HttpResponse('{"error": 0}')
|
||||||
|
|
||||||
if status not in (2, 4, 6):
|
if status not in (2, 4, 6):
|
||||||
logger.error('status {}: invalid status'.format(status))
|
logger.error('status {}: invalid status'.format(status))
|
||||||
return HttpResponse('{"error": 0}')
|
return HttpResponse('{"error": 1}')
|
||||||
|
|
||||||
# get file basic info
|
|
||||||
doc_key = post_data.get('key')
|
|
||||||
doc_info_from_cache = cache.get("ONLYOFFICE_%s" % doc_key)
|
|
||||||
if not doc_info_from_cache:
|
|
||||||
logger.error('status {}: can not get doc_info from cache by doc_key {}'.format(status, doc_key))
|
|
||||||
return HttpResponse('{"error": 0}')
|
|
||||||
|
|
||||||
doc_info = json.loads(doc_info_from_cache)
|
doc_info = json.loads(doc_info_from_cache)
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ def onlyoffice_editor_callback(request):
|
|||||||
onlyoffice_resp = requests.get(url, verify=VERIFY_ONLYOFFICE_CERTIFICATE)
|
onlyoffice_resp = requests.get(url, verify=VERIFY_ONLYOFFICE_CERTIFICATE)
|
||||||
if not onlyoffice_resp:
|
if not onlyoffice_resp:
|
||||||
logger.error('[OnlyOffice] No response from file content url.')
|
logger.error('[OnlyOffice] No response from file content url.')
|
||||||
return HttpResponse('{"error": 0}')
|
return HttpResponse('{"error": 1}')
|
||||||
|
|
||||||
fake_obj_id = {'online_office_update': True}
|
fake_obj_id = {'online_office_update': True}
|
||||||
update_token = seafile_api.get_fileserver_access_token(repo_id,
|
update_token = seafile_api.get_fileserver_access_token(repo_id,
|
||||||
@@ -121,7 +122,7 @@ def onlyoffice_editor_callback(request):
|
|||||||
|
|
||||||
if not update_token:
|
if not update_token:
|
||||||
logger.error('[OnlyOffice] No fileserver access token.')
|
logger.error('[OnlyOffice] No fileserver access token.')
|
||||||
return HttpResponse('{"error": 0}')
|
return HttpResponse('{"error": 1}')
|
||||||
|
|
||||||
# get file content
|
# get file content
|
||||||
files = {
|
files = {
|
||||||
|
Reference in New Issue
Block a user