优化签名代码逻辑

dependabot/npm_and_yarn/fir_admin/url-parse-1.5.10
MMXX 3 years ago
parent 59d7d905d3
commit 7ad5bc8161
  1. 5
      fir_ser/api/models.py
  2. 19
      fir_ser/api/utils/app/supersignutils.py
  3. 4
      fir_ser/api/views/download.py

@ -280,8 +280,9 @@ class AppIOSDeveloperInfo(models.Model):
description = models.TextField('备注', blank=True, null=True, default='') description = models.TextField('备注', blank=True, null=True, default='')
auth_type_choices = ((0, 'p8key认证'),) auth_type_choices = ((0, 'p8key认证'),)
auth_type = models.SmallIntegerField(choices=auth_type_choices, default=0, verbose_name="认证类型") auth_type = models.SmallIntegerField(choices=auth_type_choices, default=0, verbose_name="认证类型")
status_choices = (
(0, '未激活'), (1, '已激活'), (2, '协议待同意'), (3, '维护中'), (4, '证书过期'), (5, '状态异常')) # 协议待同意和维护中:代表只读,不可创建和注册新设备号 # 协议待同意和维护中:代表只读,不可创建和注册新设备号
status_choices = ((0, '未激活'), (1, '已激活'), (2, '协议待同意'), (3, '维护中'), (4, '证书过期'), (5, '状态异常'))
status = models.SmallIntegerField(choices=status_choices, verbose_name="账户状态", default=0) status = models.SmallIntegerField(choices=status_choices, verbose_name="账户状态", default=0)
class Meta: class Meta:

@ -252,8 +252,17 @@ def get_new_developer_by_app_obj(app_obj, obj_base_filter, apple_to_app=False):
def filter_developer_by_pk_list(developer_pk_list, f_key, app_search_flag=True): def filter_developer_by_pk_list(developer_pk_list, f_key, app_search_flag=True):
developer_obj_dict = AppIOSDeveloperInfo.objects.filter(pk__in=developer_pk_list).values( developer_obj_dict = AppIOSDeveloperInfo.objects.filter(pk__in=developer_pk_list).values(
f_key, 'pk').annotate(count=Count('pk')) f_key, 'pk').annotate(count=Count('pk'))
if not app_search_flag: if app_search_flag:
developer_obj_dict = developer_obj_dict.filter(count__lt=F('app_limit_number')) return developer_obj_dict
else:
apple_filter = {f'{f_key}__isnull': False, 'pk__in': developer_pk_list}
developer_obj_dict = AppIOSDeveloperInfo.objects.filter(**apple_filter).values(f_key, 'pk').annotate(
count=Count('pk')).filter(count__lt=F('app_limit_number'))
if not developer_obj_dict:
apple_filter = {f'{f_key}__isnull': True, 'pk__in': developer_pk_list}
developer_obj_dict = AppIOSDeveloperInfo.objects.filter(**apple_filter).values(f_key, 'pk').annotate(
count=Count('pk'))
return developer_obj_dict return developer_obj_dict
@ -727,7 +736,7 @@ class IosUtils(object):
with cache.lock(register_devices_prefix, timeout=360): with cache.lock(register_devices_prefix, timeout=360):
if CleanErrorBundleIdSignDataState(add_new_bundles_prefix).get_state(): if CleanErrorBundleIdSignDataState(add_new_bundles_prefix).get_state():
return True, True # 程序错误,进行清理的时候,拦截多余的设备注册 return True, True # 程序错误,进行清理的时候,拦截多余的设备注册
if not get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj): if not get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj, False):
d_result['code'] = 1005 d_result['code'] = 1005
return False, d_result return False, d_result
status, did_udid_result = IosUtils.check_or_register_devices(self.app_obj, self.user_obj, status, did_udid_result = IosUtils.check_or_register_devices(self.app_obj, self.user_obj,
@ -971,7 +980,7 @@ class IosUtils(object):
status, result = app_api_obj.create_cert(user_obj) status, result = app_api_obj.create_cert(user_obj)
if status: if status:
cert_id = result.id cert_id = result.id
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=developer_obj.issuer_id).update(
status=1, status=1,
certid=cert_id, cert_expire_time=format_apple_date(result.expirationDate)) certid=cert_id, cert_expire_time=format_apple_date(result.expirationDate))
resign_app_obj = IosUtils.get_resign_obj(user_obj, developer_obj) resign_app_obj = IosUtils.get_resign_obj(user_obj, developer_obj)
@ -995,7 +1004,7 @@ class IosUtils(object):
app_api_obj = get_api_obj(developer_obj) app_api_obj = get_api_obj(developer_obj)
status, result = app_api_obj.get_cert_obj_by_cid() status, result = app_api_obj.get_cert_obj_by_cid()
if not status: if not status:
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=developer_obj.issuer_id).update(
certid=None, cert_expire_time=None) certid=None, cert_expire_time=None)
return status, result return status, result

@ -20,7 +20,7 @@ from api.utils.modelutils import get_filename_form_file, check_app_domain_name_a
ad_random_weight, get_app_download_uri ad_random_weight, get_app_download_uri
from api.utils.response import BaseResponse from api.utils.response import BaseResponse
from api.utils.serializer import AppsShortSerializer, AppAdInfoSerializer from api.utils.serializer import AppsShortSerializer, AppAdInfoSerializer
from api.utils.storage.caches import del_cache_response_by_short, check_app_permission, get_app_download_url from api.utils.storage.caches import check_app_permission, get_app_download_url
from api.utils.storage.storage import Storage, get_local_storage from api.utils.storage.storage import Storage, get_local_storage
from api.utils.throttle import VisitShortThrottle, InstallShortThrottle, InstallThrottle1, InstallThrottle2 from api.utils.throttle import VisitShortThrottle, InstallShortThrottle, InstallThrottle1, InstallThrottle2
from common.base.baseutils import get_profile_full_path, make_random_uuid, get_origin_domain_name, \ from common.base.baseutils import get_profile_full_path, make_random_uuid, get_origin_domain_name, \
@ -176,7 +176,7 @@ class ShortDownloadView(APIView):
res.code = 1002 res.code = 1002
res.msg = "参数有误" res.msg = "参数有误"
return Response(res.dict) return Response(res.dict)
del_cache_response_by_short(app_obj.app_id, udid=udid) # del_cache_response_by_short(app_obj.app_id, udid=udid)
app_serializer = AppsShortSerializer(app_obj, context={"key": "ShortDownloadView", "release_id": release_id, app_serializer = AppsShortSerializer(app_obj, context={"key": "ShortDownloadView", "release_id": release_id,
"storage": Storage(user_obj)}) "storage": Storage(user_obj)})

Loading…
Cancel
Save