Skip to content

Commit

Permalink
Merge branch 'release/1.5.11' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Dec 8, 2022
2 parents 6e87d1e + 0cac61c commit 1a098a6
Show file tree
Hide file tree
Showing 105 changed files with 2,760 additions and 599 deletions.
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
Please also refer to the Changelog of Element Android: https://github.com/vector-im/element-android/blob/main/CHANGES.md

Changes in Matrix-SDK v1.5.11 (2022-12-08)
=========================================

Imported from Element 1.5.11. (https://github.com/vector-im/element-android/releases/tag/v1.5.11)

SDK API changes ⚠️
------------------
- Added support for read receipts in threads. Now user in a room can have multiple read receipts (one per thread + one in main thread + one without threadId) ([#6996](https://github.com/vector-im/element-android/issues/6996))
- Sync Filter now taking in account homeserver capabilities to not pass unsupported parameters.
Sync Filter is now configured by providing SyncFilterBuilder class instance, instead of Filter to identify Filter changes related to homeserver capabilities ([#7626](https://github.com/vector-im/element-android/issues/7626))

Changes in Matrix-SDK v1.5.8 (2022-11-23)
=========================================

Expand Down
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def gradle = "7.3.1"
// Ref: https://kotlinlang.org/releases.html
def kotlin = "1.7.21"
def kotlinCoroutines = "1.6.4"
def dagger = "2.44"
def dagger = "2.44.2"
def appDistribution = "16.0.0-beta05"
def retrofit = "2.9.0"
def markwon = "4.6.2"
Expand Down Expand Up @@ -83,7 +83,7 @@ ext.libs = [
'appdistributionApi' : "com.google.firebase:firebase-appdistribution-api-ktx:$appDistribution",
'appdistribution' : "com.google.firebase:firebase-appdistribution:$appDistribution",
// Phone number https://github.com/google/libphonenumber
'phonenumber' : "com.googlecode.libphonenumber:libphonenumber:8.13.0"
'phonenumber' : "com.googlecode.libphonenumber:libphonenumber:8.13.1"
],
dagger : [
'dagger' : "com.google.dagger:dagger:$dagger",
Expand All @@ -98,7 +98,7 @@ ext.libs = [
],
element : [
'opusencoder' : "io.element.android:opusencoder:1.1.0",
'wysiwyg' : "io.element.android:wysiwyg:0.4.0"
'wysiwyg' : "io.element.android:wysiwyg:0.7.0.1"
],
squareup : [
'moshi' : "com.squareup.moshi:moshi:$moshi",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ vector.httpLogLevel=NONE
# Ref: https://github.com/vanniktech/gradle-maven-publish-plugin
GROUP=org.matrix.android
POM_ARTIFACT_ID=matrix-android-sdk2
VERSION_NAME=1.5.8
VERSION_NAME=1.5.11

POM_PACKAGING=aar

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.api.session.room.timeline.Timeline
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
import org.matrix.android.sdk.api.session.sync.filter.SyncFilterBuilder
import timber.log.Timber
import java.util.UUID
import java.util.concurrent.CountDownLatch
Expand Down Expand Up @@ -346,6 +347,10 @@ class CommonTestHelper internal constructor(context: Context, val cryptoConfig:
assertTrue(registrationResult is RegistrationResult.Success)
val session = (registrationResult as RegistrationResult.Success).session
session.open()
session.filterService().setSyncFilter(
SyncFilterBuilder()
.lazyLoadMembersForStateEvents(true)
)
if (sessionTestParams.withInitialSync) {
syncSession(session, 120_000)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright 2022 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 org.matrix.android.sdk.internal.database

import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import io.realm.Realm
import org.amshove.kluent.fail
import org.amshove.kluent.shouldBe
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldNotBe
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
import org.matrix.android.sdk.internal.database.mapper.EventMapper
import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntity
import org.matrix.android.sdk.internal.database.model.SessionRealmModule
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.util.Normalizer

@RunWith(AndroidJUnit4::class)
class RealmSessionStoreMigration43Test {

@get:Rule val configurationFactory = TestRealmConfigurationFactory()

lateinit var context: Context
var realm: Realm? = null

@Before
fun setUp() {
context = InstrumentationRegistry.getInstrumentation().context
}

@After
fun tearDown() {
realm?.close()
}

@Test
fun migrationShouldBeNeeed() {
val realmName = "session_42.realm"
val realmConfiguration = configurationFactory.createConfiguration(
realmName,
"efa9ab2c77ae06b0e767ffdb1c45b12be3c77d48d94f1ac41a7cd1d637fc59ac41f869a250453074e21ce13cfe7ed535593e7d150c08ce2bad7a2ab8c7b841f0",
SessionRealmModule(),
43,
null
)
configurationFactory.copyRealmFromAssets(context, realmName, realmName)

try {
realm = Realm.getInstance(realmConfiguration)
fail("Should need a migration")
} catch (failure: Throwable) {
// nop
}
}

// Database key for alias `session_db_e00482619b2597069b1f192b86de7da9`: efa9ab2c77ae06b0e767ffdb1c45b12be3c77d48d94f1ac41a7cd1d637fc59ac41f869a250453074e21ce13cfe7ed535593e7d150c08ce2bad7a2ab8c7b841f0
// $WEJ8U6Zsx3TDZx3qmHIOKh-mXe5kqL_MnPcIkStEwwI
// $11EtAQ8RYcudJVtw7e6B5Vm4ufCqKTOWKblY2U_wrpo
@Test
fun testMigration43() {
val realmName = "session_42.realm"
val migration = RealmSessionStoreMigration(Normalizer())
val realmConfiguration = configurationFactory.createConfiguration(
realmName,
"efa9ab2c77ae06b0e767ffdb1c45b12be3c77d48d94f1ac41a7cd1d637fc59ac41f869a250453074e21ce13cfe7ed535593e7d150c08ce2bad7a2ab8c7b841f0",
SessionRealmModule(),
43,
migration
)
configurationFactory.copyRealmFromAssets(context, realmName, realmName)

realm = Realm.getInstance(realmConfiguration)

// assert that the edit from 42 are migrated
val editions = EventAnnotationsSummaryEntity
.where(realm!!, "\$WEJ8U6Zsx3TDZx3qmHIOKh-mXe5kqL_MnPcIkStEwwI")
.findFirst()
?.editSummary
?.editions

editions shouldNotBe null
editions!!.size shouldBe 1
val firstEdition = editions.first()
firstEdition?.eventId shouldBeEqualTo "\$DvOyA8vJxwGfTaJG3OEJVcL4isShyaVDnprihy38W28"
firstEdition?.isLocalEcho shouldBeEqualTo false

val editEvent = EventMapper.map(firstEdition!!.event!!)
val body = editEvent.content.toModel<MessageContent>()?.body
body shouldBeEqualTo "* Message 2 with edit"

// assert that the edit from 42 are migrated
val editionsOfE2E = EventAnnotationsSummaryEntity
.where(realm!!, "\$11EtAQ8RYcudJVtw7e6B5Vm4ufCqKTOWKblY2U_wrpo")
.findFirst()
?.editSummary
?.editions

editionsOfE2E shouldNotBe null
editionsOfE2E!!.size shouldBe 1
val firstEditionE2E = editionsOfE2E.first()
firstEditionE2E?.eventId shouldBeEqualTo "\$HUwJOQRCJwfPv7XSKvBPcvncjM0oR3q2tGIIIdv9Zts"
firstEditionE2E?.isLocalEcho shouldBeEqualTo false

val editEventE2E = EventMapper.map(firstEditionE2E!!.event!!)
val body2 = editEventE2E.getClearContent().toModel<MessageContent>()?.body
body2 shouldBeEqualTo "* Message 2, e2e edit"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 org.matrix.android.sdk.internal.database

import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import io.realm.Realm
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.matrix.android.sdk.internal.database.model.SessionRealmModule
import org.matrix.android.sdk.internal.util.Normalizer

@RunWith(AndroidJUnit4::class)
class SessionSanityMigrationTest {

@get:Rule val configurationFactory = TestRealmConfigurationFactory()

lateinit var context: Context
var realm: Realm? = null

@Before
fun setUp() {
context = InstrumentationRegistry.getInstrumentation().context
}

@After
fun tearDown() {
realm?.close()
}

@Test
fun sessionDatabaseShouldMigrateGracefully() {
val realmName = "session_42.realm"
val migration = RealmSessionStoreMigration(Normalizer())
val realmConfiguration = configurationFactory.createConfiguration(
realmName,
"efa9ab2c77ae06b0e767ffdb1c45b12be3c77d48d94f1ac41a7cd1d637fc59ac41f869a250453074e21ce13cfe7ed535593e7d150c08ce2bad7a2ab8c7b841f0",
SessionRealmModule(),
migration.schemaVersion,
migration
)
configurationFactory.copyRealmFromAssets(context, realmName, realmName)

realm = Realm.getInstance(realmConfiguration)
}
}
Loading

0 comments on commit 1a098a6

Please sign in to comment.