Skip to main content

Search Chatrooms

Searches for chatrooms based on the specified request. This function allows users to search for chatrooms using various parameters like search terms, follow status, and pagination, and returns a response with the matching chatrooms.

Steps to search for chatrooms

  1. Create a SearchChatroomRequest object using the builder pattern.
  2. Call the searchChatroom() function using the instance of SearchClient, passing the request object and an optional response handler.
  3. Process the response LMResponse<SearchChatroomResponse> to handle the found chatrooms or any errors.
let request = SearchChatroomRequest.builder()
.search("ENTER_SEARCH_TERM")
.followStatus(true)
.page(1)
.pageSize(20)
.searchType("ENTER_SEARCH_TYPE")
.build()

SearchClient.shared.searchChatroom(request: request) { response in
if let result = response?.data {
// Handle success
print("Chatrooms found: \(result.conversations)")
} else if let error = response?.error {
// Handle error
print("Error searching chatrooms: \(error.localizedDescription)")
}
}

Models

SearchChatroomRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
searchStringThe search term to query chatrooms
followStatusBoolWhether to filter by followed chatrooms✔️
pageIntPage number for pagination
pageSizeIntNumber of results per page
searchTypeStringOn which key, search to be happen (e.g., "header", "title")✔️

SearchChatroomResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
chatrooms[SearchChatroom]Array of chatrooms matching the search criteria

SearchChatroom

VARIABLETYPEDESCRIPTIONOPTIONAL
attachments[Attachment]List of attachments associated with the chatroom
attendingStatusBoolWhether the user is attending the chatroom
chatroomChatroomThe chatroom object
communityCommunityCommunity where the chatroom exists
followStatusBoolWhether the user follows the chatroom
idIntUnique identifier of the chatroom
isGuestBoolWhether the user is a guest in the chatroom
isTaggedBoolWhether the chatroom is tagged
memberMemberThe member associated with the chatroom
muteStatusBoolWhether the chatroom is muted
secretChatroomLeftBoolWhether the secret chatroom has been left
stateIntState of the chatroom (e.g., active, archived)
updatedAtTimeIntervalLast updated timestamp of the chatroom
isDisabledBool?Whether the chatroom is disabled✔️