You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
1.2 KiB

from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from .models import ASSNotification
from django.conf import settings
import json, jwt
import base64
import logging
import logging.config
logger = logging.getLogger("main")
def index(request):
return HttpResponse("Hello, world. You're at the subs index.")
def test(request):
return HttpResponse("Test succeeded!")
@csrf_exempt
def app_store_webhook(request):
data = request.body.decode('utf-8')
# Parse the JSON payload
fulljson = json.loads(data)
signedPayload = fulljson['signedPayload']
content = signedPayload.split('.')[1]
jws_payload = base64.b64decode(content)
data = json.loads(jws_payload.decode())
#KEY_FILE = settings.ASS_KEY_FILE
#with open(KEY_FILE,'r') as key_file:
# key = ''.join(key_file.readlines())
#decodedPayload = jwt.decode(signedPayload, key, algorithms=['ES256'])
#print('hell yeah!' + str(key))
#logger.debug('test getLogger' + str(key))
notification = ASSNotification(
content=jws_payload,
)
notification.save()
return JsonResponse({'status': 'success'})