-
Notifications
You must be signed in to change notification settings - Fork 320
Migrate the thread channel to the generated ChannelResponse model #6635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2d1e74d
Migrate the thread channel to the generated ChannelResponse model
gpunto edfd322
Keep the generated channel and member wire keys in extraData
gpunto b127160
Point the extraData keep sets at the ticket that removes them
gpunto 64b89af
Read the adapted model from the adapter's declared type parameter
gpunto 9d89df6
Map the channel config message retention now that the spec declares it
gpunto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...in/java/io/getstream/chat/android/client/parser2/adapters/ChannelMemberResponseAdapter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.client.parser2.adapters | ||
|
|
||
| import com.squareup.moshi.FromJson | ||
| import com.squareup.moshi.JsonAdapter | ||
| import com.squareup.moshi.JsonReader | ||
| import com.squareup.moshi.JsonWriter | ||
| import com.squareup.moshi.ToJson | ||
| import io.getstream.chat.android.network.models.ChannelMemberResponse | ||
|
|
||
| /** | ||
| * Keys `ChannelMemberResponse` declares that `DownstreamMemberDto` did not, so they used to reach | ||
| * `Member.extraData` and would otherwise stop doing so. Only `user_id` is read at all, as the fallback | ||
| * for the user id when the payload carries no user, and that does not restore the map an app may already | ||
| * read. Drop with AND-1398. | ||
| */ | ||
| internal val GENERATED_MEMBER_EXTRA_DATA_KEYS = setOf( | ||
| "deleted_at", | ||
| "deleted_messages", | ||
| "is_moderator", | ||
| "role", | ||
| "user_id", | ||
| ) | ||
|
|
||
| // Downstream (read-only) adapter for the generated ChannelMemberResponse: collects root-level custom fields | ||
| // into `custom`, matching the wire's flattened extra data. extraDataPropertyName is its @Json name. | ||
| internal object ChannelMemberResponseAdapter : | ||
| CustomObjectDtoAdapter<ChannelMemberResponse>( | ||
| ChannelMemberResponse::class, | ||
| extraDataPropertyName = "custom", | ||
| alsoKeepInExtraData = GENERATED_MEMBER_EXTRA_DATA_KEYS, | ||
| ) { | ||
|
|
||
| @FromJson | ||
| fun fromJson( | ||
| jsonReader: JsonReader, | ||
| mapAdapter: JsonAdapter<MutableMap<String, Any>>, | ||
| valueAdapter: JsonAdapter<ChannelMemberResponse>, | ||
| ): ChannelMemberResponse? = parseWithExtraData(jsonReader, mapAdapter, valueAdapter) | ||
|
|
||
| @ToJson | ||
| @Suppress("UNUSED_PARAMETER") | ||
| fun toJson(jsonWriter: JsonWriter, value: ChannelMemberResponse): Unit = error("Can't convert this to Json") | ||
| } |
60 changes: 60 additions & 0 deletions
60
...src/main/java/io/getstream/chat/android/client/parser2/adapters/ChannelResponseAdapter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.client.parser2.adapters | ||
|
|
||
| import com.squareup.moshi.FromJson | ||
| import com.squareup.moshi.JsonAdapter | ||
| import com.squareup.moshi.JsonReader | ||
| import com.squareup.moshi.JsonWriter | ||
| import com.squareup.moshi.ToJson | ||
| import io.getstream.chat.android.network.models.ChannelResponse | ||
|
|
||
| /** | ||
| * Keys `ChannelResponse` declares that `DownstreamChannelDto` did not, so they used to reach | ||
| * `Channel.extraData` and would otherwise stop doing so. Kept there as well as mapped, matching how | ||
| * [LEGACY_CHANNEL_EXTRA_DATA_KEYS] treats the keys the hand-written DTO declared. Drop with AND-1398. | ||
| */ | ||
| internal val GENERATED_CHANNEL_EXTRA_DATA_KEYS = setOf( | ||
| "auto_translation_enabled", | ||
| "auto_translation_language", | ||
| "hidden", | ||
| "hide_messages_before", | ||
| "mute_expires_at", | ||
| "muted", | ||
| "truncated_by", | ||
| ) | ||
|
|
||
| // Downstream (read-only) adapter for the generated ChannelResponse: collects root-level custom fields | ||
| // into `custom`, matching the wire's flattened extra data. extraDataPropertyName is its @Json name. | ||
| internal object ChannelResponseAdapter : | ||
| CustomObjectDtoAdapter<ChannelResponse>( | ||
| ChannelResponse::class, | ||
| extraDataPropertyName = "custom", | ||
| alsoKeepInExtraData = LEGACY_CHANNEL_EXTRA_DATA_KEYS + GENERATED_CHANNEL_EXTRA_DATA_KEYS, | ||
| ) { | ||
|
|
||
| @FromJson | ||
| fun fromJson( | ||
| jsonReader: JsonReader, | ||
| mapAdapter: JsonAdapter<MutableMap<String, Any>>, | ||
| valueAdapter: JsonAdapter<ChannelResponse>, | ||
| ): ChannelResponse? = parseWithExtraData(jsonReader, mapAdapter, valueAdapter) | ||
|
|
||
| @ToJson | ||
| @Suppress("UNUSED_PARAMETER") | ||
| fun toJson(jsonWriter: JsonWriter, value: ChannelResponse): Unit = error("Can't convert this to Json") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.