Merge remote-tracking branch 'origin/develop' into HEAD · GetStream/stream-chat-android@3ef2163 · GitHub
Skip to content

Commit 3ef2163

Browse files
committed
Merge remote-tracking branch 'origin/develop' into HEAD
# Conflicts: # stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/ChannelApi.kt # stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt # stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTestArguments.kt
2 parents 6dfafe5 + 7750e4b commit 3ef2163

30 files changed

Lines changed: 459 additions & 121 deletions

File tree

‎metrics/size.json‎

Lines changed: 1 addition & 1 deletion

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/ChannelApi.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import io.getstream.chat.android.client.api2.UrlQueryPayload
2222
import io.getstream.chat.android.client.api2.model.requests.PinnedMessagesRequest
2323
import io.getstream.chat.android.client.api2.model.response.ChannelResponse
2424
import io.getstream.chat.android.client.api2.model.response.EventResponse
25-
import io.getstream.chat.android.client.api2.model.response.MessagesResponse
2625
import io.getstream.chat.android.client.call.RetrofitCall
2726
import io.getstream.chat.android.network.models.ChannelGetOrCreateRequest
2827
import io.getstream.chat.android.network.models.ChannelStateResponse
28+
import io.getstream.chat.android.network.models.GetPinnedMessagesResponse
2929
import io.getstream.chat.android.network.models.GroupedQueryChannelsRequest
3030
import io.getstream.chat.android.network.models.GroupedQueryChannelsResponse
3131
import io.getstream.chat.android.network.models.HideChannelRequest
@@ -180,7 +180,7 @@ internal interface ChannelApi {
180180
@Path("type") channelType: String,
181181
@Path("id") channelId: String,
182182
@UrlQueryPayload @Query("payload") payload: PinnedMessagesRequest,
183-
): RetrofitCall<MessagesResponse>
183+
): RetrofitCall<GetPinnedMessagesResponse>
184184

185185
@POST("/channels/delivered")
186186
fun markDelivered(

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/MessageApi.kt‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ package io.getstream.chat.android.client.api2.endpoint
1818

1919
import io.getstream.chat.android.client.api.AuthenticatedApi
2020
import io.getstream.chat.android.client.api2.model.response.MessageResponse
21-
import io.getstream.chat.android.client.api2.model.response.MessagesResponse
22-
import io.getstream.chat.android.client.api2.model.response.ReactionResponse
2321
import io.getstream.chat.android.client.call.RetrofitCall
2422
import io.getstream.chat.android.network.models.CreateDraftResponse
2523
import io.getstream.chat.android.network.models.GetReactionsResponse
24+
import io.getstream.chat.android.network.models.GetRepliesResponse
2625
import io.getstream.chat.android.network.models.MessageActionRequest
2726
import io.getstream.chat.android.network.models.QueryDraftsRequest
2827
import io.getstream.chat.android.network.models.QueryDraftsResponse
@@ -31,6 +30,7 @@ import io.getstream.chat.android.network.models.QueryReactionsResponse
3130
import io.getstream.chat.android.network.models.Response
3231
import io.getstream.chat.android.network.models.SendMessageRequest
3332
import io.getstream.chat.android.network.models.SendReactionRequest
33+
import io.getstream.chat.android.network.models.SendReactionResponse
3434
import io.getstream.chat.android.network.models.TranslateMessageRequest
3535
import io.getstream.chat.android.network.models.UpdateMessagePartialRequest
3636
import io.getstream.chat.android.network.models.UpdateMessageRequest
@@ -114,7 +114,7 @@ internal interface MessageApi {
114114
fun sendReaction(
115115
@Path("id") messageId: String,
116116
@Body request: SendReactionRequest,
117-
): RetrofitCall<ReactionResponse>
117+
): RetrofitCall<SendReactionResponse>
118118

119119
@DELETE("/messages/{id}/reaction/{type}")
120120
fun deleteReaction(
@@ -145,26 +145,26 @@ internal interface MessageApi {
145145
fun getReplies(
146146
@Path("parent_id") messageId: String,
147147
@Query("limit") limit: Int,
148-
): RetrofitCall<MessagesResponse>
148+
): RetrofitCall<GetRepliesResponse>
149149

150150
@GET("/messages/{parent_id}/replies?sort=[{\"field\":\"created_at\",\"direction\":1}]")
151151
fun getNewerReplies(
152152
@Path("parent_id") parentId: String,
153153
@Query("limit") limit: Int,
154154
@Query("id_gt") lastId: String?,
155-
): RetrofitCall<MessagesResponse>
155+
): RetrofitCall<GetRepliesResponse>
156156

157157
@GET("/messages/{parent_id}/replies")
158158
fun getRepliesMore(
159159
@Path("parent_id") messageId: String,
160160
@Query("limit") limit: Int,
161161
@Query("id_lt") firstId: String,
162-
): RetrofitCall<MessagesResponse>
162+
): RetrofitCall<GetRepliesResponse>
163163

164164
@GET("/messages/{parent_id}/replies")
165165
fun getRepliesAround(
166166
@Path("parent_id") parentId: String,
167167
@Query("limit") limit: Int,
168168
@Query("id_around") aroundId: String,
169-
): RetrofitCall<MessagesResponse>
169+
): RetrofitCall<GetRepliesResponse>
170170
}

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,9 +1228,10 @@ internal class DomainMapping(
12281228
originalText = originalText,
12291229
textHarms = textHarms.orEmpty(),
12301230
imageHarms = imageHarms.orEmpty(),
1231-
blocklistMatched = blocklistMatched,
1231+
blocklistMatched = blocklistMatched ?: blocklistsMatched?.firstOrNull(),
12321232
semanticFilterMatched = semanticFilterMatched,
12331233
platformCircumvented = platformCircumvented ?: false,
1234+
blocklistsMatched = blocklistsMatched.orEmpty(),
12341235
)
12351236

12361237
/**

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/offline/repository/database/converter/internal/LocationConverter.kt‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,11 @@ internal class LocationConverter {
2525
@OptIn(ExperimentalStdlibApi::class)
2626
private val entityAdapter = moshi.adapter<LocationEntity>()
2727

28-
@OptIn(ExperimentalStdlibApi::class)
29-
private val entityListAdapter = moshi.adapter<List<LocationEntity>>()
30-
3128
@TypeConverter
3229
fun stringToLocation(json: String?): LocationEntity? =
3330
json?.let(entityAdapter::fromJson)
3431

3532
@TypeConverter
3633
fun locationToString(entity: LocationEntity?): String? =
3734
entity?.let(entityAdapter::toJson)
38-
39-
@TypeConverter
40-
fun stringToLocationList(json: String?): List<LocationEntity>? =
41-
if (json.isNullOrEmpty() || json == "null") {
42-
emptyList()
43-
} else {
44-
entityListAdapter.fromJson(json)
45-
}
46-
47-
@TypeConverter
48-
fun locationListToString(entities: List<LocationEntity>?): String? =
49-
entities?.let(entityListAdapter::toJson)
5035
}

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/offline/repository/database/internal/ChatDatabase.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ import io.getstream.chat.android.client.internal.offline.repository.domain.user.
9090
ThreadOrderEntity::class,
9191
DraftMessageEntity::class,
9292
],
93-
version = 205,
93+
version = 206,
9494
exportSchema = false,
9595
)
9696
@TypeConverters(

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/offline/repository/domain/channel/internal/ChannelEntity.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ import androidx.room.Index
2121
import androidx.room.PrimaryKey
2222
import io.getstream.chat.android.client.internal.offline.repository.domain.channel.member.internal.MemberEntity
2323
import io.getstream.chat.android.client.internal.offline.repository.domain.channel.userread.internal.ChannelUserReadEntity
24-
import io.getstream.chat.android.client.internal.offline.repository.domain.message.internal.LocationEntity
2524
import io.getstream.chat.android.models.SyncStatus
2625
import java.util.Date
2726

2827
/**
2928
* ChannelEntity stores both the channel information as well as references to all of the channel's state.
3029
* Messages are stored on their own table for easier pagination and updates.
3130
*
31+
* Active live locations are not stored: stopping one does not update the stored channel, so a stored copy could
32+
* bring back a stopped location after a restart.
33+
*
3234
* @param type Type of the channel.
3335
* @param channelId Channel's unique ID.
3436
* @param name Channel's name.
@@ -58,7 +60,6 @@ import java.util.Date
5860
* @param ownCapabilities Channel's capabilities available for the current user. Note that the field is not provided in
5961
* the events.
6062
* @param membership Represents relationship of the current user to this channel.
61-
* @param activeLiveLocations List of active live locations in the channel.
6263
* @param messageCount The total number of messages in the channel, if known.
6364
*/
6465
@Entity(tableName = CHANNEL_ENTITY_TABLE_NAME, indices = [Index(value = ["syncStatus"])])
@@ -91,7 +92,6 @@ internal data class ChannelEntity(
9192
val team: String,
9293
val ownCapabilities: Set<String>,
9394
val membership: MemberEntity?,
94-
val activeLiveLocations: List<LocationEntity>,
9595
val messageCount: Int?,
9696
) {
9797
/**

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/offline/repository/domain/channel/internal/ChannelMapper.kt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ internal fun Channel.toEntity(): ChannelEntity {
6565
team = team,
6666
ownCapabilities = ownCapabilities,
6767
membership = membership?.toEntity(),
68-
activeLiveLocations = activeLiveLocations.map { it.toEntity() },
6968
messageCount = messageCount,
7069
)
7170
}
@@ -104,6 +103,5 @@ internal suspend fun ChannelEntity.toModel(
104103
ownCapabilities = ownCapabilities,
105104
membership = membership?.toModel(getUser),
106105
draftMessage = getDraftMessage(channelId),
107-
activeLiveLocations = activeLiveLocations.map { it.toModel() },
108106
messageCount = messageCount,
109107
).syncUnreadCountWithReads()

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/offline/repository/domain/channel/internal/DatabaseChannelRepository.kt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ internal class DatabaseChannelRepository(
7676
val updatedChannels = channels
7777
.map { channelCache[it.cid]?.let { cachedChannel -> it.combine(cachedChannel) } ?: it }
7878
.map { if (it.isReadTrackedLocally()) it.preserveLocallyTrackedReads(storedReadsByCid[it.cid]) else it }
79+
// Cleared before the comparison below, as the cached copies hold no live locations.
80+
.map { it.copy(activeLiveLocations = emptyList()) }
7981
updatedChannels
8082
.filter { channelCache[it.cid] != it }
8183
.also { cacheChannel(updatedChannels) }
@@ -147,11 +149,12 @@ internal class DatabaseChannelRepository(
147149
}
148150

149151
private fun cacheChannel(vararg channels: Channel) {
150-
channels.forEach { channelCache.put(it.cid, it) }
152+
cacheChannel(channels.asList())
151153
}
152154

153155
private fun cacheChannel(channels: Collection<Channel>) {
154-
channels.forEach { channelCache.put(it.cid, it) }
156+
// Live locations are not cached, for the same reason they are not stored (see ChannelEntity).
157+
channels.forEach { channelCache.put(it.cid, it.copy(activeLiveLocations = emptyList())) }
155158
}
156159

157160
/**

‎stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/offline/repository/domain/message/internal/ModerationEntity.kt‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)