Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ import io.getstream.chat.android.client.api2.model.dto.DownstreamMemberDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamMemberInfoDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamMessageDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamModerationDetailsDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamModerationDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamMuteDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPendingMessageDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPollDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPollOptionDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPushPreferenceDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamReactionDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamReactionGroupDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamReminderDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamReminderInfoDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamThreadDto
Expand Down Expand Up @@ -136,13 +134,15 @@ import io.getstream.chat.android.network.models.DeviceResponse
import io.getstream.chat.android.network.models.FullUserResponse
import io.getstream.chat.android.network.models.GetApplicationResponse
import io.getstream.chat.android.network.models.GetOGResponse
import io.getstream.chat.android.network.models.ModerationV2Response
import io.getstream.chat.android.network.models.PollOptionResponseData
import io.getstream.chat.android.network.models.PollResponseData
import io.getstream.chat.android.network.models.PollVoteResponseData
import io.getstream.chat.android.network.models.PollVotesResponse
import io.getstream.chat.android.network.models.PrivacySettingsResponse
import io.getstream.chat.android.network.models.PushPreferencesResponse
import io.getstream.chat.android.network.models.QueryPollsResponse
import io.getstream.chat.android.network.models.ReactionGroupResponse
import io.getstream.chat.android.network.models.ReactionResponse
import io.getstream.chat.android.network.models.UnreadCountsChannel
import io.getstream.chat.android.network.models.UnreadCountsChannelType
Expand Down Expand Up @@ -530,15 +530,15 @@ internal class DomainMapping(
)

/**
* Transforms [DownstreamReactionGroupDto] to [ReactionGroup].
* Transforms [ReactionGroupResponse] to [ReactionGroup].
*/
internal fun DownstreamReactionGroupDto.toDomain(type: String): ReactionGroup =
internal fun ReactionGroupResponse.toDomain(type: String): ReactionGroup =
ReactionGroup(
type = type,
count = count,
sumScore = sum_scores,
firstReactionAt = first_reaction_at,
lastReactionAt = last_reaction_at,
sumScore = sumScores,
firstReactionAt = firstReactionAt,
lastReactionAt = lastReactionAt,
)

/**
Expand Down Expand Up @@ -1124,16 +1124,16 @@ internal class DomainMapping(
)

/**
* Maps the network [DownstreamModerationDto] to the domain model [Moderation].
* Maps the network [ModerationV2Response] to the domain model [Moderation].
*/
internal fun DownstreamModerationDto.toDomain() = Moderation(
action = ModerationAction.fromValue(this.action),
originalText = this.original_text,
textHarms = this.text_harms.orEmpty(),
imageHarms = this.image_harms.orEmpty(),
blocklistMatched = this.blocklist_matched,
semanticFilterMatched = this.semantic_filter_matched,
platformCircumvented = this.platform_circumvented ?: false,
internal fun ModerationV2Response.toDomain() = Moderation(
action = ModerationAction.fromValue(action),
originalText = originalText,
textHarms = textHarms.orEmpty(),
imageHarms = imageHarms.orEmpty(),
blocklistMatched = blocklistMatched,
semanticFilterMatched = semanticFilterMatched,
platformCircumvented = platformCircumvented ?: false,
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,16 @@
)
@JsonClass(generateAdapter = true)
internal data class DownstreamReactionDto(
val created_at: Date?,

Check warning on line 33 in stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamReactionDto.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter to match the regular expression ^`?[_a-z][a-zA-Z0-9]*`?$

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-chat-android&issues=AaCAdUTos8C6e7r480le&open=AaCAdUTos8C6e7r480le&pullRequest=6685
val message_id: String,

Check warning on line 34 in stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamReactionDto.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter to match the regular expression ^`?[_a-z][a-zA-Z0-9]*`?$

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-chat-android&issues=AaCAdUTos8C6e7r480lf&open=AaCAdUTos8C6e7r480lf&pullRequest=6685
val score: Int,
val type: String,
val updated_at: Date?,

Check warning on line 37 in stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamReactionDto.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter to match the regular expression ^`?[_a-z][a-zA-Z0-9]*`?$

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-chat-android&issues=AaCAdUTos8C6e7r480lg&open=AaCAdUTos8C6e7r480lg&pullRequest=6685
val user: DownstreamUserDto?,
val user_id: String,

Check warning on line 39 in stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamReactionDto.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter to match the regular expression ^`?[_a-z][a-zA-Z0-9]*`?$

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-chat-android&issues=AaCAdUTos8C6e7r480lh&open=AaCAdUTos8C6e7r480lh&pullRequest=6685
// Note: This is not contextually a top-level field in the API, it should be inside `reaction.extraData`.
// But for convenience, we make it a top-level field here, because when serialized, it will be top-level in the
// JSON string.
val emoji_code: String?,

Check warning on line 43 in stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamReactionDto.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter to match the regular expression ^`?[_a-z][a-zA-Z0-9]*`?$

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-chat-android&issues=AaCAdUTos8C6e7r480li&open=AaCAdUTos8C6e7r480li&pullRequest=6685
val extraData: Map<String, Any>,
) : ExtraDataDto

@JsonClass(generateAdapter = true)
internal data class DownstreamReactionGroupDto(
val count: Int,
val sum_scores: Int,
val first_reaction_at: Date,
val last_reaction_at: Date,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import com.squareup.moshi.JsonClass
import io.getstream.chat.android.core.internal.StreamHandsOff
import io.getstream.chat.android.network.models.Attachment
import io.getstream.chat.android.network.models.ModerationV2Response
import io.getstream.chat.android.network.models.PollResponseData
import io.getstream.chat.android.network.models.ReactionGroupResponse
import java.util.Date

/**
Expand Down Expand Up @@ -58,7 +60,7 @@
val quoted_message_id: String?,
val reaction_counts: Map<String, Int>?,
val reaction_scores: Map<String, Int>?,
val reaction_groups: Map<String, DownstreamReactionGroupDto>?,
val reaction_groups: Map<String, ReactionGroupResponse>?,

Check warning on line 63 in stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/MessageDtos.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter to match the regular expression ^`?[_a-z][a-zA-Z0-9]*`?$

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-chat-android&issues=AaCAdUW2s8C6e7r480lj&open=AaCAdUW2s8C6e7r480lj&pullRequest=6685
val reply_count: Int,
val deleted_reply_count: Int,
val shadowed: Boolean = false,
Expand All @@ -70,7 +72,7 @@
val updated_at: Date,
val user: DownstreamUserDto,
val moderation_details: DownstreamModerationDetailsDto? = null, // Used for Moderation V1
val moderation: DownstreamModerationDto? = null, // Used for Moderation V2
val moderation: ModerationV2Response? = null, // Used for Moderation V2
val poll: PollResponseData? = null,
val reminder: DownstreamReminderInfoDto? = null,
val shared_location: DownstreamLocationDto? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 ModerationV2Response(
@Json(name = "action")
internal val action: String,

@Json(name = "original_text")
internal val originalText: String,

@Json(name = "blocklist_matched")
internal val blocklistMatched: String? = null,

@Json(name = "platform_circumvented")
internal val platformCircumvented: Boolean? = null,

@Json(name = "semantic_filter_matched")
internal val semanticFilterMatched: String? = null,

@Json(name = "blocklists_matched")
internal val blocklistsMatched: List<String>? = emptyList(),

@Json(name = "image_harms")
internal val imageHarms: List<String>? = emptyList(),

@Json(name = "text_harms")
internal val textHarms: List<String>? = emptyList(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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

/**
* ReactionGroupResponse contains all information about a reaction of the same type.
*/
@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class ReactionGroupResponse(
@Json(name = "count")
internal val count: Int,

@Json(name = "first_reaction_at")
internal val firstReactionAt: java.util.Date,

@Json(name = "last_reaction_at")
internal val lastReactionAt: java.util.Date,

@Json(name = "sum_scores")
internal val sumScores: Int,

@Json(name = "latest_reactions_by")
internal val latestReactionsBy: List<io.getstream.chat.android.network.models.ReactionGroupUserResponse> = emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,28 @@
* limitations under the License.
*/

package io.getstream.chat.android.client.api2.model.dto
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

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

import com.squareup.moshi.JsonClass
import com.squareup.moshi.Json

/**
* Downstream JSON holding the data related to Moderation V2.
* Contains information about a user who reacted with this reaction type.
*/
@JsonClass(generateAdapter = true)
internal data class DownstreamModerationDto(
val action: String,
val original_text: String,
val text_harms: List<String>?,
val image_harms: List<String>?,
val blocklist_matched: String?,
val semantic_filter_matched: String?,
val platform_circumvented: Boolean?,
@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class ReactionGroupUserResponse(
@Json(name = "created_at")
internal val createdAt: java.util.Date,

@Json(name = "user_id")
internal val userId: String,

@Json(name = "user")
internal val user: io.getstream.chat.android.network.models.UserResponse? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ import io.getstream.chat.android.client.api2.model.dto.DownstreamMemberDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamMemberInfoDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamMessageDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamModerationDetailsDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamModerationDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamMuteDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPendingMessageDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPollDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPollOptionDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamPushPreferenceDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamReactionDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamReactionGroupDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamReminderDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamThreadDto
import io.getstream.chat.android.client.api2.model.dto.DownstreamThreadInfoDto
Expand Down Expand Up @@ -100,11 +98,13 @@ import io.getstream.chat.android.network.models.FileUploadResponse
import io.getstream.chat.android.network.models.FullUserResponse
import io.getstream.chat.android.network.models.GetApplicationResponse
import io.getstream.chat.android.network.models.GetOGResponse
import io.getstream.chat.android.network.models.ModerationV2Response
import io.getstream.chat.android.network.models.PollOptionResponseData
import io.getstream.chat.android.network.models.PollResponseData
import io.getstream.chat.android.network.models.PollVoteResponseData
import io.getstream.chat.android.network.models.PollVotesResponse
import io.getstream.chat.android.network.models.QueryPollsResponse
import io.getstream.chat.android.network.models.ReactionGroupResponse
import io.getstream.chat.android.network.models.ReactionResponse
import io.getstream.chat.android.network.models.ThreadParticipant
import io.getstream.chat.android.network.models.UnblockUsersResponse
Expand Down Expand Up @@ -320,7 +320,7 @@ internal object Mother {
quoted_message_id: String? = randomString(),
reaction_counts: Map<String, Int>? = emptyMap(),
reaction_scores: Map<String, Int>? = emptyMap(),
reaction_groups: Map<String, DownstreamReactionGroupDto>? = emptyMap(),
reaction_groups: Map<String, ReactionGroupResponse>? = emptyMap(),
reply_count: Int = randomInt(),
deleted_reply_count: Int = randomInt(),
shadowed: Boolean = randomBoolean(),
Expand All @@ -332,7 +332,7 @@ internal object Mother {
updated_at: Date = randomDate(),
user: DownstreamUserDto = randomDownstreamUserDto(),
moderation_details: DownstreamModerationDetailsDto? = null,
moderation: DownstreamModerationDto? = null,
moderation: ModerationV2Response? = null,
poll: PollResponseData? = null,
member: DownstreamMemberInfoDto? = randomDownstreamMemberInfoDto(),
deleted_for_me: Boolean? = null,
Expand Down Expand Up @@ -698,16 +698,16 @@ internal object Mother {
expires = expires,
)

fun randomDownstreamReactionGroupDto(
fun randomReactionGroupResponse(
count: Int = randomInt(),
sumScores: Int = randomInt(),
firstReactionAt: Date = randomDate(),
lastReactionAt: Date = randomDate(),
): DownstreamReactionGroupDto = DownstreamReactionGroupDto(
): ReactionGroupResponse = ReactionGroupResponse(
count = count,
sum_scores = sumScores,
first_reaction_at = firstReactionAt,
last_reaction_at = lastReactionAt,
sumScores = sumScores,
firstReactionAt = firstReactionAt,
lastReactionAt = lastReactionAt,
)

fun randomChannelMemberResponse(
Expand Down Expand Up @@ -942,22 +942,22 @@ internal object Mother {
extraData = extraData,
)

fun randomDownstreamModerationDto(
fun randomModerationV2Response(
action: String = randomString(),
originalText: String = randomString(),
textHarms: List<String> = listOf(randomString()),
imageHarms: List<String> = listOf(randomString()),
blocklistMatched: String = randomString(),
semanticFilterMatched: String = randomString(),
platformCircumvented: Boolean = randomBoolean(),
): DownstreamModerationDto = DownstreamModerationDto(
): ModerationV2Response = ModerationV2Response(
action = action,
original_text = originalText,
text_harms = textHarms,
image_harms = imageHarms,
blocklist_matched = blocklistMatched,
semantic_filter_matched = semanticFilterMatched,
platform_circumvented = platformCircumvented,
originalText = originalText,
textHarms = textHarms,
imageHarms = imageHarms,
blocklistMatched = blocklistMatched,
semanticFilterMatched = semanticFilterMatched,
platformCircumvented = platformCircumvented,
)

fun randomPrivacySettingsDto(
Expand Down
Loading
Loading