93f47042d5
Made-with: Cursor
39 lines
1.4 KiB
Lua
39 lines
1.4 KiB
Lua
-- 压缩直传成功后向 Rust TS(3003)登记 IMAGE_FORM_COMPRESS,便于管理端 Tasks 可追溯(非 UPLOAD_PICTURE:后者专指 combine 管线)。
|
||
local cjson = require("cjson")
|
||
|
||
local function create(httpc, auth_header, sudoer_token, public_url)
|
||
local ts_host = ngx.var.huiwing_htyts_rust or "127.0.0.1:3003"
|
||
local remote_url = "http://" .. ts_host .. "/api/v1/ts/create_task"
|
||
local hty_host = ngx.req.get_headers()["HtyHost"] or ""
|
||
local body_tbl = {
|
||
task_type = "IMAGE_FORM_COMPRESS",
|
||
payload = {
|
||
url = public_url,
|
||
},
|
||
}
|
||
local body = cjson.encode(body_tbl)
|
||
local res, err = httpc:request_uri(remote_url, {
|
||
ssl_verify = false,
|
||
method = "POST",
|
||
headers = {
|
||
["Content-Type"] = "application/json",
|
||
["Authorization"] = auth_header or "",
|
||
["HtySudoerToken"] = sudoer_token or "",
|
||
["HtyHost"] = hty_host,
|
||
},
|
||
body = body,
|
||
})
|
||
if not res then
|
||
ngx.log(ngx.ERR, "IMAGE_FORM_COMPRESS audit: request failed ", err)
|
||
return false
|
||
end
|
||
if res.status ~= 201 and res.status ~= 200 then
|
||
ngx.log(ngx.ERR, "IMAGE_FORM_COMPRESS audit: status=", res.status, " body=", res.body)
|
||
return false
|
||
end
|
||
ngx.log(ngx.INFO, "IMAGE_FORM_COMPRESS audit task created")
|
||
return true
|
||
end
|
||
|
||
return { create = create }
|