Skip to content

Commit

Permalink
Merge pull request #160 from tencentyun/feature_wqingzhang_5f8244a4
Browse files Browse the repository at this point in the history
批量图片审核增加 timeout 参数&图片处理参数头部签名
  • Loading branch information
Huberyxiao authored Apr 22, 2024
2 parents e178f03 + ae7a17b commit 80c770f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions include/request/auditing_req.h
Original file line number Diff line number Diff line change
Expand Up @@ -2784,6 +2784,11 @@ class Conf {
m_mask = m_mask | 0x00000200u;
m_freeze = freeze;
}

void SetTimeout(const int timeout) {
m_mask = m_mask | 0x00000400u;
m_timeout = timeout;
}

std::string GetBizType() const { return m_biz_type;}

Expand All @@ -2803,6 +2808,8 @@ class Conf {

Freeze GetFreeze() const { return m_freeze; }

int GetTimeout() const { return m_timeout; }

bool HasBizType() const { return (m_mask & 0x00000001u) != 0; }

bool HasDetectType() const { return (m_mask & 0x00000002u) != 0;}
Expand All @@ -2819,7 +2826,9 @@ class Conf {

bool HasAsync() const { return (m_mask & 0x00000080u) != 0; }

bool HasFreeze() const { return (m_mask & 0x00000020u) != 0; }
bool HasFreeze() const { return (m_mask & 0x00000200u) != 0; }

bool HasTimeout() const { return (m_mask & 0x00000400u) != 0; }

std::string to_string() const {
std::stringstream ss;
Expand All @@ -2831,7 +2840,8 @@ class Conf {
<< ", detect_content: " << m_detect_content
<< ", return_highlight_html: " << m_return_highlight_html
<< ", async: " << m_async
<< ", freeze: " << m_freeze.to_string();
<< ", freeze: " << m_freeze.to_string()
<< ", timeout: " << m_timeout;
return ss.str();
}

Expand All @@ -2846,6 +2856,7 @@ class Conf {
bool m_return_highlight_html; // 网页审核时,是否需要高亮网页耶的违规文本
int m_async; // 是否异步进行审核,0:同步返回结果,1:异步进行审核。默认值为 0。
Freeze m_freeze; // 可通过该字段,设置根据审核结果给出的不同分值,对图片进行自动冻结,仅当input中审核的图片为object时有效
int m_timeout; // 通过该参数可设置请求的超时时间。参数有效值为大于等于0的整数,单位为毫秒,0表示不限制时间,默认值为0
};

class GetImageAuditingReq : public ObjectReq {
Expand Down
5 changes: 5 additions & 0 deletions src/request/auditing_req.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ bool BatchImageAuditingReq::GenerateRequestBody(std::string* body) const {
rapidxml::node_element, "PornScore",
doc.allocate_string((std::to_string(m_conf.GetFreeze().GetPornSocre()).c_str()))));
}
if (m_conf.HasTimeout()) {
conf_node->append_node(doc.allocate_node(
rapidxml::node_element, "Timeout",
doc.allocate_string((std::to_string(m_conf.GetTimeout()).c_str()))));
}
root_node->append_node(conf_node);

rapidxml::print(std::back_inserter(*body), doc, 0);
Expand Down

0 comments on commit 80c770f

Please sign in to comment.