feat(htyproc): IMAGE_FORM_COMPRESS task posts form_image_compress_audit to ai-api
Made-with: Cursor
This commit is contained in:
@@ -247,6 +247,9 @@ async fn run_one(
|
||||
TaskType::VideoCompression => {
|
||||
tasks::run_video_compression_task(rt, sudo, host, &mut req).await
|
||||
}
|
||||
TaskType::ImageFormCompress => {
|
||||
tasks::run_image_form_compress_task(rt, sudo, host, &mut req).await
|
||||
}
|
||||
TaskType::Noop | TaskType::TestUpyunRemove => Ok(()),
|
||||
};
|
||||
match &res {
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
mod pipelines;
|
||||
|
||||
pub use pipelines::{
|
||||
run_ai_score_task, run_audio_file_ai_score_task, run_video_compression_task, run_watermark_task,
|
||||
run_ai_score_task, run_audio_file_ai_score_task, run_image_form_compress_task,
|
||||
run_video_compression_task, run_watermark_task,
|
||||
};
|
||||
|
||||
@@ -39,6 +39,46 @@ pub async fn run_ai_score_task(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `IMAGE_FORM_COMPRESS`:压缩直传已在 ngx 完成;此处仅向 ai-api 登记 URL(日志/后续扩展),不重跑压缩。
|
||||
pub async fn run_image_form_compress_task(
|
||||
rt: &Arc<ProcessorRuntime>,
|
||||
sudo: &str,
|
||||
host: &str,
|
||||
req: &mut ReqTask,
|
||||
) -> anyhow::Result<()> {
|
||||
let ts_tid = req.task_id.as_deref().unwrap_or("");
|
||||
let raw = req
|
||||
.payload
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow::anyhow!("missing payload"))?;
|
||||
let public_url = raw
|
||||
.get("url")
|
||||
.and_then(|v| v.as_str())
|
||||
.filter(|s| !s.is_empty())
|
||||
.ok_or_else(|| anyhow::anyhow!("IMAGE_FORM_COMPRESS: missing payload.url"))?;
|
||||
let hint: String = public_url.chars().take(120).collect();
|
||||
let base = rt.ai_url.trim_end_matches('/');
|
||||
let url = format!("{base}/api/v1/ai/form_image_compress_audit");
|
||||
tracing::debug!(
|
||||
ts_task_id = %ts_tid,
|
||||
endpoint = %url,
|
||||
url_prefix = %hint,
|
||||
"IMAGE_FORM_COMPRESS: POST ai-api audit",
|
||||
);
|
||||
let body = json!({ "url": public_url });
|
||||
let resp = rt
|
||||
.http
|
||||
.post(&url)
|
||||
.header("HtySudoerToken", sudo)
|
||||
.header("HtyHost", host)
|
||||
.json(&body)
|
||||
.send()
|
||||
.await?;
|
||||
parse_hty_response(resp).await?;
|
||||
tracing::debug!(ts_task_id = %ts_tid, "IMAGE_FORM_COMPRESS: ai-api audit ok");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn run_watermark_task(
|
||||
rt: &Arc<ProcessorRuntime>,
|
||||
sudo: &str,
|
||||
|
||||
Reference in New Issue
Block a user