添加审核 优化
Deploy dev / deploy (push) Successful in 1m2s

This commit is contained in:
Azmat@qq.com
2026-09-24 18:25:15 +08:00
parent 5dbb240b59
commit a84431c9c5
10 changed files with 334 additions and 48 deletions
+9 -4
View File
@@ -37,12 +37,15 @@ OTHER_REMOTE_GROUP_MESSAGE = "该素材组属于其他火山账号,请新建
def _serialize_asset(fa: FreeAsset) -> dict:
# 火山仍在审核的素材不能把 TOS 原始链接回传给浏览器。否则前端虽已禁选,
# 仍可能把未审核直链带入其它生成入口。审核通过后 poll 接口会再返回链接。
available = fa.status == FreeAsset.Status.ACTIVE
return {
"id": str(fa.id),
"name": fa.name,
"url": fa.url,
"url": fa.url if available else "",
"type": fa.asset_type.lower(),
"thumb_url": fa.thumbnail_url or (fa.url if fa.asset_type == FreeAsset.Type.IMAGE else ""),
"thumb_url": (fa.thumbnail_url or (fa.url if fa.asset_type == FreeAsset.Type.IMAGE else "")) if available else "",
"duration": fa.duration,
"status": fa.status,
"error_message": fa.error_message,
@@ -167,7 +170,9 @@ def _upload_asset_to_group(request, *, team, group: FreeAssetGroup, image_only:
if not group.thumbnail_url and fa.thumbnail_url:
group.thumbnail_url = fa.thumbnail_url
group.save(update_fields=["thumbnail_url", "updated_at"])
return Response({"group": _serialize_group(group), "asset": _serialize_asset(fa)}, status=status.HTTP_201_CREATED)
# 202 明确表示「已受理审核」而不是上传成功。只有轮询到 active 后,序列化结果
# 才会含可用于生成的 URL。
return Response({"group": _serialize_group(group), "asset": _serialize_asset(fa)}, status=status.HTTP_202_ACCEPTED)
class FreeAssetGroupListView(APIView):
@@ -263,7 +268,7 @@ class FreeAssetUploadView(APIView):
if group is None:
return Response({"detail": "素材组不存在"}, status=status.HTTP_404_NOT_FOUND)
response = _upload_asset_to_group(request, team=team, group=group)
if response.status_code == status.HTTP_201_CREATED:
if response.status_code in (status.HTTP_201_CREATED, status.HTTP_202_ACCEPTED):
response.data.pop("group", None)
return response