Package 

Interface ChatDomain


  • 
    public interface ChatDomain
    
                        

    The ChatDomain is the main entry point for all flow & offline operations on chat.

    • Method Detail

      • watchChannel

        @CheckResult() abstract Call<ChannelController> watchChannel(String cid, Integer messageLimit)

        Watches the given channel and returns a ChannelController.

        Parameters:
        cid - The full channel id.
        messageLimit - How many messages to load on the first request.
      • queryChannels

        @CheckResult() abstract Call<QueryChannelsController> queryChannels(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit)

        Queries offline storage and the API for channels matching the filter.

        Parameters:
        filter - The filter object.
        sort - How to sort the channels (default is last_message_at).
        limit - The number of channels to retrieve.
        messageLimit - How many messages to retrieve per channel.
        memberLimit - The number of members per channel.
      • getThread

        @CheckResult() abstract Call<ThreadController> getThread(String cid, String parentId)

        Returns a thread controller for the given channel and message id.

        Parameters:
        cid - The full channel id.
        parentId - The message id for the parent of this thread.
      • loadOlderMessages

        @CheckResult()@Deprecated(message = loadOlderMessages is deprecated. Use extension function ChatClient::loadOlderMessages instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().loadOlderMessages(cid, messageLimit)), level = DeprecationLevel.ERROR) abstract Call<Channel> loadOlderMessages(String cid, Integer messageLimit)

        Loads older messages for the channel.

        Parameters:
        cid - The full channel id i.
        messageLimit - How many new messages to load.
      • loadNewerMessages

        @CheckResult() abstract Call<Channel> loadNewerMessages(String cid, Integer messageLimit)

        Loads newer messages for the channel.

        Parameters:
        cid - The full channel id i.
        messageLimit - How many new messages to load.
      • loadMessageById

        @CheckResult() abstract Call<Message> loadMessageById(String cid, String messageId, Integer olderMessagesOffset, Integer newerMessagesOffset)

        Loads message for a given message id and channel id.

        Parameters:
        cid - The full channel id i.
        messageId - The id of the message.
        olderMessagesOffset - How many new messages to load before the requested message.
        newerMessagesOffset - How many new messages to load after the requested message.
      • queryChannelsLoadMore

        @CheckResult() abstract Call<List<Channel>> queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit)

        Load more channels for this query.

        Parameters:
        filter - The filter for querying channels, see https://getstream.io/chat/docs/query_channels/?language=kotlin.
        sort - The sort for the channels, by default will sort on last_message_at.
        limit - The number of channels to retrieve.
        messageLimit - How many messages to fetch per channel.
        memberLimit - The number of members per channel.
      • queryChannelsLoadMore

        @CheckResult() abstract Call<List<Channel>> queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort, Integer messageLimit)

        Load more channels for this query.

        Parameters:
        filter - The filter for querying channels, see https://getstream.io/chat/docs/query_channels/?language=kotlin.
        sort - The sort for the channels, by default will sort on last_message_at.
        messageLimit - How many messages to fetch per channel.
      • queryChannelsLoadMore

        @CheckResult() abstract Call<List<Channel>> queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort)

        Load more channels for this query.

        Parameters:
        filter - The filter for querying channels, see https://getstream.io/chat/docs/query_channels/?language=kotlin.
        sort - The sort for the channels, by default will sort on last_message_at.
      • threadLoadMore

        @CheckResult() abstract Call<List<Message>> threadLoadMore(String cid, String parentId, Integer messageLimit)

        Loads more messages for the specified thread.

        Parameters:
        cid - The full channel id i.
        parentId - The parentId of the thread.
        messageLimit - How many new messages to load.
      • createChannel

        @Deprecated(message = createChannel is deprecated. Use ChatClient::createChannel extension function  instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().createChannel(channel)))@CheckResult() abstract Call<Channel> createChannel(Channel channel)

        Creates a new channel. Will retry according to the retry policy if it fails.

        Parameters:
        channel - The channel object.
      • sendMessage

        @CheckResult() abstract Call<Message> sendMessage(Message message)

        Sends the message. Immediately adds the message to local storage API call to send the message is retried according to the retry policy specified on the chatDomain.

        Parameters:
        message - The message to send.
      • cancelMessage

        @CheckResult()@Deprecated(message = cancelMessage is deprecated. Use extension function ChatClient::cancelMessage instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().cancelMessage(message)), level = DeprecationLevel.WARNING) abstract Call<Boolean> cancelMessage(Message message)

        Cancels the message of "ephemeral" type. Removes the message from local storage. API call to remove the message is retried according to the retry policy specified on the chatDomain.

        Parameters:
        message - The message to send.
      • shuffleGiphy

        @CheckResult() abstract Call<Message> shuffleGiphy(Message message)

        Performs giphy shuffle operation. Removes the original "ephemeral" message from local storage. Returns new "ephemeral" message with new giphy url. API call to remove the message is retried according to the retry policy specified on the chatDomain

        Parameters:
        message - The message to send.
      • sendGiphy

        @CheckResult() abstract Call<Message> sendGiphy(Message message)

        Sends selected giphy message to the channel. Removes the original "ephemeral" message from local storage. Returns new "ephemeral" message with new giphy url. API call to remove the message is retried according to the retry policy specified on the chatDomain

        Parameters:
        message - The message to send.
      • editMessage

        @CheckResult()@Deprecated(message = ChatDomain.editMessage is deprecated. Use function ChatClient::updateMessage instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().updateMessage(message)), level = DeprecationLevel.WARNING) abstract Call<Message> editMessage(Message message)

        Edits the specified message. Local storage is updated immediately. The API request is retried according to the retry policy specified on the chatDomain.

        Parameters:
        message - The message to edit.
      • deleteMessage

        @CheckResult() abstract Call<Message> deleteMessage(Message message, Boolean hard)

        Deletes the specified message, request is retried according to the retry policy specified on the chatDomain.

        Parameters:
        message - The message to mark as deleted.
        hard - Use to hard delete the message (delete in backend).
      • deleteMessage

         abstract Call<Message> deleteMessage(Message message)
      • sendReaction

        @CheckResult() abstract Call<Reaction> sendReaction(String cid, Reaction reaction, Boolean enforceUnique)

        Sends the reaction. Immediately adds the reaction to local storage and updates the reaction fields on the related message. API call to send the reaction is retried according to the retry policy specified on the chatDomain.

        Parameters:
        cid - The full channel id i.
        reaction - The reaction to add.
        enforceUnique - If set to true, new reaction will replace all reactions the user has on this message.
      • deleteReaction

        @CheckResult() abstract Call<Message> deleteReaction(String cid, Reaction reaction)

        Deletes the specified reaction, request is retried according to the retry policy specified on the chatDomain.

        Parameters:
        cid - The full channel id, ie messaging:123.
        reaction - The reaction to mark as deleted.
      • markRead

        @CheckResult() abstract Call<Boolean> markRead(String cid)

        Marks all messages of the specified channel as read.

        Parameters:
        cid - The full channel id i.
      • hideChannel

        @CheckResult() abstract Call<Unit> hideChannel(String cid, Boolean keepHistory)

        Hides the channel with the specified id.

        Parameters:
        cid - The full channel id i.
        keepHistory - Boolean, if you want to keep the history of this channel or not.
      • showChannel

        @CheckResult()@Deprecated(message = Deprecated. Use ChatClient::showChannel instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().showChannel(channelType, channelId)), level = DeprecationLevel.ERROR) abstract Call<Unit> showChannel(String cid)

        Shows a channel that was previously hidden.

        Parameters:
        cid - The full channel id i.
      • leaveChannel

        @CheckResult()@Deprecated(message = leaveChannel is deprecated. Use function ChatClient::removeMembers instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().removeMembers(channel.type, channel.id, listOf(userId))), level = DeprecationLevel.WARNING) abstract Call<Unit> leaveChannel(String cid)

        Leaves the channel with the specified id.

        Parameters:
        cid - The full channel id i.
      • deleteChannel

        @CheckResult()@Deprecated(message = deleteChannel is deprecated. Use function ChannelClient::delete instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().channel(cid).delete().toUnitCall()), level = DeprecationLevel.WARNING) abstract Call<Unit> deleteChannel(String cid)

        Deletes the channel with the specified id.

        Parameters:
        cid - The full channel id i.
      • searchUsersByName

        @CheckResult() abstract Call<List<User>> searchUsersByName(String querySearch, Integer offset, Integer userLimit, Boolean userPresence)

        Perform api request with a search string as autocomplete if in online state. Otherwise performs search by name in local database.

        Parameters:
        querySearch - Search string used as autocomplete.
        offset - Offset for paginated requests.
        userLimit - The page size in the request.
        userPresence - Presence flag to obtain additional info such as last active date.
      • queryMembers

        @CheckResult() abstract Call<List<Member>> queryMembers(String cid, Integer offset, Integer limit, FilterObject filter, QuerySort<Member> sort, List<Member> members)

        Query members of a channel.

        Parameters:
        cid - CID of the Channel whose members we are querying.
        offset - Indicates how many items to exclude from the start of the result.
        limit - Indicates the maximum allowed number of items in the result.
        filter - Applied to online queries for advanced selection criteria.
        sort - The sort criteria applied to the result.
      • getUser

         abstract StateFlow<User> getUser()

        The current user on the chatDomain object

      • getInitialized

         abstract StateFlow<Boolean> getInitialized()

        if the client connection has been initialized

      • getConnectionState

         abstract StateFlow<ConnectionState> getConnectionState()

        StateFlow<ConnectionState> that indicates if we are currently online, connecting of offline.

      • getTotalUnreadCount

         abstract StateFlow<Integer> getTotalUnreadCount()

        The total unread message count for the current user. Depending on your app you'll want to show this or the channelUnreadCount

      • getErrorEvents

         abstract StateFlow<Event<ChatError>> getErrorEvents()

        The error event state flow object is triggered when errors in the underlying components occur. The following example shows how to observe these errors

        repo.errorEvent.collect { // create a toast }

      • getMuted

         abstract StateFlow<List<Mute>> getMuted()

        list of users that you've muted

      • getChannelMutes

         abstract StateFlow<List<ChannelMute>> getChannelMutes()

        List of channels you've muted

      • getBanned

         abstract StateFlow<Boolean> getBanned()

        if the current user is banned or not

      • getTypingUpdates

         abstract StateFlow<TypingEvent> getTypingUpdates()

        Updates about currently typing users in active channels. See TypingEvent.