Commit 88ea998f authored by Ozzieisaacs's avatar Ozzieisaacs

Only register gdrive callback if gdrive is enabled

With enabled gdrive return on change if no watch callback is configured, instead of send request to google drive
parent 388e46ee
......@@ -31,7 +31,7 @@ else:
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'vendor'))
from cps import create_app
from cps import create_app, config
from cps import web_server
from cps.opds import opds
from cps.web import web
......@@ -64,6 +64,7 @@ def main():
app.register_blueprint(about)
app.register_blueprint(shelf)
app.register_blueprint(admi)
if config.config_use_google_drive:
app.register_blueprint(gdrive)
app.register_blueprint(editbook)
if kobo_available:
......
......@@ -123,10 +123,12 @@ def revoke_watch_gdrive():
@gdrive.route("/gdrive/watch/callback", methods=['GET', 'POST'])
def on_received_watch_confirmation():
if not config.config_google_drive_watch_changes_response:
return ''
if request.headers.get('X-Goog-Channel-Token') != gdrive_watch_callback_token \
or request.headers.get('X-Goog-Resource-State') != 'change' \
or not request.data:
return redirect(url_for('admin.configuration'))
return '' # redirect(url_for('admin.configuration'))
log.debug('%r', request.headers)
log.debug('%r', request.data)
......
......@@ -20,6 +20,8 @@ from __future__ import division, print_function, unicode_literals
import os
import json
import shutil
import chardet
import ssl
from flask import Response, stream_with_context
from sqlalchemy import create_engine
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment