Class UserModule
-
- All Implemented Interfaces:
public final class UserModuleUser feature module.
Provides user-related features including subscription event management, online status queries, user profile management, friend management, and friend applications.
This is a singleton class. Obtain the instance via ai.nexconn.chat.NCEngine.userModule.
-
-
Method Summary
Modifier and Type Method Description final UnitsubscribeEvent(SubscribeEventParams params, ErrorDetailHandler<List<String>> handler)Subscribes to user status events. final UnitunsubscribeEvent(UnsubscribeEventParams params, ErrorDetailHandler<List<String>> handler)Unsubscribes from user status events. final UnitgetSubscribeEvent(GetSubscribeEventParams params, OperationHandler<List<SubscriptionStatusInfo>> handler)Queries current subscription event status. final SubscribeQuerycreateSubscribeQuery(SubscribeQueryParams params)Creates a paginated query object for subscription events. final UnitgetSubscribeUsersOnlineStatus(List<String> userIds, OperationHandler<List<UserOnlineStatus>> handler)Batch queries the online status of subscribed users. final UnitaddToBlocklist(String userId, ErrorHandler handler)Adds a user to the block list. final UnitgetBlocklist(OperationHandler<List<String>> handler)Gets the current user's block list. final UnitremoveFromBlocklist(String userId, ErrorHandler handler)Removes a user from the block list. final UnitcheckBlocked(String userId, OperationHandler<Boolean> handler)Checks whether a specified user is in the block list. final UnitupdateMyUserProfile(UserProfile profile, ErrorDetailHandler<List<String>> handler)Updates the current user's profile. final UnitgetUserProfiles(List<String> userIds, OperationHandler<List<UserProfile>> handler)Batch retrieves user profiles. final UnitgetMyUserProfile(OperationHandler<UserProfile> handler)Gets the current user's profile. final UnitupdateMyUserProfileVisibility(UserProfileVisibility visibility, ErrorHandler handler)Updates the current user's profile visibility. final UnitgetMyUserProfileVisibility(OperationHandler<UserProfileVisibility> handler)Gets the current user's profile visibility setting. final UnitsetFriendAddPermission(FriendAddPermission permission, ErrorHandler handler)Sets the friend request permission. final UnitgetFriendAddPermission(OperationHandler<FriendAddPermission> handler)Gets the current friend request permission setting. final UnitaddFriend(AddFriendParams params, OperationHandler<Integer> handler)Sends a friend request. final UnitdeleteFriends(List<String> userIds, ErrorHandler handler)Deletes friends in batch. final UnitacceptFriendApplication(String userId, ErrorHandler handler)Accepts a friend request. final UnitrefuseFriendApplication(String userId, ErrorHandler handler)Rejects a friend request. final UnitsetFriendInfo(SetFriendInfoParams params, ErrorDetailHandler<List<String>> handler)Sets friend info (e.g., remark name, extended profile). final UnitcheckFriends(List<String> userIds, OperationHandler<List<FriendRelation>> handler)Checks friend relationships with specified users. final UnitgetFriends(OperationHandler<List<FriendDetail>> handler)Gets the friend list. final FriendApplicationsQuerycreateFriendApplicationsQuery(FriendApplicationsQueryParams params)Creates a paginated query object for friend applications. final UnitgetFriendsInfo(List<String> userIds, OperationHandler<List<FriendDetail>> handler)Batch retrieves friend info. final UnitsearchFriendsInfo(String name, OperationHandler<List<FriendDetail>> handler)Searches for friends by name. -
-
Method Detail
-
subscribeEvent
final Unit subscribeEvent(SubscribeEventParams params, ErrorDetailHandler<List<String>> handler)
Subscribes to user status events.
When a subscribed user's status changes, the registered event handler will be notified.
- Parameters:
params- Subscription parameters including event type, user list, and expiry durationhandler- Callback; on success error isnull; on failure, detail contains the list of failed user IDs
-
unsubscribeEvent
final Unit unsubscribeEvent(UnsubscribeEventParams params, ErrorDetailHandler<List<String>> handler)
Unsubscribes from user status events.
- Parameters:
params- unsubscribeEvent parameters including event type and user listhandler- Callback; on success error isnull; on failure, detail contains the list of failed user IDs
-
getSubscribeEvent
final Unit getSubscribeEvent(GetSubscribeEventParams params, OperationHandler<List<SubscriptionStatusInfo>> handler)
Queries current subscription event status.
Retrieves all currently active subscription info.
- Parameters:
params- Query parameters; can specify event type and user listhandler- Callback returning the list of subscription info on success
-
createSubscribeQuery
final SubscribeQuery createSubscribeQuery(SubscribeQueryParams params)
Creates a paginated query object for subscription events.
Returns a SubscribeQuery object. Use SubscribeQuery.loadNextPage to load data page by page.
- Parameters:
params- Query parameters including subscription type and page size- Returns:
A paginated query object
-
getSubscribeUsersOnlineStatus
final Unit getSubscribeUsersOnlineStatus(List<String> userIds, OperationHandler<List<UserOnlineStatus>> handler)
Batch queries the online status of subscribed users.
Requires the "Friend Online Status Change Notification" feature to be enabled.
- Parameters:
userIds- List of user IDs to queryhandler- Callback returning the list of user online statuses on success
-
addToBlocklist
final Unit addToBlocklist(String userId, ErrorHandler handler)
Adds a user to the block list.
Blocked users will be unable to send messages to the current user.
- Parameters:
userId- The user ID to blockhandler- Error callback;nullerror indicates success
-
getBlocklist
final Unit getBlocklist(OperationHandler<List<String>> handler)
Gets the current user's block list.
- Parameters:
handler- Callback returning the list of blocked user IDs on success
-
removeFromBlocklist
final Unit removeFromBlocklist(String userId, ErrorHandler handler)
Removes a user from the block list.
- Parameters:
userId- The user ID to unblockhandler- Error callback;nullerror indicates success
-
checkBlocked
final Unit checkBlocked(String userId, OperationHandler<Boolean> handler)
Checks whether a specified user is in the block list.
- Parameters:
userId- The user ID to checkhandler- Callback returningtrueif the user is blocked,falseotherwise
-
updateMyUserProfile
final Unit updateMyUserProfile(UserProfile profile, ErrorDetailHandler<List<String>> handler)
Updates the current user's profile.
It is recommended to fetch the latest profile first and update on top of it.
- Parameters:
profile- Update parameters containing the fields to modifyhandler- Callback; on success error isnull; on failure, detail contains the list of failed field keys
-
getUserProfiles
final Unit getUserProfiles(List<String> userIds, OperationHandler<List<UserProfile>> handler)
Batch retrieves user profiles.
- Parameters:
userIds- List of user IDs to query (max 20 per request)handler- Callback returning the list of user profiles on success
-
getMyUserProfile
final Unit getMyUserProfile(OperationHandler<UserProfile> handler)
Gets the current user's profile.
- Parameters:
handler- Callback returning the current user's profile info on success
-
updateMyUserProfileVisibility
final Unit updateMyUserProfileVisibility(UserProfileVisibility visibility, ErrorHandler handler)
Updates the current user's profile visibility.
Controls the visibility scope of the user's profile to other users.
- Parameters:
visibility- The visibility setting to applyhandler- Error callback;nullerror indicates success
-
getMyUserProfileVisibility
final Unit getMyUserProfileVisibility(OperationHandler<UserProfileVisibility> handler)
Gets the current user's profile visibility setting.
- Parameters:
handler- Callback returning the current visibility setting on success
-
setFriendAddPermission
final Unit setFriendAddPermission(FriendAddPermission permission, ErrorHandler handler)
Sets the friend request permission.
Controls whether other users can send friend requests to the current user, and under what conditions.
- Parameters:
permission- The permission setting to applyhandler- Error callback;nullerror indicates success
-
getFriendAddPermission
final Unit getFriendAddPermission(OperationHandler<FriendAddPermission> handler)
Gets the current friend request permission setting.
- Parameters:
handler- Callback returning the current friend request permission setting on success
-
addFriend
final Unit addFriend(AddFriendParams params, OperationHandler<Integer> handler)
Sends a friend request.
Usage example:
val params = AddFriendParams("userId").apply { extra = "Hello, please add me as a friend" } NCEngine.user.addFriend(params) { resultCode, error -> if (error == null) { // Request sent successfully; resultCode is the operation result code } }- Parameters:
params- Friend request parametershandler- Callback returning the operation result code on success
-
deleteFriends
final Unit deleteFriends(List<String> userIds, ErrorHandler handler)
Deletes friends in batch.
This is a bidirectional deletion: the friend is removed from both parties' friend lists.
- Parameters:
userIds- List of user IDs to delete, max 100 at a timehandler- Error callback;nullerror indicates success
-
acceptFriendApplication
final Unit acceptFriendApplication(String userId, ErrorHandler handler)
Accepts a friend request.
- Parameters:
userId- The user ID of the applicanthandler- Error callback;nullerror indicates success
-
refuseFriendApplication
final Unit refuseFriendApplication(String userId, ErrorHandler handler)
Rejects a friend request.
- Parameters:
userId- The user ID of the applicanthandler- Error callback;nullerror indicates success
-
setFriendInfo
final Unit setFriendInfo(SetFriendInfoParams params, ErrorDetailHandler<List<String>> handler)
Sets friend info (e.g., remark name, extended profile).
Usage example:
val params = SetFriendInfoParams("userId").apply { remark = "Friend remark name" extProfile = mapOf("key1" to "value1") } NCEngine.user.setFriendInfo(params) { errorKeys, error -> if (error == null) { // Set successfully } else { // Set failed; errorKeys contains the list of failed field keys } }- Parameters:
params- Parameters specifying the friend info to updatehandler- Callback; on success error isnull; on failure, detail contains the list of failed field keys
-
checkFriends
final Unit checkFriends(List<String> userIds, OperationHandler<List<FriendRelation>> handler)
Checks friend relationships with specified users.
Queries the friend relationship type between the current user and the specified users.
- Parameters:
userIds- List of user IDs to checkhandler- Callback returning the list of friend relationships on success
-
getFriends
final Unit getFriends(OperationHandler<List<FriendDetail>> handler)
Gets the friend list.
- Parameters:
handler- Callback returning the list of friend details on success
-
createFriendApplicationsQuery
final FriendApplicationsQuery createFriendApplicationsQuery(FriendApplicationsQueryParams params)
Creates a paginated query object for friend applications.
Returns a FriendApplicationsQuery object. Use FriendApplicationsQuery.loadNextPage to load data page by page, and FriendApplicationsQuery.hasMore to check if more data is available.
Usage example:
val params = FriendApplicationsQueryParams().apply { count = 20 types = listOf(FriendApplicationType.RECEIVED) statuses = listOf(FriendApplicationStatus.UN_HANDLED) } val query = NCEngine.user.createFriendApplicationsQuery(params) query.loadNextPage { list, error -> if (error == null && list != null) { list.forEach { app -> println("${app.userId}: ${app.applicationStatus}") } } if (query.hasMore) { query.loadNextPage { nextList, nextError -> // Handle next page data } } }- Parameters:
params- Paginated query parameters- Returns:
A paginated query object
-
getFriendsInfo
final Unit getFriendsInfo(List<String> userIds, OperationHandler<List<FriendDetail>> handler)
Batch retrieves friend info.
- Parameters:
userIds- List of user IDs to queryhandler- Callback returning the list of friend details on success
-
searchFriendsInfo
final Unit searchFriendsInfo(String name, OperationHandler<List<FriendDetail>> handler)
Searches for friends by name.
- Parameters:
name- The search keywordhandler- Callback returning the list of matching friend details on success
-
-
-
-