Relationship Chain Management
Contacts System Overview
Chat can host user contacts and offers a complete set of contacts solutions. If you do not want to develop or maintain friend relationship features for your app users but need features like adding and deleting friends, then you should use Chat's contacts hosting service.
Chat can store contacts, ensuring that your data has disaster recovery, multi-region deployment, and auto-scaling capabilities. This frees you from complex processing flows, such as server downtime, multi-copy primary-secondary replication, and scaling.
Chat provides business processing flows that are commonly used in the industry, with which you do not have to worry about contacts logic.
Chat provides professional operations processes and teams, ensuring 99.99% annual service quality stability and helping you offer stable services.
Chat provides easy-to-use service APIs and easy-to-access guidelines, with premium services throughout the whole process.
Contacts are a set of data used to describe the relationships between one user and other users. The contacts supported by Chat include friend lists and blocklists.
Relationship Chain Fields
The Chat contacts system supports standard and custom contacts fields. Contacts fields have the following characteristics:
Contacts fields are displayed in key-value format.
Key is in string format, and its name can only contain uppercase and lowercase letters, numbers, and underscores.
Value has the following types:
a. An integer of uint64_t type (not supported for custom contacts fields)
b. A string of string type (string length cannot exceed 500 bytes)
c. A buffer of bytes type (buffer length cannot exceed 500 bytes)
d. A string array of string type (the length of each string cannot exceed 500 bytes, and this type is used only for the
Tag_SNS_IM_Group
field of a friend list)Contacts
Users can add up to 3,000 friends to their contacts in Chat.
Contacts support standard friend fields and custom friend fields.
Standard friend fields
Currently, Chat supports the following standard friend fields:
Field | Type | Description |
Tag_SNS_IM_Group | Array | Friend list:1. A maximum of 32 lists are supported.2. The list name cannot be empty.3. The length of a list name cannot exceed 30 bytes.4. One friend can be added to multiple lists. |
Tag_SNS_IM_Remark | String | Remark: The length of a remark cannot exceed 96 bytes. |
Tag_SNS_IM_AddSource | String | Source from which a friend is added:1. The source field contains a prefix and keyword.2. The prefix of the source field is AddSource_Type_ .3. Keyword: It must be a combination of letters with no more than 8 bytes. We recommend that you use an English word or its abbreviation.4. Example: If the source keyword is Android, the source field is AddSource_Type_Android |
Tag_SNS_IM_AddWording | String | Request content: The length of a request cannot exceed 256 bytes. |
Tag_SNS_IM_AddTime | Integer | Timestamp of adding friends. |
Custom friend fields
Custom friend fields are the friend data set by each app based on its own business needs. By using custom friend fields, an app can add additional data to friends and perform read and write operations through existing APIs.
To apply for custom friend fields, the app admin can log in to the Chat console and select App Configuration > Feature Configuration. After the application is submitted, custom friend fields will take effect in 5 minutes.
The naming requirements for custom friend fields are as follows:
The name of a custom friend field has two parts: prefix and keyword.
The prefix of a custom friend field is
Tag_SNS_Custom
.Keyword: The keyword must be a string of letters with a length no more than 8 bytes. We recommend that you use an English word or its abbreviation as the keyword.
Example: If the custom friend field to be applied for by an app has the keyword
Test
, the name of the custom friend field is Tag_SNS_Custom_Test
.When applying for custom friend fields, you need to submit the following information for each custom friend field:
The name of the custom friend field (Key).
The type of the custom friend field (Value). For more information, see Relationship Chain Fields.
Adding friends
Chat supports the following modes for adding friends: adding friends in batches, no approval required, and approval required. For more information, see Adding Friends.
Two-way friends: user A is a friend of user B, and user B is a friend of user A.
One-way friend: user A is a friend of user B, but user B is not a friend of user A.
Verification method for adding friends: Each user can choose the way with which he/she is added as a friend by another user. For more information, see the verification method field for adding friends in Standard Profile Fields.
No approval required: If the approval method for friend requests set by account A is
AllowType_Type_AllowAny
, then anyone who wants to add account A as a friend can directly add account A. In this scenario, there is one step in the friend request and acceptance process.
Approval required: If the approval method for friend requests set by account A is AllowType_Type_NeedConfirm
, then for anyone who wants to add account A as a friend, account A will receive a message asking whether to approve the new friend request. Then, account A accepts or rejects the request to complete the process. In this scenario, there are two steps in the friend request and acceptance process.Deleting friends
Chat supports two modes for deleting friends: one-way deletion and two-way deletion.
Deletion Mode | DeleteType | Description |
One-way deletion | Delete_Type_Single | To_Account is deleted from the contacts of From_Account , but From_Account is not deleted from the contacts of To_Account . |
Two-way deletion | Delete_Type_Both | To_Account is deleted from the contacts of From_Account , and From_Account is deleted from the contacts of To_Account . |
Verifying friends
Chat supports two friend verification modes: one-way friend verification and two-way friend verification.
Verification Mode | CheckType | Description |
One-way friend verification | CheckResult_Type_Single | This is used to check whether To_Account is in the contact of From_Account , but does not check whether From_Account is in the contact of To_Account . |
Two-way friend verification | CheckResult_Type_Both | This is used to check whether To_Account is in the contact of From_Account and also whether From_Account is in the contact of To_Account . |
Possible results of one-way friend verification are:
Relation | Description |
CheckResult_Type_NoRelation | To_Account is not in the contact of From_Account , but it cannot determine whether From_Account is in the contact of To_Account . |
CheckResult_Type_AWithB | To_Account is in the contact of From_Account , but it cannot determine whether From_Account is in the contact of To_Account . |
Possible results of two-way friend verification are:
Relation | Description |
CheckResult_Type_BothWay | To_Account is in the contact of From_Account , and From_Account is in the contact of To_Account . |
CheckResult_Type_AWithB | To_Account is in the contact of From_Account , but From_Account is not in the contact of To_Account . |
CheckResult_Type_BWithA | To_Account is not in the contact of From_Account , but From_Account is in the contact of To_Account . |
CheckResult_Type_NoRelation | To_Account is not in the contact of From_Account , and From_Account is not in the contact of To_Account . |
Blocklists
Each user has a blocklist, which is used to store the accounts blocked by this user.
After user A adds user B to the blocklist, user A will unfriend user B (if they are friends), and users A and B cannot send friend requests to each other in the future.
Each user can add up to 1,000 accounts to their Chat blocklist.
Adding users to a blocklist
Chat allows you to add multiple users to a blocklist at a time. For more information, see Blocklisting Users .
Removing users from a blocklist
Chat allows you to remove multiple users from a blocklist at a time. For more information, see Unblocklisting Users .
Pulling a blocklist
Verifying a blocklist
Chat supports two blocklist verification modes: one-way verification and two-way verification.
Verification Mode | CheckType | Description |
One-way verification | BlackCheckResult_Type_Single | This is used to check whether To_Account is in the blocklist of From_Account , but not check whether From_Account is in the blocklist of To_Account . |
Two-way verification | BlackCheckResult_Type_Both | This is used not only to check whether To_Account is in the blocklist of From_Account , but also to check whether From_Account is in the blocklist of To_Account . |
Possible results of one-way blocklist relationship verification are:
Relation | Description |
BlackCheckResult_Type_AWithB | To_Account is in the blocklist of From_Account , but it cannot determine whether From_Account is in the blocklist of To_Account . |
BlackCheckResult_Type_NO | To_Account is not in the blocklist of From_Account , but it cannot determine whether From_Account is in the blocklist of To_Account . |
Possible results of two-way blocklist relationship verification are:
Relation | Description |
BlackCheckResult_Type_BothWay | To_Account is in the blocklist of From_Account , and From_Account is also in the blocklist of To_Account . |
BlackCheckResult_Type_AWithB | To_Account is in the blocklist of From_Account , but From_Account is not in the blocklist of To_Account . |
BlackCheckResult_Type_BWithA | To_Account is not in the blocklist of From_Account , but From_Account is in the blocklist of To_Account . |
BlackCheckResult_Type_NO | To_Account is not in the blocklist of From_Account , and From_Account is not in the blocklist of To_Account . |