diff --git a/CHANGELOG.md b/CHANGELOG.md index fac2c68640f..4616a414b90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,18 @@ ### ⬆️ Improved ### ✅ Added +- Add `ChatClient.getPoll(pollId: String)` for retrieving a poll by its ID. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Add `ChatClient.partialUpdatePoll(pollId: String, set: Map, unset: List)` for partially updating a poll. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Add `ChatClient.createPollOption(pollId: String, option: CreatePollOptionRequest)` for creating a poll option. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Add `ChatClient.updatePollOption(pollId: String, option: UpdatePollOptionRequest)` for updating a poll option. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Add `ChatClient.deletePollOption(pollId: String, optionId: String)` for deleting a poll option. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Add `ChatClient.queryPollVotes(pollId: String, filter: FilterObject?, limit: Int?, next: String?, sort: QuerySorter?)` for querying poll votes with filtering, sorting, and pagination support. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Add `ChatClient.queryPolls(filter: FilterObject?, limit: Int?, next: String?, sort: QuerySorter?)` for querying polls with filtering, sorting, and pagination support. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Add `PollConfig` constructor with support for extra custom data for the poll and the poll options. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) ### ⚠️ Changed +- Deprecate `PollConfig` constructor without support for custom data. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) +- Deprecate `ChatClient.suggestPollOption(pollId: String, option: String)` in favour of `ChatClient.createPollOption(pollId: String, option: CreatePollOptionRequest)`. [#5966](https://github.com/GetStream/stream-chat-android/pull/5966) ### ❌ Removed @@ -56,6 +66,7 @@ ## stream-chat-android-ui-components ### 🐞 Fixed +- Disallow creating polls in threads. [#5970](https://github.com/GetStream/stream-chat-android/pull/5970) ### ⬆️ Improved @@ -67,6 +78,7 @@ ## stream-chat-android-compose ### 🐞 Fixed +- Disallow creating polls in threads. [#5970](https://github.com/GetStream/stream-chat-android/pull/5970) ### ⬆️ Improved diff --git a/DEPRECATIONS.md b/DEPRECATIONS.md index a1a93d3d6c6..aec1535d2b6 100644 --- a/DEPRECATIONS.md +++ b/DEPRECATIONS.md @@ -4,6 +4,8 @@ This document lists deprecated constructs in the SDK, with their expected time | API / Feature | Deprecated (warning) | Deprecated (error) | Removed | Notes | |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|-----------------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `PollConfig(String, List, String, VotingVisibility, Boolean, Int, Boolean, Boolean)` constructor | 2025.10.20 ⌛ | | | This constructor has been deprecated. Please use `PollConfig(String, List, String, VotingVisibility, Boolean, Int, Boolean, Boolean, Map)` instead. | +| `ChatClient.suggestPollOption(pollId: String, option: String)` method | 2025.10.20 ⌛ | | | This method has been deprecated. Please use `ChatClient.createPollOption(pollId: String, option: CreatePollOptionRequest)` instead. | | `SendReactionListener.onSendReactionRequest(cid: String?, reaction: Reaction, enforceUnique: Boolean, currentUser: User)` method | 2025.09.22 ⌛ | | | This method has been deprecated. Please use `SendReactionListener.onSendReactionRequest(cid: String?, reaction: Reaction, enforceUnique: Boolean, skipPush: Boolean, currentUser: User)` instead. | | `AudioWaveVSeekbar`
*compose* | 2025.09.22 ⌛ | | | | | `StateRegistry.queryThreads()` method | 2025.09.15 ⌛ | | | This method has been deprecated as it is no longer used internally. Please use the `StateRegistry.queryThreads(FilterObject, QuerySorter)` method instead for better flexibility. | diff --git a/stream-chat-android-client/api/stream-chat-android-client.api b/stream-chat-android-client/api/stream-chat-android-client.api index d538b9f6f5d..067a69eb45e 100644 --- a/stream-chat-android-client/api/stream-chat-android-client.api +++ b/stream-chat-android-client/api/stream-chat-android-client.api @@ -41,6 +41,7 @@ public final class io/getstream/chat/android/client/ChatClient { public final fun createChannel (Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/client/query/CreateChannelParams;)Lio/getstream/result/call/Call; public final fun createChannel (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/util/Map;)Lio/getstream/result/call/Call; public final fun createDraftMessage (Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/DraftMessage;)Lio/getstream/result/call/Call; + public final fun createPollOption (Ljava/lang/String;Lio/getstream/chat/android/client/api/models/CreatePollOptionRequest;)Lio/getstream/result/call/Call; public final fun createReminder (Ljava/lang/String;Ljava/util/Date;)Lio/getstream/result/call/Call; public final fun createVideoCall (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; public final fun deleteChannel (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; @@ -55,6 +56,7 @@ public final class io/getstream/chat/android/client/ChatClient { public static synthetic fun deleteMessage$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;ZILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun deleteMessageForMe (Ljava/lang/String;)Lio/getstream/result/call/Call; public final fun deletePoll (Ljava/lang/String;)Lio/getstream/result/call/Call; + public final fun deletePollOption (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; public final fun deleteReaction (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; public static synthetic fun deleteReaction$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun deleteReminder (Ljava/lang/String;)Lio/getstream/result/call/Call; @@ -92,6 +94,7 @@ public final class io/getstream/chat/android/client/ChatClient { public static final fun getOFFLINE_SUPPORT_ENABLED ()Z public final fun getPendingMessage (Ljava/lang/String;)Lio/getstream/result/call/Call; public final fun getPinnedMessages (Ljava/lang/String;Ljava/lang/String;ILio/getstream/chat/android/models/querysort/QuerySorter;Lio/getstream/chat/android/client/api/models/PinnedMessagesPagination;)Lio/getstream/result/call/Call; + public final fun getPoll (Ljava/lang/String;)Lio/getstream/result/call/Call; public final fun getReactions (Ljava/lang/String;II)Lio/getstream/result/call/Call; public final fun getReplies (Ljava/lang/String;I)Lio/getstream/result/call/Call; public final fun getRepliesMore (Ljava/lang/String;Ljava/lang/String;I)Lio/getstream/result/call/Call; @@ -129,6 +132,8 @@ public final class io/getstream/chat/android/client/ChatClient { public static synthetic fun partialUpdateMember$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun partialUpdateMessage (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;)Lio/getstream/result/call/Call; public static synthetic fun partialUpdateMessage$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call; + public final fun partialUpdatePoll (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;)Lio/getstream/result/call/Call; + public static synthetic fun partialUpdatePoll$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun partialUpdateThread (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;)Lio/getstream/result/call/Call; public static synthetic fun partialUpdateThread$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun partialUpdateUser (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;)Lio/getstream/result/call/Call; @@ -156,6 +161,10 @@ public final class io/getstream/chat/android/client/ChatClient { public static synthetic fun queryDrafts$default (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/FilterObject;ILjava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun queryMembers (Ljava/lang/String;Ljava/lang/String;IILio/getstream/chat/android/models/FilterObject;Lio/getstream/chat/android/models/querysort/QuerySorter;Ljava/util/List;)Lio/getstream/result/call/Call; public static synthetic fun queryMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;IILio/getstream/chat/android/models/FilterObject;Lio/getstream/chat/android/models/querysort/QuerySorter;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call; + public final fun queryPollVotes (Ljava/lang/String;Lio/getstream/chat/android/models/FilterObject;Ljava/lang/Integer;Ljava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;)Lio/getstream/result/call/Call; + public static synthetic fun queryPollVotes$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Lio/getstream/chat/android/models/FilterObject;Ljava/lang/Integer;Ljava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;ILjava/lang/Object;)Lio/getstream/result/call/Call; + public final fun queryPolls (Lio/getstream/chat/android/models/FilterObject;Ljava/lang/Integer;Ljava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;)Lio/getstream/result/call/Call; + public static synthetic fun queryPolls$default (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/FilterObject;Ljava/lang/Integer;Ljava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun queryReminders (Lio/getstream/chat/android/models/FilterObject;ILjava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;)Lio/getstream/result/call/Call; public static synthetic fun queryReminders$default (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/FilterObject;ILjava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun queryThreads (Lio/getstream/chat/android/client/api/models/QueryThreadsRequest;)Lio/getstream/result/call/Call; @@ -238,6 +247,7 @@ public final class io/getstream/chat/android/client/ChatClient { public static synthetic fun updateChannelPartial$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun updateLiveLocation (Ljava/lang/String;DDLjava/lang/String;)Lio/getstream/result/call/Call; public final fun updateMessage (Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call; + public final fun updatePollOption (Ljava/lang/String;Lio/getstream/chat/android/client/api/models/UpdatePollOptionRequest;)Lio/getstream/result/call/Call; public final fun updateReminder (Ljava/lang/String;Ljava/util/Date;)Lio/getstream/result/call/Call; public final fun updateUser (Lio/getstream/chat/android/models/User;)Lio/getstream/result/call/Call; public final fun updateUsers (Ljava/util/List;)Lio/getstream/result/call/Call; @@ -320,6 +330,20 @@ public final class io/getstream/chat/android/client/api/ChatClientConfig { public final fun setWssUrl (Ljava/lang/String;)V } +public final class io/getstream/chat/android/client/api/models/CreatePollOptionRequest { + public fun (Ljava/lang/String;Ljava/util/Map;)V + public synthetic fun (Ljava/lang/String;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/util/Map; + public final fun copy (Ljava/lang/String;Ljava/util/Map;)Lio/getstream/chat/android/client/api/models/CreatePollOptionRequest; + public static synthetic fun copy$default (Lio/getstream/chat/android/client/api/models/CreatePollOptionRequest;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/chat/android/client/api/models/CreatePollOptionRequest; + public fun equals (Ljava/lang/Object;)Z + public final fun getExtraData ()Ljava/util/Map; + public final fun getText ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public final class io/getstream/chat/android/client/api/models/GetThreadOptions { public fun ()V public fun (Z)V @@ -615,6 +639,22 @@ public final class io/getstream/chat/android/client/api/models/SendActionRequest public fun toString ()Ljava/lang/String; } +public final class io/getstream/chat/android/client/api/models/UpdatePollOptionRequest { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Ljava/util/Map; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Lio/getstream/chat/android/client/api/models/UpdatePollOptionRequest; + public static synthetic fun copy$default (Lio/getstream/chat/android/client/api/models/UpdatePollOptionRequest;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/chat/android/client/api/models/UpdatePollOptionRequest; + public fun equals (Ljava/lang/Object;)Z + public final fun getExtraData ()Ljava/util/Map; + public final fun getId ()Ljava/lang/String; + public final fun getText ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public final class io/getstream/chat/android/client/api/models/WatchChannelRequest : io/getstream/chat/android/client/api/models/QueryChannelRequest { public fun ()V public synthetic fun withData (Ljava/util/Map;)Lio/getstream/chat/android/client/api/models/QueryChannelRequest; diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt index e0739366623..5646510f69c 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt @@ -30,6 +30,7 @@ import io.getstream.chat.android.client.ChatClient.Companion.MAX_COOLDOWN_TIME_S import io.getstream.chat.android.client.api.ChatApi import io.getstream.chat.android.client.api.ChatClientConfig import io.getstream.chat.android.client.api.ErrorCall +import io.getstream.chat.android.client.api.models.CreatePollOptionRequest import io.getstream.chat.android.client.api.models.GetThreadOptions import io.getstream.chat.android.client.api.models.PinnedMessagesPagination import io.getstream.chat.android.client.api.models.QueryChannelRequest @@ -37,6 +38,7 @@ import io.getstream.chat.android.client.api.models.QueryChannelsRequest import io.getstream.chat.android.client.api.models.QueryThreadsRequest import io.getstream.chat.android.client.api.models.QueryUsersRequest import io.getstream.chat.android.client.api.models.SendActionRequest +import io.getstream.chat.android.client.api.models.UpdatePollOptionRequest import io.getstream.chat.android.client.api.models.identifier.AddDeviceIdentifier import io.getstream.chat.android.client.api.models.identifier.ConnectUserIdentifier import io.getstream.chat.android.client.api.models.identifier.DeleteDeviceIdentifier @@ -189,6 +191,8 @@ import io.getstream.chat.android.models.PushMessage import io.getstream.chat.android.models.PushPreference import io.getstream.chat.android.models.PushPreferenceLevel import io.getstream.chat.android.models.QueryDraftsResult +import io.getstream.chat.android.models.QueryPollVotesResult +import io.getstream.chat.android.models.QueryPollsResult import io.getstream.chat.android.models.QueryRemindersResult import io.getstream.chat.android.models.QueryThreadsResult import io.getstream.chat.android.models.Reaction @@ -1727,35 +1731,6 @@ internal constructor( ) } - /** - * Send a message with a poll to the given channel. - * - * IMPORTANT: Polls cannot be sent inside a thread! - * - * @param channelType The channel type. ie messaging. - * @param channelId The channel id. ie 123. - * @param pollConfig The poll configuration. - * - * @return Executable async [Call] responsible for sending a poll. - */ - @CheckResult - public fun sendPoll( - channelType: String, - channelId: String, - pollConfig: PollConfig, - ): Call { - return api.createPoll(pollConfig) - .flatMap { poll -> - sendMessage( - channelType = channelType, - channelId = channelId, - Message( - extraData = mapOf("poll_id" to poll.id), - ), - ) - } - } - /** * Sends a static location message to the given channel. * @@ -1898,12 +1873,196 @@ internal constructor( } } + /** + * Send a message with a poll to the given channel. + * + * IMPORTANT: Polls cannot be sent inside a thread! + * + * @param channelType The channel type. ie messaging. + * @param channelId The channel id. ie 123. + * @param pollConfig The poll configuration. + * + * @return Executable async [Call] responsible for sending a poll. + */ + @CheckResult + public fun sendPoll( + channelType: String, + channelId: String, + pollConfig: PollConfig, + ): Call { + return api.createPoll(pollConfig) + .flatMap { poll -> + sendMessage( + channelType = channelType, + channelId = channelId, + Message( + extraData = mapOf("poll_id" to poll.id), + ), + ) + } + } + + /** + * Get a poll by id. + * + * @param pollId The poll id. + * @return Executable async [Call] responsible for fetching a poll. + */ + @CheckResult + public fun getPoll(pollId: String): Call { + return api.getPoll(pollId) + } + + /** + * Partially update a poll. + * + * @param pollId The poll id. + * @param set Map of fields to set. + * @param unset List of fields to unset. + * @return Executable async [Call] responsible for updating a poll. + */ + @CheckResult + public fun partialUpdatePoll( + pollId: String, + set: Map = emptyMap(), + unset: List = emptyList(), + ): Call { + return api.partialUpdatePoll(pollId, set, unset) + } + + /** + * Close a poll in a message. + * + * @param pollId The poll id. + * + * @return Executable async [Call] responsible for closing a poll. + */ + @CheckResult + public fun closePoll(pollId: String): Call { + return api.closePoll(pollId) + } + + /** + * Deletes a poll. + * + * @param pollId The ID of the poll to delete. + * @return Executable async [Call] responsible for deleting a poll. + */ + @CheckResult + public fun deletePoll(pollId: String): Call { + return api.deletePoll(pollId) + } + + /** + * Create a new option for a poll. + * Note: To create an option with custom data, use [createPollOption] instead. + * + * @param pollId The poll id. + * @param option The option to create. + * + * @return Executable async [Call] responsible for creating a new option. + */ + @Deprecated("ChatClient.suggestPollOption doesn't allow passing custom data. Use createPollOption instead.") @CheckResult public fun suggestPollOption( pollId: String, option: String, ): Call