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.
flyapps/fir_ser/api/views/receiveudids.py

41 lines
1.6 KiB

5 years ago
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 3月
# author: liuyu
# date: 2020/3/6
5 years ago
from api.utils.app.supersignutils import udid_bytes_to_dict, get_redirect_server_domain, IosUtils
from api.models import Apps, AppUDID
5 years ago
from django.views import View
from django.http import HttpResponsePermanentRedirect
import logging
logger = logging.getLogger(__file__)
5 years ago
5 years ago
class IosUDIDView(View):
5 years ago
def post(self, request, short):
5 years ago
stream_f = str(request.body)
format_udid_info = udid_bytes_to_dict(stream_f)
logger.info("short %s get new udid %s" % (short, format_udid_info))
5 years ago
server_domain = get_redirect_server_domain(request)
5 years ago
try:
5 years ago
app_info = Apps.objects.filter(short=short).first()
5 years ago
5 years ago
if app_info:
if app_info.issupersign and app_info.user_id.supersign_active:
5 years ago
AppUDID.objects.update_or_create(app_id=app_info, **format_udid_info,
defaults={'udid': format_udid_info.get('udid')})
ios_obj = IosUtils(format_udid_info, app_info.user_id, app_info)
5 years ago
ios_obj.resign()
else:
5 years ago
return HttpResponsePermanentRedirect(
"%s/%s" % (server_domain, short))
5 years ago
else:
5 years ago
return HttpResponsePermanentRedirect(
"%s/%s" % (server_domain, short))
5 years ago
except Exception as e:
logger.error("short %s receive udid Exception:%s" % (short, e))
5 years ago
return HttpResponsePermanentRedirect("%s/%s?udid=%s" % (server_domain, short, format_udid_info.get("udid")))