后端更新下载码逻辑

qrnn
MMXX 3 years ago
parent 979b6f0386
commit 5dd1dd0681
  1. 2
      fir_ser/api/migrations/0012_useraddisplayinfo.py
  2. 22
      fir_ser/api/migrations/0028_auto_20211220_1711.py
  3. 4
      fir_ser/api/models.py
  4. 11
      fir_ser/api/utils/baseutils.py
  5. 77
      fir_ser/api/utils/modelutils.py
  6. 28
      fir_ser/api/utils/serializer.py
  7. 54
      fir_ser/api/views/apps.py
  8. 77
      fir_ser/api/views/domain.py
  9. 17
      fir_ser/api/views/download.py
  10. 5
      fir_ser/api/views/receiveudids.py
  11. 6
      fir_ser/api/views/uploads.py

@ -17,7 +17,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ad_uri', models.CharField(max_length=256, verbose_name='广告跳转地址')),
('ad_pic', models.CharField(help_text='像素最高80px', max_length=256, verbose_name='广告图片地址')),
('weight', models.IntegerField(default=1, verbose_name='广告展示权重')),
('weight', models.IntegerField(default=10, verbose_name='广告展示权重')),
('description', models.TextField(blank=True, default='', null=True, verbose_name='描述信息')),
('is_enable', models.BooleanField(default=False, verbose_name='广告开启状态')),
('created_time', models.DateTimeField(auto_now_add=True, verbose_name='广告创建时间')),

@ -0,0 +1,22 @@
# Generated by Django 3.2.3 on 2021-12-20 17:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0027_appiosdeveloperinfo_app_limit_number'),
]
operations = [
migrations.AddField(
model_name='userdomaininfo',
name='is_https',
field=models.BooleanField(default=False, verbose_name='是否支持HTTPS'),
),
migrations.AddField(
model_name='userdomaininfo',
name='weight',
field=models.IntegerField(default=10, verbose_name='下载页域名展示权重'),
),
]

@ -497,6 +497,8 @@ class UserDomainInfo(models.Model):
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="APP专属域名", null=True, blank=True)
cname_id = models.ForeignKey(to="DomainCnameInfo", verbose_name="cname解析ID", on_delete=models.CASCADE)
domain_name = models.CharField(verbose_name="下载页面域名", db_index=True, max_length=64, null=False, blank=False)
is_https = models.BooleanField(default=False, verbose_name="是否支持HTTPS")
weight = models.IntegerField(verbose_name="下载页域名展示权重", default=10)
is_enable = models.BooleanField(default=False, verbose_name="绑定成功")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
domain_type_choices = ((0, '下载码域名'), (1, '下载页域名'), (2, '应用专用域名'))
@ -522,7 +524,7 @@ class UserAdDisplayInfo(models.Model):
ad_name = models.CharField(verbose_name="广告名称", max_length=256, null=False, blank=False)
ad_uri = models.CharField(verbose_name="广告跳转地址", max_length=256, null=False, blank=False)
ad_pic = models.CharField(verbose_name="广告图片地址", max_length=256, null=False, blank=False, help_text="像素最高80px", )
weight = models.IntegerField(verbose_name="广告展示权重", default=1)
weight = models.IntegerField(verbose_name="广告展示权重", default=10)
description = models.TextField('描述信息', blank=True, null=True, default='')
is_enable = models.BooleanField(default=False, verbose_name="广告开启状态")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="广告创建时间")

@ -199,11 +199,11 @@ def format_storage_selection(storage_info_list, storage_choice_list):
return storage_choice_list
def get_cname_from_domain(domain):
def get_cname_from_domain(domain, resolve_cname):
dns_list = [
["8.8.8.8", "8.8.4.4"],
["119.29.29.29", "114.114.114.114"],
["223.5.5.5", "223.6.6.6"],
["8.8.8.8", "8.8.4.4"],
]
dns_resolver = Resolver()
domain = domain.lower().strip()
@ -211,13 +211,14 @@ def get_cname_from_domain(domain):
while count:
try:
dns_resolver.nameservers = dns_list[len(dns_list) - count]
return dns_resolver.resolve(domain, 'CNAME')[0].to_text()
if dns_resolver.resolve(domain, 'CNAME')[0].to_text() == resolve_cname:
return True
except Exception as e:
logger.error(f"dns {dns_resolver.nameservers} resolve {domain} failed Exception:{e}")
count -= 1
time.sleep(0.3)
if count <= 0:
return str(None)
return None
def get_user_default_domain_name(domain_cname_obj):
@ -227,7 +228,7 @@ def get_user_default_domain_name(domain_cname_obj):
def get_server_domain_from_request(request, server_domain):
if not server_domain or not server_domain.startswith("http"):
if not (server_domain and len(server_domain) > 8): # len('https://')
http_host = request.META.get('HTTP_HOST')
server_protocol = request.META.get('SERVER_PROTOCOL')
protocol = 'https'

@ -43,6 +43,48 @@ def get_app_domain_name(obj):
return ''
def get_app_download_domain(user_obj, request=None, app_obj=None, preview=False):
# 如果有专属域名,则返回专属域名
# 如果只配置了下载码域名,则返回下载码域名
# 如果配置下载页域名,则返回下载页域名
# 最后返回该用户系统默认域名
base_user_domain = UserDomainInfo.objects.filter(is_enable=True, user_id=user_obj).all()
if app_obj:
app_domain_name = base_user_domain.filter(app_id=app_obj, domain_type=2).first()
if app_domain_name:
return app_domain_name.is_https, app_domain_name.domain_name
qr_domain_name = base_user_domain.filter(app_id=None, domain_type=0).values_list('is_https', 'domain_name').first()
download_domain_name = base_user_domain.filter(app_id=None, domain_type=1).all()
if request:
origin_domain_name = get_origin_domain_name(request)
exist_download_obj = download_domain_name.filter(domain_name=origin_domain_name).first()
if exist_download_obj:
return exist_download_obj.is_https, exist_download_obj.domain_name
download_domain_name = base_random_weight(download_domain_name, 'weight')
if preview:
if qr_domain_name:
return qr_domain_name
else:
if qr_domain_name and not download_domain_name:
return qr_domain_name
if download_domain_name:
return download_domain_name.is_https, download_domain_name.domain_name
return get_user_default_domain_name(user_obj.default_domain_name)
def get_app_download_uri(request, user_obj, app_obj=None, preview=True):
is_https, domain_name = get_app_download_domain(user_obj, request, app_obj, preview)
if not (domain_name and len(domain_name) > 3):
is_https, domain_name = get_user_default_domain_name(get_min_default_domain_cname_obj(True))
server_domain = ''
if domain_name and len(domain_name) > 3:
protocol = 'https' if is_https else 'http'
server_domain = f"{protocol}://{domain_name}"
return get_server_domain_from_request(request, server_domain)
def get_min_default_domain_cname_obj(is_system=True):
return min(DomainCnameInfo.objects.annotate(Count('userinfo')).filter(is_enable=True, is_system=is_system),
key=lambda x: x.userinfo__count)
@ -62,20 +104,24 @@ def get_filename_form_file(filename):
return filename
def ad_random_weight(user_obj):
ad_info_list = UserAdDisplayInfo.objects.filter(user_id=user_obj, is_enable=True).order_by('-created_time')
total = sum([ad_info.weight for ad_info in ad_info_list]) # 权重求和
def base_random_weight(obj, key):
total = sum([getattr(ad_info, key) for ad_info in obj]) # 权重求和
ra = random.uniform(0, total) # 在0与权重和之前获取一个随机数
curr_sum = 0
ret = ad_info_list.first()
for ad_info in ad_info_list:
curr_sum += ad_info.weight # 在遍历中,累加当前权重值
ret = obj.first()
for ad_info in obj:
curr_sum += getattr(ad_info, key) # 在遍历中,累加当前权重值
if ra <= curr_sum: # 当随机数<=当前权重和时,返回权重key
ret = ad_info
break
return ret
def ad_random_weight(user_obj):
ad_info_list = UserAdDisplayInfo.objects.filter(user_id=user_obj, is_enable=True).order_by('-created_time')
return base_random_weight(ad_info_list, 'weight')
def add_remote_info_from_request(request, description):
meta_info = request.META
if request.user and request.user.id is not None:
@ -94,23 +140,16 @@ def add_remote_info_from_request(request, description):
logger.error(e)
def get_redirect_server_domain(request, user_obj=None, app_domain_name=None):
def get_redirect_server_domain(request, user_obj=None):
is_https = False
if user_obj:
if app_domain_name and len(app_domain_name) > 3:
domain_name = app_domain_name
else:
domain_name = get_user_domain_name(user_obj)
if not domain_name:
is_https, domain_name = get_user_default_domain_name(user_obj.default_domain_name)
elif app_domain_name and len(app_domain_name) > 3:
domain_name = app_domain_name
domain_name = get_user_domain_name(user_obj)
if not domain_name:
is_https, domain_name = get_user_default_domain_name(user_obj.default_domain_name)
else:
is_https, domain_name = get_user_default_domain_name(get_min_default_domain_cname_obj(True))
protocol = 'http'
if is_https:
protocol = 'https'
server_domain = "%s://%s" % (protocol, domain_name)
protocol = 'https' if is_https else 'http'
server_domain = f"{protocol}://{domain_name}"
return get_server_domain_from_request(request, server_domain)

@ -7,7 +7,7 @@ from rest_framework import serializers
from api import models
from api.utils.TokenManager import make_token
from api.utils.app.apputils import bytes2human
from api.utils.modelutils import get_user_domain_name, get_app_domain_name, get_redirect_server_domain
from api.utils.modelutils import get_user_domain_name, get_app_domain_name, get_app_download_uri
from api.utils.storage.caches import get_user_free_download_times, get_user_cert_auth_status
from api.utils.storage.storage import Storage
from api.utils.utils import get_developer_udided, get_choices_dict, get_choices_name_from_key
@ -152,7 +152,7 @@ class AppsSerializer(serializers.ModelSerializer):
preview_url = serializers.SerializerMethodField()
def get_preview_url(self, obj):
return get_redirect_server_domain(None, obj.user_id, get_app_domain_name(obj))
return get_app_download_uri(None, obj.user_id, obj)
private_developer_number = serializers.SerializerMethodField()
@ -255,6 +255,28 @@ class AppsListSerializer(AppsSerializer):
return AppsListSerializer(obj.has_combo, context=self.context).data
class AppsQrListSerializer(AppsListSerializer):
class Meta:
model = models.Apps
fields = ["app_id", "bundle_id", "name", "preview_url", "short", "type", "master_release"]
def get_master_release(self, obj):
master_release_obj = get_app_master_obj_from_context(self, obj)
if master_release_obj:
key = ''
icon_url = get_download_url_from_context(self, obj, key, master_release_obj.icon_url)
datainfo = {
"app_version": master_release_obj.app_version,
"icon_url": icon_url,
"build_version": master_release_obj.build_version,
"binary_url": master_release_obj.binary_url,
"release_type": master_release_obj.release_type,
}
return datainfo
else:
return {}
class AdminAppsSerializer(AppsSerializer):
class Meta:
model = models.Apps
@ -322,6 +344,8 @@ class AppsShortSerializer(serializers.ModelSerializer):
master_release_obj = get_app_master_obj_from_context(self, obj)
if master_release_obj:
key = ''
if self.context.get("key", None) and self.context.get("key") != "undefined":
key = self.context.get("key", '')
icon_url = get_download_url_from_context(self, obj, key, os.path.basename(master_release_obj.icon_url),
True)
datainfo = {

@ -18,7 +18,7 @@ from api.utils.app.supersignutils import IosUtils
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.modelutils import get_user_domain_name, get_app_domain_name, check_super_sign_permission
from api.utils.response import BaseResponse
from api.utils.serializer import AppsSerializer, AppReleaseSerializer, AppsListSerializer
from api.utils.serializer import AppsSerializer, AppReleaseSerializer, AppsListSerializer, AppsQrListSerializer
from api.utils.storage.caches import del_cache_response_by_short, get_app_today_download_times, del_cache_by_delete_app, \
CleanAppSignDataState, MigrateStorageState
from api.utils.storage.storage import Storage
@ -39,6 +39,22 @@ def get_release_apps(request, res, app_serializer, apps_obj, storage):
return res
def apps_filter(request):
app_type = request.query_params.get("type", None)
act_type = request.query_params.get("act", None)
if app_type == "android":
filter_data = {"user_id": request.user, "type": 0}
elif app_type == "ios":
filter_data = {"user_id": request.user, "type": 1}
else:
filter_data = {"user_id": request.user}
if act_type == "combo":
filter_data["has_combo"] = None
return Apps.objects.filter(**filter_data).all()
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
@ -50,9 +66,6 @@ class AppsView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
def get(self, request):
app_type = request.query_params.get("type", None)
act_type = request.query_params.get("act", None)
res = BaseResponse()
res.hdata = {"all_hits_count": 0,
"ios_count": Apps.objects.filter(type=1, user_id=request.user).values('app_id').count(),
@ -79,19 +92,7 @@ class AppsView(APIView):
else:
res.hdata["all_hits_count"] = 0
if app_type == "android":
filter_data = {"user_id": request.user, "type": 0}
elif app_type == "ios":
filter_data = {"user_id": request.user, "type": 1}
else:
filter_data = {"user_id": request.user}
if act_type == "combo":
filter_data["has_combo"] = None
apps_obj = Apps.objects.filter(**filter_data)
logger.info(filter_data)
apps_obj = apps_filter(request)
page_obj = AppsPageNumber()
app_page_serializer = page_obj.paginate_queryset(queryset=apps_obj.order_by("-updated_time"), request=request,
view=self)
@ -390,27 +391,14 @@ class AppsQrcodeShowView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
def get(self, request):
app_type = request.query_params.get("type", None)
act_type = request.query_params.get("act", None)
res = BaseResponse()
if app_type == "android":
filter_data = {"user_id": request.user, "type": 0}
elif app_type == "ios":
filter_data = {"user_id": request.user, "type": 1}
else:
filter_data = {"user_id": request.user}
if act_type == "combo":
filter_data["has_combo"] = None
apps_obj = Apps.objects.filter(**filter_data)
apps_obj = apps_filter(request)
page_obj = AppsPageNumber()
app_page_serializer = page_obj.paginate_queryset(queryset=apps_obj.order_by("-updated_time"), request=request,
view=self)
app_serializer = AppsListSerializer(app_page_serializer, many=True, context={"storage": Storage(request.user)})
app_serializer = AppsQrListSerializer(app_page_serializer, many=True,
context={"storage": Storage(request.user)})
res.data = app_serializer.data
res.has_next = page_obj.page.has_next()

@ -10,7 +10,7 @@ from rest_framework.response import Response
from rest_framework.views import APIView
from api.models import UserDomainInfo, Apps
from api.utils.auth import ExpiringTokenAuthentication, DownloadQrPermission
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.baseutils import is_valid_domain, get_cname_from_domain
from api.utils.modelutils import get_user_domain_name, get_min_default_domain_cname_obj
from api.utils.response import BaseResponse
@ -25,14 +25,27 @@ def get_domain_filter(request):
filter_dict = {'user_id': request.user, 'app_id__app_id': None}
app_id = request.query_params.get("app_id", request.data.get("app_id", None))
domain_type = request.query_params.get("domain_type", request.data.get("domain_type", None))
domain_name = request.query_params.get("domain_name", request.data.get("domain_name", ''))
if app_id is not None:
filter_dict['app_id__app_id'] = app_id
if domain_type is not None:
filter_dict['domain_type'] = domain_type
if domain_name:
filter_dict['domain_name'] = domain_name
logger.info(f"domain filter {filter_dict}")
return filter_dict
def auto_clean_download_cache(user_obj, user_domain_obj, app_obj):
if user_domain_obj:
base_domain_queryset = UserDomainInfo.objects.filter(user_id=user_obj, is_enable=True).all()
if user_domain_obj.domain_type in [0, 1]:
if base_domain_queryset.filter(domain_type__in=[0, 1]).count() == 0:
reset_app_wx_easy_type(user_obj, None)
else:
reset_app_wx_easy_type(user_obj, app_obj)
def remove_domain_wx_easy(app_obj, user_obj):
if app_obj and not get_user_domain_name(user_obj):
app_obj.wxeasytype = True
@ -62,13 +75,13 @@ def add_new_domain_info(res, request, domain_name, domain_type):
class DomainCnameView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
permission_classes = [DownloadQrPermission, ]
def get(self, request):
res = BaseResponse()
res.data = {'domain_name': '', 'domain_record': '', 'is_enable': False}
user_domain_obj = UserDomainInfo.objects.filter(**get_domain_filter(request)).first()
if user_domain_obj:
domain_name = request.query_params.get("domain_name", '')
if (user_domain_obj and domain_name) or (user_domain_obj and user_domain_obj.domain_type == 0):
res.data['domain_name'] = user_domain_obj.domain_name
res.data['is_enable'] = user_domain_obj.is_enable
if user_domain_obj.cname_id:
@ -87,7 +100,7 @@ class DomainCnameView(APIView):
if domain_name:
domain_name = domain_name.strip(" ")
if domain_name and len(domain_name) > 3 and is_valid_domain(domain_name):
filter_dict = get_domain_filter(request)
# filter_dict = get_domain_filter(request)
if not force_bind:
user_domain_obj = UserDomainInfo.objects.filter(domain_name=domain_name, is_enable=True).first()
if user_domain_obj:
@ -104,16 +117,18 @@ class DomainCnameView(APIView):
res.msg = "该域名已经被其他用户绑定"
res.msg += ",请更换要绑定的域名,或者进行强制绑定域名"
else:
user_domain_obj = UserDomainInfo.objects.filter(**get_domain_filter(request),
domain_name=domain_name).first()
kwargs = get_domain_filter(request)
kwargs['domain_name'] = domain_name
user_domain_obj = UserDomainInfo.objects.filter(**kwargs).first()
if user_domain_obj:
res.data = {'cname_domain': user_domain_obj.cname_id.domain_record}
else:
UserDomainInfo.objects.filter(**filter_dict, is_enable=False).delete()
UserDomainInfo.objects.filter(**kwargs, is_enable=False).delete()
add_new_domain_info(res, request, domain_name, domain_type)
else:
user_domain_obj = UserDomainInfo.objects.filter(**filter_dict,
domain_name=domain_name).first()
kwargs = get_domain_filter(request)
kwargs['domain_name'] = domain_name
user_domain_obj = UserDomainInfo.objects.filter(**kwargs).first()
if user_domain_obj:
res.data = {'cname_domain': user_domain_obj.cname_id.domain_record}
else:
@ -125,27 +140,40 @@ class DomainCnameView(APIView):
def put(self, request):
res = BaseResponse()
user_domain_obj = UserDomainInfo.objects.filter(**get_domain_filter(request)).first()
kwargs = get_domain_filter(request)
if kwargs.get('domain_type', -1) in [0, 2]:
domain_name = kwargs.get('domain_name')
if domain_name:
kwargs.pop('domain_name')
kwargs['is_enable'] = False
user_domain_obj = UserDomainInfo.objects.filter(**kwargs).first()
if user_domain_obj:
cname = get_cname_from_domain(user_domain_obj.domain_name)
if cname == user_domain_obj.cname_id.domain_record + '.':
cname = get_cname_from_domain(user_domain_obj.domain_name, user_domain_obj.cname_id.domain_record + '.')
if cname:
user_domain_obj_list = UserDomainInfo.objects.filter(domain_name=user_domain_obj.domain_name,
is_enable=True).all()
if len(user_domain_obj_list) < 2:
if len(user_domain_obj_list) == 1:
user_obj = user_domain_obj_list.first().user_id
app_obj = user_domain_obj_list.first().app_id
o_user_domain_obj = user_domain_obj_list.first()
auto_clean_download_cache(user_obj, o_user_domain_obj, app_obj)
user_domain_obj_list.delete()
reset_app_wx_easy_type(user_obj, app_obj)
if kwargs.get('domain_type', -1) in [0, 2]:
kwargs.pop('is_enable')
UserDomainInfo.objects.filter(**kwargs).delete()
user_domain_obj.is_enable = True
user_domain_obj.save(update_fields=["is_enable"])
user_domain_obj.save()
app_id = request.data.get("app_id", None)
app_obj = None
if app_id:
app_obj = Apps.objects.filter(app_id=app_id).first()
reset_app_wx_easy_type(request.user, app_obj)
auto_clean_download_cache(request.user, user_domain_obj, app_obj)
else:
res.code = 1002
res.msg = "该域名查询校验失败,请检查"
@ -157,7 +185,7 @@ class DomainCnameView(APIView):
res.msg = "域名已经被绑定或者域名有误"
return Response(res.dict)
def delete(sele, request):
def delete(self, request):
res = BaseResponse()
user_domain_obj = UserDomainInfo.objects.filter(**get_domain_filter(request)).first()
if user_domain_obj:
@ -165,7 +193,7 @@ class DomainCnameView(APIView):
app_obj = None
if app_id:
app_obj = Apps.objects.filter(app_id=app_id).first()
reset_app_wx_easy_type(request.user, app_obj)
auto_clean_download_cache(request.user, user_domain_obj, app_obj)
user_domain_obj.delete()
return Response(res.dict)
@ -203,3 +231,18 @@ class DomainInfoView(APIView):
res.domain_type_choices = get_choices_dict(UserDomainInfo.domain_type_choices)
return Response(res.dict)
def put(self, request):
res = BaseResponse()
domain_name = request.data.get('domain_name', '')
weight = request.data.get('weight', 10)
domain_type = request.data.get('domain_type', None)
if domain_type is not None and weight and domain_name:
domain_name_obj = UserDomainInfo.objects.filter(user_id=request.user, domain_name=domain_name,
domain_type=domain_type).all()
if domain_name_obj and len(domain_name_obj) == 1:
domain_name_obj.update(weight=weight)
else:
res.code = 1002
res.msg = '参数有误'
return Response(res.dict)

@ -18,8 +18,8 @@ from api.utils.app.supersignutils import make_sign_udid_mobile_config
from api.utils.baseutils import get_profile_full_path, make_random_uuid, get_origin_domain_name, \
format_get_uri, get_post_udid_url
from api.utils.decorators import cache_response # 本来使用的是 drf-extensions==0.7.0 但是还未支持该版本Django
from api.utils.modelutils import get_app_domain_name, get_filename_form_file, check_app_domain_name_access, \
ad_random_weight, get_redirect_server_domain
from api.utils.modelutils import get_filename_form_file, check_app_domain_name_access, \
ad_random_weight, get_app_download_uri
from api.utils.response import BaseResponse
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
@ -154,9 +154,9 @@ class ShortDownloadView(APIView):
res = check_app_permission(app_obj, res, user_obj)
if res.code != 1000:
return Response(res.dict)
domain_name = get_redirect_server_domain(request, user_obj, get_app_domain_name(app_obj))
domain_name = get_app_download_uri(request, user_obj, app_obj, False)
origin_domain_name = get_origin_domain_name(request)
logger.info(f"app_obj:{app_obj.__dict__} domain_name:{domain_name} origin_domain_name:{origin_domain_name}")
if user_obj and user_obj.role and user_obj.role == 3:
...
else:
@ -184,7 +184,9 @@ class ShortDownloadView(APIView):
res.udid = udid
res.domain_name = domain_name
if user_obj and user_obj.role and user_obj.role > 1:
res.ad = AppAdInfoSerializer(ad_random_weight(user_obj), context={"key": "ShortDownloadView"}).data
ad_obj = ad_random_weight(user_obj)
if ad_obj:
res.ad = AppAdInfoSerializer(ad_obj, context={"key": "ShortDownloadView", "short": short}).data
return Response(res.dict)
# key的设置
@ -193,6 +195,7 @@ class ShortDownloadView(APIView):
release_id = request.query_params.get("release_id", '')
udid = request.query_params.get("udid", None)
time = request.query_params.get("time", None)
short = kwargs.get("short", '')
origin_domain_name = get_origin_domain_name(request)
if not origin_domain_name:
origin_domain_name = 'default.site'
@ -201,9 +204,9 @@ class ShortDownloadView(APIView):
if not udid:
udid = ""
logging.info(
f"get or make cache_response short:{kwargs.get('short', '')} origin_domain_name:{origin_domain_name} release_id:{release_id} udid:{udid}")
f"get or make cache_response short:{short} origin_domain_name:{origin_domain_name} release_id:{release_id} udid:{udid}")
return "_".join(
[settings.CACHE_KEY_TEMPLATE.get("download_short_key"), kwargs.get("short", ''), origin_domain_name,
[settings.CACHE_KEY_TEMPLATE.get("download_short_key"), short, origin_domain_name,
release_id, udid])

@ -15,7 +15,8 @@ from api.models import Apps
from api.tasks import run_sign_task
from api.utils.app.supersignutils import udid_bytes_to_dict, make_sign_udid_mobile_config
from api.utils.baseutils import get_real_ip_address, get_http_server_domain, make_random_uuid
from api.utils.modelutils import get_app_domain_name, get_redirect_server_domain, add_remote_info_from_request
from api.utils.modelutils import get_redirect_server_domain, add_remote_info_from_request, \
get_app_download_uri
from api.utils.response import BaseResponse
from api.utils.storage.caches import check_app_permission
from api.utils.throttle import ReceiveUdidThrottle1, ReceiveUdidThrottle2
@ -35,7 +36,7 @@ class IosUDIDView(APIView):
try:
app_obj = Apps.objects.filter(short=short).first()
if app_obj:
server_domain = get_redirect_server_domain(request, app_obj.user_id, get_app_domain_name(app_obj))
server_domain = get_app_download_uri(request, app_obj.user_id, app_obj, preview=False)
if app_obj.issupersign and app_obj.user_id.supersign_active:
res = check_app_permission(app_obj, BaseResponse())
if res.code != 1000:

@ -16,7 +16,7 @@ from api.utils.TokenManager import verify_token
from api.utils.app.apputils import get_random_short, save_app_infos
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.baseutils import make_app_uuid, make_from_user_uuid
from api.utils.modelutils import get_app_domain_name, get_redirect_server_domain, check_super_sign_permission
from api.utils.modelutils import check_super_sign_permission, get_app_download_uri
from api.utils.response import BaseResponse
from api.utils.storage.caches import upload_file_tmp_name, del_cache_response_by_short, MigrateStorageState
from api.utils.storage.storage import Storage
@ -60,12 +60,12 @@ class AppAnalyseView(APIView):
enable_sign = app_obj.issupersign
short = app_obj.short
app_release_obj = AppReleaseInfo.objects.filter(app_id=app_obj, is_master=True).first()
short_domain_name = get_redirect_server_domain(request, request.user, get_app_domain_name(app_obj))
short_domain_name = get_app_download_uri(request, request.user, app_obj)
if app_release_obj:
binary_url = app_release_obj.binary_url
else:
is_new = True
short_domain_name = get_redirect_server_domain(request, request.user)
short_domain_name = get_app_download_uri(request, request.user)
short = get_random_short()
if app_type == 'iOS':
upload_key = release_id + '.ipa' + settings.FILE_UPLOAD_TMP_KEY

Loading…
Cancel
Save