Class UserModule

  • All Implemented Interfaces:

    
    public final class UserModule
    
                        

    User 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.

    • Constructor Detail

    • 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 duration
        handler - Callback; on success error is null; 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 list
        handler - Callback; on success error is null; on failure, detail contains the list of failed user IDs
      • 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 query
        handler - 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 block
        handler - Error callback; null error 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 unblock
        handler - Error callback; null error 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 check
        handler - Callback returning true if the user is blocked, false otherwise
      • 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 modify
        handler - Callback; on success error is null; 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
      • 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 apply
        handler - Error callback; null error indicates 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 apply
        handler - Error callback; null error indicates 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 parameters
        handler - 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 time
        handler - Error callback; null error indicates success
      • acceptFriendApplication

         final Unit acceptFriendApplication(String userId, ErrorHandler handler)

        Accepts a friend request.

        Parameters:
        userId - The user ID of the applicant
        handler - Error callback; null error indicates success
      • refuseFriendApplication

         final Unit refuseFriendApplication(String userId, ErrorHandler handler)

        Rejects a friend request.

        Parameters:
        userId - The user ID of the applicant
        handler - Error callback; null error 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 update
        handler - Callback; on success error is null; 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 check
        handler - Callback returning the list of friend relationships 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 query
        handler - 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 keyword
        handler - Callback returning the list of matching friend details on success