Content Moderation sends asynchronous notifications with the results of machine-based and manual audits. To use or integrate this data, configure message notifications. This topic describes how to configure message notifications for OSS violation detection.
Concepts
Before you configure callback notifications, familiarize yourself with the following concepts.
Concept | Description |
callback URL | A callback URL is the server address that you configure on the Content Moderation console. It is typically the public address of your business server. The callback URL must meet the following requirements:
|
seed | The seed is used to verify that requests sent to your callback URL originate from the Content Moderation server. Note A seed is automatically generated after you configure message notifications on the console. |
Callback retries | When your server receives a callback message from Content Moderation, an HTTP status code of 200 indicates success. Any other HTTP status code indicates failure. If a delivery fails, the Content Moderation server retries sending the message up to three times or until it is successfully delivered. |
Callback data | Callback data is the content returned by the Content Moderation server to your configured callback URL. For details about the structure of the callback data, see Callback notification form data. |
Table 1. Callback notification form data
Parameter | Type | Description |
checksum | String | The checksum is generated by using the SHA256 algorithm on a string formed by concatenating Note To prevent tampering, when you receive a push result, you can generate a string by using the algorithm described above and verify it against the checksum. |
content | String | The JSON object is saved in a string format. You must parse it to convert it back into an object. For the structure of the content field after it is parsed, see Description of the content field structure. Note The structure of the content parameter differs between the Content Moderation API and OSS violation detection. |
Configure message notifications
Log on to the Content Moderation console.
In the left-side navigation pane, select .
On the OSS Violation Detection V1.0 page, click Message Notification.
On the Message Notification tab, click Add Notification.
In the Add Notification dialog box, configure the callback notification, and click OK.
The following table describes the parameters.
Parameter
Description
Plan name
Enter a name for the plan. The name can be up to 12 characters long and can contain Chinese characters, letters, digits, and underscores (_).
Callback URL
Enter the callback URL.
Encryption algorithm
Specifies the algorithm for encrypting the callback notification content. Content Moderation encrypts the response (a string that is a concatenation of
user UID + seed + content) by using the specified algorithm. The encrypted response is then sent to your callback notification URL. The encryption algorithms are classified into the following two types:SHA256 (Default): Uses the HMAC-SHA256 algorithm.
SM3: Uses the SM3 algorithm. A hexadecimal string consisting of lowercase letters and digits is returned.
For example, if the notification content is abc, the SM3-encrypted result is 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0.
Notification type
Select the types of scan results that trigger callback notifications. You can select multiple types. The following options are available:
Machine audit result
Manual audit result
Audit result
Select the audit results that trigger callback notifications. You can select multiple results. The following options are available:
Confirmed Violation
Suspected Violation
Normal
After you complete the configuration, the system automatically generates a seed. The seed is used to verify that requests to your callback URL originate from Alibaba Cloud. Save the generated seed for use in your applications.
Content field structure
After you enable callback notifications, Content Moderation sends OSS violation detection notifications based on your configuration. These notifications include the content form data. The following table describes the structure of the content field.
Table 2. Structure of the content form field
Parameter | Type | Required | Description |
bucket | String | Yes | The name of the OSS bucket. |
object | String | Yes | The name of the OSS object. |
stock | Boolean | Yes | Indicates whether the content is historical data. Valid values:
|
region | String | Yes | The region where the OSS object is stored. |
freezed | Boolean | Yes | Indicates whether the content is frozen, which prevents public access. Valid values:
|
scanResult | JSONObject | No | The scan result. The structure varies depending on the object type (image or video).
|
auditResult | JSONObject | No | The manual audit result. This field is returned only after you perform a manual audit. For details about the structure, see auditResult. Note This field is returned only if you select Manual audit result for Notification type. |
Table 3. auditResult parameters
Parameter | Type | Required | Description |
suggestion | String | Yes | The manual audit result. Valid values:
|
resourceStatus | Integer | Yes | The status of the object after manual audit. Valid values:
|
Example of the content field
{
"bucket": "xxxxb",
"freezed": false,
"object": "xxx.jpg",
"region": "cn-hangzhou",
"scanResult": {
"code": 200,
"dataId": "5C919E2FBD6CD6940D4A8B46",
"msg": "OK",
"results": [
{
"label": "porn",
"rate": 100.0,
"scene": "porn",
"suggestion": "block"
},
{
"label": "normal",
"rate": 99.6,
"scene": "terrorism",
"suggestion": "pass"
}
],
"taskId": "img1ZxzVQUuAz36scZEjyGXzx-1qpzhY"
},
"auditResult": {
"resoureStatus": 2,
"suggestion": "pass"
},
"stock": false
}Next steps
After you configure message notifications, you can use the incremental scan and full scan features of OSS violation detection. For more information, see Set Incremental Scan Tasks and Create Full Scan Tasks.
If you want detection results to be more aligned with your business needs, you can use a custom image library to specifically block, allow, or manually review images to meet unexpected content moderation requirements. For more information, see Configure a risk database.