Skip to main content

Get Blocked Users

The getBlockedUsers() function retrieves a list of users that have been blocked by a specific user. It utilizes the GetBlockedUsersRequest model to specify the user whose blocked list is being requested and returns a LMResponse<GetBlockedUsersResponse>.

Steps to Get Blocked Users List

  1. Build a GetBlockedUsersRequest object using the GetBlockedUsersRequestBuilder class.
  2. Call the getBlockedUsers() function using an instance of the LMFeedClient class.
  3. Use the response (LMResponse<GetBlockedUsersResponse>) as per your requirement.
// Build the request object
// USER_UUID: ID of the user blocked list is being fetched for
GetBlockedUsersRequest request = (GetBlockedUsersRequestBuilder()
..userUUID("USER_UUID")) // Replace with the actual user UUID
.build();

// Get the response from calling the function
LMResponse<GetBlockedUsersResponse> response = await client.getBlockedUsers(request);

// Process the response, as per requirement
if (response.success) {
// Your function to handle successful retrieval of blocked users
handleBlockedUsers(response.data);
} else {
// Your function to handle error message
handleError(response.errorMessage);
}

Get Blocked User State

To check if a user is blocked, consider the following code snippet

// Build the request object
// USER_UUID: ID of the user blocked list is being fetched for
GetBlockedUsersRequest request = (GetBlockedUsersRequestBuilder()
..userUUID("USER_UUID")) // Replace with the actual user UUID
.build();

LMResponse<GetBlockedUsersResponse> response =
await client.getBlockedUsers(request);

List<User> blockedUsers = response.data?.blockedUsers ?? [];

// BLOCKED_USER_ID: ID of the user being searched in the blocked list
int index = blockedUsers
.indexWhere((user) => user.sdkClientInfo.uuid == "BLOCKED_USER_ID"); // Replace with the actual user UUID

if(index == -1){
// user if not in the blocked users list
}else{
// user if in the blocked users list
}

Models

GetBlockedUsersRequest

The GetBlockedUsersRequest class represents the parameters required to request the blocked users list. Below are the details of the GetBlockedUsersRequest model:

VariableTypeDescriptionOptional
userUUIDStringThe unique identifier (UUID) of the user for whom the blocked list is requested.No

GetBlockedUsersResponse

This response model encapsulates the success status and the list of blocked users returned by the API.

VariableTypeDescriptionOptional
blockedUsersList<User>List of blocked usersYes