@@ -157,7 +157,10 @@ def reference_review_state(asset: Asset, *, require_registered: bool = False) ->
|
||||
火山素材 ID 并通过 asset:// 引用。普通直链会被生成接口按真人隐私素材直接拒绝。
|
||||
"""
|
||||
if not assets_client.is_enabled():
|
||||
# 审核整套机制没配置时不能拿它拦人,否则一关审核全平台引用都用不了
|
||||
# 平台自生成资产不依赖用户上传审核;用户上传则必须阻止,不能因为审核服务
|
||||
# 短暂不可用而把历史未审素材带进 Seedance。
|
||||
if asset.source == Asset.Source.UPLOAD:
|
||||
return "unavailable"
|
||||
return "allowed"
|
||||
if asset.review_status == "active" and (asset.review_remote_id or not require_registered):
|
||||
return "allowed"
|
||||
@@ -243,16 +246,22 @@ def ensure_review_drain_loop() -> None:
|
||||
def wait_upload_review(asset: Asset, *, timeout_s: float = 45.0, interval_s: float = 1.5) -> str:
|
||||
"""上传素材:立刻送审并等到终态。
|
||||
|
||||
返回 active / failed / processing(超时仍在审) / allowed(审核未启用)。
|
||||
审核未配置时不能拦上传,直接当 allowed。
|
||||
返回 active / failed / processing(超时仍在审) / unavailable(审核未启用或送审失败)。
|
||||
|
||||
用户上传的素材不能因为审核服务暂时不可用而被当作已通过。调用方应把
|
||||
unavailable 当作上传未完成处理,既不返回可引用链接,也不允许进入生成链路。
|
||||
"""
|
||||
if not assets_client.is_enabled():
|
||||
return "allowed"
|
||||
submit_asset_for_review(asset, force=True)
|
||||
return "unavailable"
|
||||
submitted = submit_asset_for_review(asset, force=True)
|
||||
asset.refresh_from_db()
|
||||
status = asset.review_status or ""
|
||||
if status in ("active", "failed"):
|
||||
return status
|
||||
# CreateAsset 失败时没有 remote id 可以轮询;此前会空等到超时后把上传误报为
|
||||
# 「审核中」。直接把真实的不可用状态交给上传接口,让用户可以重试。
|
||||
if not submitted and not asset.review_remote_id:
|
||||
return "unavailable"
|
||||
deadline = time.monotonic() + max(3.0, float(timeout_s))
|
||||
while time.monotonic() < deadline:
|
||||
status = poll_asset_review(asset) or ""
|
||||
|
||||
Reference in New Issue
Block a user