TIMGroupSetGroupAttributes
Introduction
Set group attributes
If the specified attribute does not exist, it will be appended to the group automatically.
Support all types of group types except Community group.
The upper limit amount for attributes is 16, with the limit of 32 bytes for each attribute keys, and 4k for each values.
The total limit for attributes, including keys and values, is 16K.
NULL
for json_keys
to delete all group attributes.
In addition to topics, group attributes support all group types
TIMGroupInitGroupAttributes, TIMGroupSetGroupAttributes, TIMGroupDeleteGroupAttributes together share the limits of calling frequency 5 times per 10 seconds. Once exceeded, it returns 8511 error code and the limits loose to 5 times per second. Once exceeded again, it returns 10049 error code.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
params | InitGroupAttributeParams | yes | Param of setting group attributes |
Returned template
Promise<commonResult<string>>
{
code: TIMResult | TIMErrCode;
desc?: string | undefined;
json_param?: string | undefined;
json_params?: string | undefined;
user_data?: string | undefined;
}
Return value details
name | type | description |
---|---|---|
code | TIMResult | TIMErrCode | Request result: Error codes. 0 means success. |
desc | string | undefined | The description of the error. It will be empty if success. |
json_param | string | undefined | Return value of calling API |
json_params | string | undefined | Return value of calling API. Compatible field, which is returned in some cases. |
user_data | string | undefined | ImSDK is responsible for transporting user-defined data without any processing |
Code example
import TimRender from "im_electron_sdk/dist/renderer";
const timRenderInstance = new TimRender();
import { GroupAttributes, InitGroupAttributeParams } from "im_electron_sdk/dist/interfaces";
let groupId = ''
let attributes: GroupAttributes = {
group_attribute_key: '', // required
group_attribute_value: '', // required
}
let param: InitGroupAttributeParams = {
groupId: groupId, // required
attributes: [attributes], // required
data: '' // optional
}
const { code } = await timRenderInstance.TIMGroupSetGroupAttributes(param)
if (code == 0) {
// success
}