Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ style:
excludePackageStatements: true
excludeImportStatements: true
excludeCommentStatements: false
# Generated network models can have long fully-qualified nested-type lines; don't lint generated code.
excludes: ['**/io/getstream/chat/android/network/**']
ignoreAnnotated: ['Test', 'ParameterizedTest', "Language"]
MayBeConst:
active: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ import io.getstream.chat.android.client.api2.model.requests.UpdateLiveLocationRe
import io.getstream.chat.android.client.api2.model.requests.UpdateMessageRequest
import io.getstream.chat.android.client.api2.model.requests.UpsertPushPreferencesRequest
import io.getstream.chat.android.client.api2.model.response.ChannelResponse
import io.getstream.chat.android.client.api2.model.response.PushPreferencesResponse
import io.getstream.chat.android.client.api2.model.response.TranslateMessageRequest
import io.getstream.chat.android.client.api2.model.response.getUserChannelPreference
import io.getstream.chat.android.client.api2.model.response.getUserPreference
import io.getstream.chat.android.client.call.RetrofitCall
import io.getstream.chat.android.client.events.ChatEvent
import io.getstream.chat.android.client.extensions.enrichWithCid
Expand Down Expand Up @@ -177,6 +174,7 @@ import io.getstream.chat.android.network.models.UpdateUserGroupResponse
import io.getstream.chat.android.network.models.UpdateUserPartialRequest
import io.getstream.chat.android.network.models.UpdateUsersPartialRequest
import io.getstream.chat.android.network.models.UpdateUsersRequest
import io.getstream.chat.android.network.models.UpsertPushPreferencesResponse
import io.getstream.chat.android.network.models.UserGroupResponse
import io.getstream.chat.android.network.models.UserRequest
import io.getstream.chat.android.network.models.VoteData
Expand Down Expand Up @@ -2022,9 +2020,9 @@ constructor(
private fun <T : Any, R : Any> RetrofitCall<T>.mapDomain(transform: DomainMapping.(T) -> R): Call<R> =
map { domainMapping.transform(it) }

private fun RetrofitCall<PushPreferencesResponse>.parseUserPushPreferencesResponse() = flatMapDomain {
private fun RetrofitCall<UpsertPushPreferencesResponse>.parseUserPushPreferencesResponse() = flatMapDomain {
val currentUserId = currentUserIdProvider().orEmpty()
val preference = it.getUserPreference(currentUserId)
val preference = it.userPreferences[currentUserId]
if (preference != null) {
val result = Result.Success(preference.toDomain())
CoroutineCall(coroutineScope) { result }
Expand All @@ -2037,9 +2035,11 @@ constructor(
}
}

private fun RetrofitCall<PushPreferencesResponse>.parseChannelPushPreferencesResponse(cid: String) = flatMapDomain {
private fun RetrofitCall<UpsertPushPreferencesResponse>.parseChannelPushPreferencesResponse(
cid: String,
) = flatMapDomain {
val currentUserId = currentUserIdProvider().orEmpty()
val preference = it.getUserChannelPreference(currentUserId, cid)
val preference = it.userChannelPreferences[currentUserId]?.get(cid)
if (preference != null) {
val result = Result.Success(preference.toDomain())
CoroutineCall(coroutineScope) { result }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package io.getstream.chat.android.client.api2.endpoint

import io.getstream.chat.android.client.api.AuthenticatedApi
import io.getstream.chat.android.client.api2.model.requests.UpsertPushPreferencesRequest
import io.getstream.chat.android.client.api2.model.response.PushPreferencesResponse
import io.getstream.chat.android.client.call.RetrofitCall
import io.getstream.chat.android.network.models.UpsertPushPreferencesResponse
import retrofit2.http.Body
import retrofit2.http.POST

Expand All @@ -35,5 +35,5 @@ internal interface PushPreferencesApi {
* @param body The request body containing the push preferences to be upserted.
*/
@POST("/push_preferences")
fun upsertPushPreferences(@Body body: UpsertPushPreferencesRequest): RetrofitCall<PushPreferencesResponse>
fun upsertPushPreferences(@Body body: UpsertPushPreferencesRequest): RetrofitCall<UpsertPushPreferencesResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ import io.getstream.chat.android.models.querysort.QuerySorter
import io.getstream.chat.android.models.querysort.SortDirection
import io.getstream.chat.android.network.models.AppResponseFields
import io.getstream.chat.android.network.models.BlockUsersResponse
import io.getstream.chat.android.network.models.ChannelPushPreferencesResponse
import io.getstream.chat.android.network.models.ChatPreferencesResponse
import io.getstream.chat.android.network.models.DeviceResponse
import io.getstream.chat.android.network.models.GetApplicationResponse
import io.getstream.chat.android.network.models.PushPreferencesResponse
import io.getstream.chat.android.network.models.UnreadCountsChannel
import io.getstream.chat.android.network.models.UnreadCountsChannelType
import io.getstream.chat.android.network.models.UnreadCountsThread
Expand Down Expand Up @@ -941,6 +944,28 @@ internal class DomainMapping(
defaultPreference = ChatPreferenceToggle.fromValue(default_preference),
)

internal fun PushPreferencesResponse.toDomain(): PushPreference = PushPreference(
level = PushPreferenceLevel.fromValue(chatLevel),
disabledUntil = disabledUntil,
chatPreferences = chatPreferences?.toDomain(),
)

internal fun ChannelPushPreferencesResponse.toDomain(): PushPreference = PushPreference(
level = PushPreferenceLevel.fromValue(chatLevel),
disabledUntil = disabledUntil,
chatPreferences = null,
)

internal fun ChatPreferencesResponse.toDomain(): ChatPreferences = ChatPreferences(
directMentions = ChatPreferenceToggle.fromValue(directMentions),
roleMentions = ChatPreferenceToggle.fromValue(roleMentions),
groupMentions = ChatPreferenceToggle.fromValue(groupMentions),
hereMentions = ChatPreferenceToggle.fromValue(hereMentions),
channelMentions = ChatPreferenceToggle.fromValue(channelMentions),
threadReplies = ChatPreferenceToggle.fromValue(threadReplies),
defaultPreference = ChatPreferenceToggle.fromValue(defaultPreference),
)

internal fun List<Map<String, Any>>?.toSortDomain(): QuerySorter<Channel>? {
if (isNullOrEmpty()) return null
return fold(QuerySortByField()) { sort, sortSpecMap ->
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

package io.getstream.chat.android.network.models

import com.squareup.moshi.Json

/**
*
*/

@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class ChannelPushPreferencesResponse(
@Json(name = "chat_level")
val chatLevel: kotlin.String? = null,

@Json(name = "disabled_until")
val disabledUntil: java.util.Date? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

package io.getstream.chat.android.network.models

import com.squareup.moshi.Json

/**
*
*/

@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class ChatPreferencesResponse(
@Json(name = "channel_mentions")
val channelMentions: kotlin.String? = null,

@Json(name = "default_preference")
val defaultPreference: kotlin.String? = null,

@Json(name = "direct_mentions")
val directMentions: kotlin.String? = null,

@Json(name = "group_mentions")
val groupMentions: kotlin.String? = null,

@Json(name = "here_mentions")
val hereMentions: kotlin.String? = null,

@Json(name = "role_mentions")
val roleMentions: kotlin.String? = null,

@Json(name = "thread_replies")
val threadReplies: kotlin.String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

package io.getstream.chat.android.network.models

import com.squareup.moshi.Json
import kotlin.collections.Map

/**
*
*/

@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class FeedsPreferencesResponse(
@Json(name = "comment")
val comment: kotlin.String? = null,

@Json(name = "comment_mention")
val commentMention: kotlin.String? = null,

@Json(name = "comment_reaction")
val commentReaction: kotlin.String? = null,

@Json(name = "comment_reply")
val commentReply: kotlin.String? = null,

@Json(name = "follow")
val follow: kotlin.String? = null,

@Json(name = "mention")
val mention: kotlin.String? = null,

@Json(name = "reaction")
val reaction: kotlin.String? = null,

@Json(name = "custom_activity_types")
val customActivityTypes: kotlin.collections.Map<kotlin.String, kotlin.String>? = emptyMap(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

package io.getstream.chat.android.network.models

import com.squareup.moshi.Json

/**
*
*/

@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class PushPreferencesResponse(
@Json(name = "call_level")
val callLevel: kotlin.String? = null,

@Json(name = "chat_level")
val chatLevel: kotlin.String? = null,

@Json(name = "disabled_until")
val disabledUntil: java.util.Date? = null,

@Json(name = "feeds_level")
val feedsLevel: kotlin.String? = null,

@Json(name = "chat_preferences")
val chatPreferences: io.getstream.chat.android.network.models.ChatPreferencesResponse? = null,

@Json(name = "feeds_preferences")
val feedsPreferences: io.getstream.chat.android.network.models.FeedsPreferencesResponse? = null,
)
Loading
Loading