Skip to content

Commit a8c53db

Browse files
authored
Merge branch 'v6' into feature/new_event_parsing
2 parents 99a8ba0 + 988fb0f commit a8c53db

10 files changed

Lines changed: 63 additions & 33 deletions

File tree

.github/workflows/pr-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ concurrency:
88

99
jobs:
1010
base-android-ci:
11-
uses: GetStream/stream-build-conventions-android/.github/workflows/android-ci.yml@v0.10.0
11+
uses: GetStream/stream-build-conventions-android/.github/workflows/android-ci.yml@v0.12.1
1212
secrets: inherit
1313

1414
detekt:
1515
name: Detekt
1616
runs-on: ubuntu-22.04
1717
steps:
1818
- uses: actions/checkout@v4.2.2
19-
- uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@v0.10.0
19+
- uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@v0.12.1
2020
- name: Detekt
2121
run: ./gradlew detekt
2222

.github/workflows/pr-cleanup.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ on:
88
permissions:
99
contents: write
1010
pull-requests: write
11-
issues: write
1211

1312
jobs:
1413
pr-clean-stale:
15-
uses: GetStream/stream-build-conventions-android/.github/workflows/pr-clean-stale.yaml@v0.10.0
14+
uses: GetStream/stream-build-conventions-android/.github/workflows/pr-clean-stale.yaml@v0.12.1
1615
secrets: inherit

.github/workflows/pr-quality.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ on:
77
permissions:
88
contents: read
99
pull-requests: write
10-
issues: write
1110

1211
concurrency:
1312
group: ${{ github.workflow }}-${{ github.ref }}
1413
cancel-in-progress: true
1514

1615
jobs:
1716
pr-checklist:
18-
uses: GetStream/stream-build-conventions-android/.github/workflows/pr-quality.yml@v0.10.0
17+
uses: GetStream/stream-build-conventions-android/.github/workflows/pr-quality.yml@v0.12.1
1918
secrets: inherit

.github/workflows/publish-new-version.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
permissions:
3131
contents: write
3232
needs: pre_release_check
33-
uses: GetStream/stream-build-conventions-android/.github/workflows/release.yml@v0.10.0
33+
uses: GetStream/stream-build-conventions-android/.github/workflows/release.yml@v0.12.1
3434
with:
3535
bump: ${{ inputs.bump }}
3636
secrets:
@@ -40,3 +40,4 @@ jobs:
4040
signing-key: ${{ secrets.SIGNING_KEY }}
4141
signing-key-id: ${{ secrets.SIGNING_KEY_ID }}
4242
signing-key-password: ${{ secrets.SIGNING_PASSWORD }}
43+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_ANDROID_CICD }}

.github/workflows/publish-snapshot.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@ on:
66
- develop
77
workflow_dispatch:
88

9+
concurrency:
10+
group: snapshot-release
11+
cancel-in-progress: false
12+
913
jobs:
10-
publish:
11-
name: Snapshot build and publish
12-
runs-on: ubuntu-24.04
13-
steps:
14-
- name: Check out code
15-
uses: actions/checkout@v3.1.0
16-
- uses: GetStream/android-ci-actions/actions/setup-java@main
17-
- name: Publish to MavenCentral
18-
run: ./gradlew publishToMavenCentral
19-
env:
20-
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
21-
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
22-
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
23-
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
24-
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
25-
ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: true
26-
SNAPSHOT: true
27-
- name: Show snapshot version
28-
run: ./scripts/show-last-snapshot-update.sh
29-
env:
30-
SNAPSHOT: true
14+
release:
15+
permissions:
16+
contents: write
17+
uses: GetStream/stream-build-conventions-android/.github/workflows/release.yml@v0.12.1
18+
with:
19+
bump: patch
20+
snapshot: true
21+
secrets:
22+
github-token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
23+
maven-central-username: ${{ secrets.OSSRH_USERNAME }}
24+
maven-central-password: ${{ secrets.OSSRH_PASSWORD }}
25+
signing-key: ${{ secrets.SIGNING_KEY }}
26+
signing-key-id: ${{ secrets.SIGNING_KEY_ID }}
27+
signing-key-password: ${{ secrets.SIGNING_PASSWORD }}
28+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_ANDROID_CICD }}

.github/workflows/sdk-size-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ concurrency:
99

1010
jobs:
1111
compare-sdk-sizes:
12-
uses: GetStream/stream-build-conventions-android/.github/workflows/sdk-size-checks.yml@v0.10.0
12+
uses: GetStream/stream-build-conventions-android/.github/workflows/sdk-size-checks.yml@v0.12.1
1313
with:
1414
modules: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose"
1515
metrics-project: "stream-chat-android-metrics"

.github/workflows/sdk-size-updates.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313

1414
jobs:
1515
update-sdk-sizes:
16-
uses: GetStream/stream-build-conventions-android/.github/workflows/sdk-size-updates.yml@v0.10.0
16+
uses: GetStream/stream-build-conventions-android/.github/workflows/sdk-size-updates.yml@v0.12.1
1717
with:
1818
modules: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose"
1919
metrics-project: "stream-chat-android-metrics"

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ room = "2.6.1"
7878
shimmer = "0.5.0"
7979
shimmerCompose = "1.3.1"
8080
shot = "6.1.0"
81-
streamConventions = "0.10.0"
81+
streamConventions = "0.12.1"
8282
streamLog = "1.3.2"
8383
streamPush = "1.3.1"
8484
streamResult = "1.3.2"

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import io.getstream.chat.android.models.Member
4343
import io.getstream.chat.android.models.MemberData
4444
import io.getstream.chat.android.models.Message
4545
import io.getstream.chat.android.models.MessageTransformer
46+
import io.getstream.chat.android.models.MessageType
4647
import io.getstream.chat.android.models.Mute
4748
import io.getstream.chat.android.models.Reaction
4849
import io.getstream.chat.android.models.User
@@ -53,6 +54,8 @@ internal class DtoMapping(
5354
private val userTransformer: UserTransformer,
5455
) {
5556

57+
private val supportedUpstreamMessageTypes = setOf(MessageType.REGULAR, MessageType.SYSTEM)
58+
5659
/**
5760
* Converts [Attachment] to [AttachmentDto].
5861
*/
@@ -121,13 +124,14 @@ internal class DtoMapping(
121124
internal fun Message.toDto(): UpstreamMessageDto =
122125
messageTransformer.transform(this)
123126
.run {
127+
val upstreamType = if (type in supportedUpstreamMessageTypes) type else ""
124128
UpstreamMessageDto(
125129
attachments = attachments.map { it.toDto() },
126130
cid = cid,
127131
command = command,
128132
html = html,
129133
id = id,
130-
type = type,
134+
type = upstreamType,
131135
mentioned_users = mentionedUsersIds,
132136
parent_id = parentId,
133137
pin_expires = pinExpires,

stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DtoMappingTest.kt

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import io.getstream.chat.android.client.api2.model.dto.UpstreamReactionDto
3535
import io.getstream.chat.android.client.api2.model.dto.UpstreamUserDto
3636
import io.getstream.chat.android.client.test.randomConnectedEvent
3737
import io.getstream.chat.android.models.MessageTransformer
38+
import io.getstream.chat.android.models.MessageType
3839
import io.getstream.chat.android.models.NoOpMessageTransformer
3940
import io.getstream.chat.android.models.NoOpUserTransformer
4041
import io.getstream.chat.android.models.UserTransformer
@@ -49,6 +50,9 @@ import io.getstream.chat.android.randomReaction
4950
import io.getstream.chat.android.randomUser
5051
import org.amshove.kluent.shouldBeEqualTo
5152
import org.junit.jupiter.api.Test
53+
import org.junit.jupiter.params.ParameterizedTest
54+
import org.junit.jupiter.params.provider.Arguments
55+
import org.junit.jupiter.params.provider.MethodSource
5256
import org.mockito.kotlin.spy
5357
import org.mockito.kotlin.times
5458
import org.mockito.kotlin.verify
@@ -167,7 +171,7 @@ internal class DtoMappingTest {
167171
@Test
168172
fun `Message is correctly mapped to Dto`() {
169173
val messageTransformer = spy(NoOpMessageTransformer)
170-
val message = randomMessage()
174+
val message = randomMessage(type = MessageType.REGULAR)
171175
val mapping = Fixture()
172176
.withMessageTransformer(messageTransformer)
173177
.get()
@@ -201,6 +205,17 @@ internal class DtoMappingTest {
201205
verify(messageTransformer, times(1)).transform(message)
202206
}
203207

208+
@ParameterizedTest
209+
@MethodSource("messageTypeCoercionInput")
210+
fun `Message toDto coerces type to allowed upstream values`(inputType: String, expectedType: String) {
211+
val message = randomMessage(type = inputType)
212+
val mapping = Fixture().get()
213+
214+
val dto = with(mapping) { message.toDto() }
215+
216+
dto.type shouldBeEqualTo expectedType
217+
}
218+
204219
@Test
205220
fun `Mute is correctly mapped to Dto`() {
206221
val mute = randomMute()
@@ -311,6 +326,20 @@ internal class DtoMappingTest {
311326
dto shouldBeEqualTo expected
312327
}
313328

329+
companion object {
330+
@JvmStatic
331+
fun messageTypeCoercionInput(): List<Arguments> = listOf(
332+
Arguments.of(MessageType.REGULAR, MessageType.REGULAR),
333+
Arguments.of(MessageType.SYSTEM, MessageType.SYSTEM),
334+
Arguments.of(MessageType.REPLY, ""),
335+
Arguments.of(MessageType.EPHEMERAL, ""),
336+
Arguments.of(MessageType.ERROR, ""),
337+
Arguments.of(MessageType.FAILED, ""),
338+
Arguments.of("some-unknown-type", ""),
339+
Arguments.of("", ""),
340+
)
341+
}
342+
314343
internal class Fixture {
315344

316345
private var messageTransformer: MessageTransformer = NoOpMessageTransformer

0 commit comments

Comments
 (0)