From 81da92672ef6e7576347199174b93c9d74fb313d Mon Sep 17 00:00:00 2001 From: kanat Date: Fri, 19 Jan 2024 08:58:17 -0800 Subject: [PATCH] [i239] Support skipPush flag in add/remove members --- .../api/stream-chat-android-client.api | 12 ++++++------ .../io/getstream/chat/android/client/ChatClient.kt | 9 +++++++++ .../io/getstream/chat/android/client/api/ChatApi.kt | 3 +++ .../chat/android/client/api2/MoshiChatApi.kt | 9 ++++++--- .../client/api2/model/requests/AddMembersRequest.kt | 1 + .../api2/model/requests/InviteMembersRequest.kt | 1 + .../api2/model/requests/RemoveMembersRequest.kt | 1 + .../chat/android/client/UsersApiCallsTests.kt | 1 + 8 files changed, 28 insertions(+), 9 deletions(-) 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 d7286b2d612..bcc7c67a2bd 100644 --- a/stream-chat-android-client/api/stream-chat-android-client.api +++ b/stream-chat-android-client/api/stream-chat-android-client.api @@ -11,8 +11,8 @@ public final class io/getstream/chat/android/client/ChatClient { public static final field DEFAULT_SORT Lio/getstream/chat/android/models/querysort/QuerySorter; public final fun acceptInvite (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; public final fun addDevice (Lio/getstream/chat/android/models/Device;)Lio/getstream/result/call/Call; - public final fun addMembers (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;)Lio/getstream/result/call/Call; - public static synthetic fun addMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;ILjava/lang/Object;)Lio/getstream/result/call/Call; + public final fun addMembers (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lio/getstream/result/call/Call; + public static synthetic fun addMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun addSocketListener (Lio/getstream/chat/android/client/socket/SocketListener;)V public final fun appSettings ()Lio/getstream/result/call/Call; public final fun banUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)Lio/getstream/result/call/Call; @@ -77,8 +77,8 @@ public final class io/getstream/chat/android/client/ChatClient { public final fun hideChannel (Ljava/lang/String;Ljava/lang/String;Z)Lio/getstream/result/call/Call; public static synthetic fun hideChannel$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Lio/getstream/result/call/Call; public static final fun instance ()Lio/getstream/chat/android/client/ChatClient; - public final fun inviteMembers (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call; - public static synthetic fun inviteMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;ILjava/lang/Object;)Lio/getstream/result/call/Call; + public final fun inviteMembers (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;)Lio/getstream/result/call/Call; + public static synthetic fun inviteMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun isSocketConnected ()Z public final fun keystroke (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; public static synthetic fun keystroke$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/getstream/result/call/Call; @@ -117,8 +117,8 @@ public final class io/getstream/chat/android/client/ChatClient { public final fun queryUsers (Lio/getstream/chat/android/client/api/models/QueryUsersRequest;)Lio/getstream/result/call/Call; public final fun reconnectSocket ()Lio/getstream/result/call/Call; public final fun rejectInvite (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; - public final fun removeMembers (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call; - public static synthetic fun removeMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;ILjava/lang/Object;)Lio/getstream/result/call/Call; + public final fun removeMembers (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;)Lio/getstream/result/call/Call; + public static synthetic fun removeMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;ILjava/lang/Object;)Lio/getstream/result/call/Call; public final fun removeShadowBan (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call; public final fun removeSocketListener (Lio/getstream/chat/android/client/socket/SocketListener;)V public final fun searchMessages (Lio/getstream/chat/android/models/FilterObject;Lio/getstream/chat/android/models/FilterObject;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;Lio/getstream/chat/android/models/querysort/QuerySorter;)Lio/getstream/result/call/Call; 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 ced23733347..4f1a334cb3b 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 @@ -2308,6 +2308,7 @@ internal constructor( * @param memberIds The list of the member ids to be added. * @param systemMessage The system message that will be shown in the channel. * @param hideHistory Hides the history of the channel to the added member. + * @param skipPush If true, skips sending push notifications. * * @return Executable async [Call] responsible for adding the members. */ @@ -2318,6 +2319,7 @@ internal constructor( memberIds: List, systemMessage: Message? = null, hideHistory: Boolean? = null, + skipPush: Boolean? = null, ): Call { return api.addMembers( channelType, @@ -2325,6 +2327,7 @@ internal constructor( memberIds, systemMessage, hideHistory, + skipPush, ) } @@ -2335,6 +2338,7 @@ internal constructor( * @param channelId The channel id. ie 123. * @param memberIds The list of the member ids to be removed. * @param systemMessage The system message that will be shown in the channel. + * @param skipPush If true, skips sending push notifications. * * @return Executable async [Call] responsible for removing the members. */ @@ -2344,11 +2348,13 @@ internal constructor( channelId: String, memberIds: List, systemMessage: Message? = null, + skipPush: Boolean? = null, ): Call = api.removeMembers( channelType, channelId, memberIds, systemMessage, + skipPush, ) /** @@ -2358,6 +2364,7 @@ internal constructor( * @param channelId The channel id. ie 123. * @param memberIds The list of the member ids to be invited. * @param systemMessage The system message that will be shown in the channel. + * @param skipPush If true, skips sending push notifications. * * @return Executable async [Call] responsible for inviting the members. */ @@ -2367,11 +2374,13 @@ internal constructor( channelId: String, memberIds: List, systemMessage: Message? = null, + skipPush: Boolean? = null, ): Call = api.inviteMembers( channelType, channelId, memberIds, systemMessage, + skipPush, ) /** diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/ChatApi.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/ChatApi.kt index 0755884a308..27f0808ac4c 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/ChatApi.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/ChatApi.kt @@ -310,6 +310,7 @@ internal interface ChatApi { members: List, systemMessage: Message?, hideHistory: Boolean?, + skipPush: Boolean?, ): Call @CheckResult @@ -318,6 +319,7 @@ internal interface ChatApi { channelId: String, members: List, systemMessage: Message?, + skipPush: Boolean?, ): Call @CheckResult @@ -326,6 +328,7 @@ internal interface ChatApi { channelId: String, members: List, systemMessage: Message?, + skipPush: Boolean?, ): Call @CheckResult diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt index cd7ab86d73e..87556c0e657 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt @@ -674,11 +674,12 @@ constructor( members: List, systemMessage: Message?, hideHistory: Boolean?, + skipPush: Boolean?, ): Call { return channelApi.addMembers( channelType = channelType, channelId = channelId, - body = AddMembersRequest(members, systemMessage?.toDto(), hideHistory), + body = AddMembersRequest(members, systemMessage?.toDto(), hideHistory, skipPush), ).map(this::flattenChannel) } @@ -687,11 +688,12 @@ constructor( channelId: String, members: List, systemMessage: Message?, + skipPush: Boolean?, ): Call { return channelApi.removeMembers( channelType = channelType, channelId = channelId, - body = RemoveMembersRequest(members, systemMessage?.toDto()), + body = RemoveMembersRequest(members, systemMessage?.toDto(), skipPush), ).map(this::flattenChannel) } @@ -700,11 +702,12 @@ constructor( channelId: String, members: List, systemMessage: Message?, + skipPush: Boolean?, ): Call { return channelApi.inviteMembers( channelType = channelType, channelId = channelId, - body = InviteMembersRequest(members, systemMessage?.toDto()), + body = InviteMembersRequest(members, systemMessage?.toDto(), skipPush), ).map(this::flattenChannel) } diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/AddMembersRequest.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/AddMembersRequest.kt index 3cff2a256fe..0277f7773c3 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/AddMembersRequest.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/AddMembersRequest.kt @@ -24,4 +24,5 @@ internal data class AddMembersRequest( val add_members: List, val message: UpstreamMessageDto?, val hide_history: Boolean?, + val skip_push: Boolean?, ) diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/InviteMembersRequest.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/InviteMembersRequest.kt index cc78b286d34..dd5a7ab6018 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/InviteMembersRequest.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/InviteMembersRequest.kt @@ -23,4 +23,5 @@ import io.getstream.chat.android.client.api2.model.dto.UpstreamMessageDto internal data class InviteMembersRequest( val invites: List, val message: UpstreamMessageDto?, + val skip_push: Boolean?, ) diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/RemoveMembersRequest.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/RemoveMembersRequest.kt index c13e090f0fb..8fc39cbed42 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/RemoveMembersRequest.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/RemoveMembersRequest.kt @@ -23,4 +23,5 @@ import io.getstream.chat.android.client.api2.model.dto.UpstreamMessageDto internal data class RemoveMembersRequest( val remove_members: List, val message: UpstreamMessageDto?, + val skip_push: Boolean?, ) diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/UsersApiCallsTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/UsersApiCallsTests.kt index c2e15c64f4a..282ae27ca2e 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/UsersApiCallsTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/UsersApiCallsTests.kt @@ -215,6 +215,7 @@ internal class UsersApiCallsTests { mock.channelId, listOf("a-id", "b-id"), null, + null, ), ).thenReturn(RetroSuccess(channel).toRetrofitCall())