Global mute
With increasingly strict rules and regulations on app compliance, content supervision has become a crucial part of the app lifecycle. To meet this need, Chat provides the global-mute feature, which enables you to mute any user ID in one-to-one chats, group chats, or chat rooms, preventing these users from sending messages to other chat users, chat groups, or chat rooms. When global-mute expires, the chat server automatically unmutes the user ID, and this user resumes the privilege of sending messages.
This feature can be widely applied in apps that power real-time engagements. For example, if a user frequently sends illegitimate advertisements to multiple chat rooms, you can use global-mute to prevent this user from sending chat room messages for 15 days; if a user makes improper statements concerning politics, global-mute can permanently prevent this user from sending any messages in one-to-one chats, chat groups, or chat rooms.
Before calling the following methods, make sure you understand the call frequency limit of the Chat RESTful APIs as described in Limitations.
Common parameters
The following table lists common request and response parameters of the Chat RESTful APIs:
Request parameters
Parameter | Type | Description | Required |
---|---|---|---|
host | String | The domain name assigned by the Chat service to access RESTful APIs. For how to get the domain name, see Get the information of your project. | Yes |
org_name | String | The unique identifier assigned to each company (organization) by the Chat service. For how to get the org name, see Get the information of the Chat project. | Yes |
app_name | String | The unique identifier assigned to each app by the Chat service. For how to get the app name, see Get the information of the Chat project. | Yes |
username | String | The unique login account of the user. The user ID must be 64 characters or less and cannot be empty. The following character sets are supported:
| Yes |
Response parameters
Parameter | Type | Description |
---|---|---|
action | String | The request method. |
organization | String | The unique identifier assigned to each company (organization) by the Chat service. This is the same as org_name . |
application | String | A unique internal ID assigned to each app by the Chat service. You can safely ignore this parameter. |
applicationName | String | The unique identifier assigned to each app by the Chat service . This is the same as app_name . |
uri | String | The request URI. |
path | String | The request path, which is part of the request URL. You can safely ignore this parameter. |
data | JSON | The response details. |
timestamp | Number | The Unix timestamp (ms) of the HTTP response. |
duration | Number | The duration (ms) from when the HTTP request is sent to the time the response is received. |
Authorization
Chat RESTful APIs require Bearer HTTP authentication. Every time an HTTP request is sent, the following Authorization
field must be filled in the request header:
In order to improve the security of the project, Agora uses a token (dynamic key) to authenticate users before they log in to the chat system. Chat RESTful APIs only support authenticating users using app tokens. For details, see Authentication using App Token.
Globally mute a specified user
This method mutes a specified user in one-to-one chats, chat groups, or chat rooms. After a successful method call, this user can no longer send messages in one-to-one chats, chat groups, or chat rooms, depending on your settings in the request parameter.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For parameters and the detailed descriptions, see Common parameters.
Request parameter
Parameter | Type | Required | Description |
---|---|---|---|
username | String | Yes | The user ID that you want to globally mute. |
chat | Number | No | The amount of time to mute this user ID in one-to-one chats, in seconds. The maximum value is 2,147,483,647.
|
groupchat | Number | No | The amount of time to mute this user in group chats, in seconds. The maximum value is 2,147,483,647.
|
chatroom | Number | No | The amount of time to mute this user in chat rooms, in seconds. The maximum value is 2,147,483,647.
|
Request header
Parameter | Type | Description |
---|---|---|
Content-Type | String | The content type. Set is as application/json . |
Authorization | String | The authentication token of the user or admin, in the format of Bearer ${YourAppToken} , where Bearer is a fixed character, followed by an English space, and then the obtained token value. |
HTTP response
If the returned HTTP status code is 200
, the request succeeds, and the response body contains the following fields:
Parameter | Type | Description |
---|---|---|
result | String | The result of this method call. ok means that global-mute is successfully enabled. |
For other fields and detailed descriptions, see Common parameters.
If the returned HTTP status code is not 200
, the request fails. You can refer to Status codes for possible reasons.
Example
Request example
Reponse example
Query the detailed information of global-mute
This method queries the detailed information of the global-mute settings of the specified user in one-to-one chats, group chats, or chatrooms.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
Parameter | Type | Required | Description |
---|---|---|---|
username | String | Yes | The user ID whose global-mute settings you want to query. |
For other parameters and the detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description |
---|---|---|
Content-Type | String | The content type. Set is as application/json . |
Authorization | String | The authentication token of the user or admin, in the format of Bearer ${YourAppToken} , where Bearer is a fixed character, followed by an English space, and then the obtained token value. |
HTTP response
If the returned HTTP status code is 200
, the request succeeds, and the response body contains the following fields:
Parameter | Type | Description |
---|---|---|
userid | String | The user ID whose global-mute settings you want to query. |
chat | Number | The remaining time that this user is muted in one-to-one chats, in seconds. The maximum value is 2,147,483,647.
|
groupchat | Number | The remaining time that this user is muted in group chats, in seconds. The maximum value is 2,147,483,647.
|
chatroom | Number | The remaining time that this user is muted in group rooms, in seconds. The maximum value is 2,147,483,647.
|
unixtime | Number | The Unix timestamp of the current operation. |
For other fields and detailed descriptions, see Common parameters.
If the returned HTTP status code is not 200
, the request fails. You can refer to Status codes for possible reasons.
Example
Request example
Response example
Retrieve all globally muted users
This method retrieves all the users that have been globally muted in the app, and returns the remaining time that each user is muted for each type of chat.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For parameters and the detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description |
---|---|---|
Content-Type | String | The content type. Set is as application/json . |
Authorization | String | The authentication token of the user or admin, in the format of Bearer ${YourAppToken} , where Bearer is a fixed character, followed by an English space, and then the obtained token value. |
Query parameter
Parameter | Type | Required | Description |
---|---|---|---|
pageNum | Number | No | The number of pages for querying the globally muted users in the app. |
pageSize | Number | No | The number of data entries on each page. The value range is [1,50]. |
HTTP response
If the returned HTTP status code is 200
, the request succeeds, and the response body contains the following fields:
Parameter | Type | Description |
---|---|---|
username | String | The user ID whose global-mute settings you want to query. |
chat | Number | The remaining time that this user is muted in one-to-one chats, in seconds. The maximum value is 2,147,483,647.
|
groupchat | Number | The remaining time that this user is muted in group chats, in seconds. The maximum value is 2,147,483,647.
|
chatroom | Number | The remaining time that this user is muted in group rooms, in seconds. The maximum value is 2,147,483,647.
|
unixtime | Number | The Unix timestamp of the current operation. |
For other fields and detailed descriptions, see Common parameters.
If the returned HTTP status code is not 200
, the request fails. You can refer to Status codes for possible reasons.
Example
Request example
Response example
Status codes
For details, see HTTP Status Codes.