GCal: Better Callback management
- when callback of an old channel is received this channel is canceled automatically
This commit is contained in:
@@ -3,6 +3,7 @@ from eventplanner_gcal.google_sync import syncFromGoogleToLocal, syncFromLocalTo
|
||||
from django.http import HttpResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from pprint import pformat
|
||||
from eventplanner_gcal.google_sync import checkIfGoogleCallbackIsValid
|
||||
|
||||
import logging
|
||||
|
||||
@@ -16,15 +17,23 @@ def runSync( request ):
|
||||
@csrf_exempt
|
||||
def gcalApiCallback( request ):
|
||||
# TODO check channel info here
|
||||
requestMetaStr = pformat( request.META )
|
||||
logger.info( "Received Google Callback with the following headers:\n" + requestMetaStr )
|
||||
token = ""
|
||||
if 'HTTP_X_GOOG_CHANNEL_TOKEN' in request.META: token = request.META['HTTP_X_GOOG_CHANNEL_TOKEN']
|
||||
channelID = ""
|
||||
if 'HTTP_X_GOOG_CHANNEL_ID' in request.META: channelID = request.META['HTTP_X_GOOG_CHANNEL_ID']
|
||||
resourceID = ""
|
||||
if 'HTTP_X_GOOG_RESOURCE_ID' in request.META: resourceID = request.META['HTTP_X_GOOG_RESOURCE_ID']
|
||||
|
||||
valid = checkIfGoogleCallbackIsValid( token, channelID, resourceID)
|
||||
|
||||
if not valid:
|
||||
return HttpResponse('<h1>Old Channel - no update triggered</h1>')
|
||||
|
||||
|
||||
logger.info( "Received Google Callback with the following headers Token: %s ID %s ResID %s " % ( token, channelID, resourceID ) )
|
||||
result = syncFromGoogleToLocal()
|
||||
logger.info("Finished processing callback from GCal - New Information present: %1 " %(result, ) )
|
||||
logger.info("Finished processing callback from GCal - New Information present: %d " %(result, ) )
|
||||
return HttpResponse('<h1>Callback successful</h1>')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user