From 20f86a30e8874db7f726c0ab33109b25a5ba5426 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 10 May 2021 13:31:38 +0200 Subject: [PATCH 1/4] Upgrade Realm to version 10.4.0 Migration with isEmbedded tested OK --- CHANGES.md | 1 + matrix-sdk-android/build.gradle | 7 ++----- .../sdk/internal/database/RealmSessionStoreMigration.kt | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b3f9615c70..43ab2ee975 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -34,6 +34,7 @@ SDK API changes ⚠️: Build 🧱: - Upgrade to gradle 7 - https://github.com/Piasy/BigImageViewer is now hosted on mavenCentral() + - Upgrade Realm to version 10.4.0 Test: - diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index 4059004394..108240f94d 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -6,13 +6,10 @@ apply plugin: 'realm-android' buildscript { repositories { - // mavenCentral() - //noinspection GrDeprecatedAPIUsage - jcenter() + mavenCentral() } dependencies { - // Stick to this version until https://github.com/realm/realm-java/issues/7402 is fixed - classpath "io.realm:realm-gradle-plugin:10.3.1" + classpath "io.realm:realm-gradle-plugin:10.4.0" } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt index 05213b40e5..8770dc8b33 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt @@ -144,10 +144,6 @@ class RealmSessionStoreMigration @Inject constructor() : RealmMigration { Timber.d("Step 7 -> 8") val editionOfEventSchema = realm.schema.create("EditionOfEvent") - .apply { - // setEmbedded does not return `this`... - isEmbedded = true - } .addField(EditionOfEventFields.CONTENT, String::class.java) .addField(EditionOfEventFields.EVENT_ID, String::class.java) .setRequired(EditionOfEventFields.EVENT_ID, true) @@ -162,6 +158,10 @@ class RealmSessionStoreMigration @Inject constructor() : RealmMigration { ?.removeField("lastEditTs") ?.removeField("sourceLocalEchoEvents") ?.addRealmListField(EditAggregatedSummaryEntityFields.EDITIONS.`$`, editionOfEventSchema) + + // This has to be done once a parent use the model as a child + // See https://github.com/realm/realm-java/issues/7402 + editionOfEventSchema.isEmbedded = true } private fun migrateTo9(realm: DynamicRealm) { From 87d35958c630c04b1afd986014b25c753e97f3cb Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 10 May 2021 16:34:30 +0300 Subject: [PATCH 2/4] Allow inviting users even if profile information cannot be retrieved. --- CHANGES.md | 1 + .../android/sdk/api/session/profile/ProfileService.kt | 1 + .../android/sdk/internal/session/profile/ProfileAPI.kt | 1 + .../app/features/userdirectory/UserListViewModel.kt | 10 +++++++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index b3f9615c70..642d5ef8b5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,7 @@ Bugfix 🐛: - Fix read marker not updating automatically (#3267) - Sent video does not contains duration (#3272) - Properly clean the back stack if the user cancel registration when waiting for email validation + - Fix user invitation in case of restricted profile api (#3306) Translations 🗣: - diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt index e493adeaf2..8401ba49eb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt @@ -66,6 +66,7 @@ interface ProfileService { /** * Get the combined profile information for this user. * This may return keys which are not limited to displayname or avatar_url. + * If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response will be HTTP 403. * @param userId the userId param to look for * */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt index 5113b821e8..7f4595caf5 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt @@ -33,6 +33,7 @@ internal interface ProfileAPI { * Get the combined profile information for this user. * This API may be used to fetch the user's own profile information or other users; either locally or on remote homeservers. * This API may return keys which are not limited to displayname or avatar_url. + * If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response will be HTTP 403. * @param userId the user id to fetch profile info */ @GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}") diff --git a/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt b/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt index a68717ea57..32771d784d 100644 --- a/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt @@ -137,7 +137,15 @@ class UserListViewModel @AssistedInject constructor(@Assisted initialState: User avatarUrl = json[ProfileService.AVATAR_URL_KEY] as? String ).toOptional() } - .onErrorReturn { Optional.empty() } + .onErrorReturn { + // Profile API can be restricted and doesn't have to return result. + // In this case allow inviting valid user ids. + User( + userId = search, + displayName = search, + avatarUrl = null + ).toOptional() + } Single.zip( searchObservable, From e74f4d570df5563c8de434b4509ef3efc8b7dcb4 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 10 May 2021 17:22:32 +0300 Subject: [PATCH 3/4] Lint fix. --- .../im/vector/app/features/userdirectory/UserListViewModel.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt b/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt index 32771d784d..e60d63f822 100644 --- a/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt @@ -33,7 +33,6 @@ import org.matrix.android.sdk.api.MatrixPatterns import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.profile.ProfileService import org.matrix.android.sdk.api.session.user.model.User -import org.matrix.android.sdk.api.util.Optional import org.matrix.android.sdk.api.util.toMatrixItem import org.matrix.android.sdk.api.util.toOptional import org.matrix.android.sdk.rx.rx From 0f8a6415109e99cced2f4010c8280d249a075890 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 10 May 2021 17:38:40 +0300 Subject: [PATCH 4/4] Code review fixes. --- .../matrix/android/sdk/api/session/profile/ProfileService.kt | 2 +- .../matrix/android/sdk/internal/session/profile/ProfileAPI.kt | 2 +- .../im/vector/app/features/userdirectory/UserListViewModel.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt index 8401ba49eb..05fa24946a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/profile/ProfileService.kt @@ -66,7 +66,7 @@ interface ProfileService { /** * Get the combined profile information for this user. * This may return keys which are not limited to displayname or avatar_url. - * If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response will be HTTP 403. + * If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response can be HTTP 403. * @param userId the userId param to look for * */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt index 7f4595caf5..485a4973ca 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt @@ -33,7 +33,7 @@ internal interface ProfileAPI { * Get the combined profile information for this user. * This API may be used to fetch the user's own profile information or other users; either locally or on remote homeservers. * This API may return keys which are not limited to displayname or avatar_url. - * If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response will be HTTP 403. + * If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response can be HTTP 403. * @param userId the user id to fetch profile info */ @GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}") diff --git a/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt b/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt index e60d63f822..5d5247ec06 100644 --- a/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/userdirectory/UserListViewModel.kt @@ -141,7 +141,7 @@ class UserListViewModel @AssistedInject constructor(@Assisted initialState: User // In this case allow inviting valid user ids. User( userId = search, - displayName = search, + displayName = null, avatarUrl = null ).toOptional() }