Skip to content

Commit

Permalink
Merge branch 'release/1.5.25' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Feb 16, 2023
2 parents 89e0d7e + df2d782 commit b3ab19c
Show file tree
Hide file tree
Showing 39 changed files with 1,648 additions and 140 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.25 (2023-02-16)
=========================================

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

SDK API changes ⚠️
------------------
- [Poll] Adding PollHistoryService ([#7864](https://github.com/vector-im/element-android/issues/7864))
- [Push rules] Call /actions api before /enabled api ([#8005](https://github.com/vector-im/element-android/issues/8005))


Changes in Matrix-SDK v1.5.22 (2023-01-30)
=========================================

Expand Down
14 changes: 7 additions & 7 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ ext.versions = [
'targetCompat' : JavaVersion.VERSION_11,
]

def gradle = "7.3.1"
def gradle = "7.4.1"
// Ref: https://kotlinlang.org/releases.html
def kotlin = "1.8.0"
def kotlin = "1.8.10"
def kotlinCoroutines = "1.6.4"
def dagger = "2.44.2"
def firebaseBom = "31.2.0"
Expand All @@ -18,7 +18,7 @@ def markwon = "4.6.2"
def moshi = "1.14.0"
def lifecycle = "2.5.1"
def flowBinding = "1.2.0"
def flipper = "0.177.0"
def flipper = "0.178.1"
def epoxy = "5.0.0"
def mavericks = "3.0.1"
def glide = "4.14.2"
Expand All @@ -27,15 +27,15 @@ def jjwt = "0.11.5"
// Temporary version to unblock #6929. Once 0.16.0 is released we should use it, and revert
// the whole commit which set version 0.16.0-SNAPSHOT
def vanniktechEmoji = "0.16.0-SNAPSHOT"
def sentry = "6.12.1"
def sentry = "6.13.0"
// Use 1.6.0 alpha to fix issue with test
def fragment = "1.6.0-alpha04"
// Testing
def mockk = "1.12.3" // We need to use 1.12.3 to have mocking in androidTest until a new version is released: https://github.com/mockk/mockk/issues/819
def espresso = "3.5.1"
def androidxTest = "1.5.0"
def androidxOrchestrator = "1.4.2"
def paparazzi = "1.1.0"
def paparazzi = "1.2.0"

ext.libs = [
gradle : [
Expand Down Expand Up @@ -82,7 +82,7 @@ ext.libs = [
'transition' : "androidx.transition:transition:1.2.0",
],
google : [
'material' : "com.google.android.material:material:1.7.0",
'material' : "com.google.android.material:material:1.8.0",
'firebaseBom' : "com.google.firebase:firebase-bom:$firebaseBom",
'messaging' : "com.google.firebase:firebase-messaging",
'appdistributionApi' : "com.google.firebase:firebase-appdistribution-api-ktx:$appDistribution",
Expand All @@ -103,7 +103,7 @@ ext.libs = [
],
element : [
'opusencoder' : "io.element.android:opusencoder:1.1.0",
'wysiwyg' : "io.element.android:wysiwyg:0.18.0"
'wysiwyg' : "io.element.android:wysiwyg:0.23.0"
],
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.22
VERSION_NAME=1.5.25

POM_PACKAGING=aar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ interface EventService {
roomId: String,
eventId: String
): Event

/**
* Get an Event from cache. Return null if not found.
*/
fun getEventFromCache(
roomId: String,
eventId: String
): Event?
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package org.matrix.android.sdk.api.session.pushrules

import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.internal.di.MoshiProvider
import org.matrix.android.sdk.internal.util.caseInsensitiveFind
import org.matrix.android.sdk.internal.util.hasSpecialGlobChar
import org.matrix.android.sdk.internal.util.simpleGlobToRegExp
import timber.log.Timber

Expand All @@ -31,40 +29,43 @@ class EventMatchCondition(
* The glob-style pattern to match against. Patterns with no special glob characters should
* be treated as having asterisks prepended and appended when testing the condition.
*/
val pattern: String,
/**
* true to match only words. In this case pattern will not be considered as a glob
*/
val wordsOnly: Boolean
val pattern: String
) : Condition {

override fun isSatisfied(event: Event, conditionResolver: ConditionResolver): Boolean {
return conditionResolver.resolveEventMatchCondition(event, this)
}

override fun technicalDescription() = "'$key' matches '$pattern', words only '$wordsOnly'"
override fun technicalDescription() = "'$key' matches '$pattern'"

fun isSatisfied(event: Event): Boolean {
// TODO encrypted events?
val rawJson = MoshiProvider.providesMoshi().adapter(Event::class.java).toJsonValue(event) as? Map<*, *>
?: return false
val value = extractField(rawJson, key) ?: return false

// Patterns with no special glob characters should be treated as having asterisks prepended
// and appended when testing the condition.
// The match is performed case-insensitively, and must match the entire value of
// the event field given by `key` (though see below regarding `content.body`). The
// exact meaning of "case insensitive" is defined by the implementation of the
// homeserver.
//
// As a special case, if `key` is `content.body`, then `pattern` must instead
// match any substring of the value of the property which starts and ends at a
// word boundary.
return try {
if (wordsOnly) {
value.caseInsensitiveFind(pattern)
} else {
val modPattern = if (pattern.hasSpecialGlobChar()) {
if (key == "content.body") {
val modPattern = if (pattern.startsWith("*") && pattern.endsWith("*")) {
// Regex.containsMatchIn() is way faster without leading and trailing
// stars, that don't make any difference for the evaluation result
pattern.removePrefix("*").removeSuffix("*").simpleGlobToRegExp()
} else {
pattern.simpleGlobToRegExp()
"(\\W|^)" + pattern.simpleGlobToRegExp() + "(\\W|$)"
}
val regex = Regex(modPattern, RegexOption.DOT_MATCHES_ALL)
val regex = Regex(modPattern, setOf(RegexOption.DOT_MATCHES_ALL, RegexOption.IGNORE_CASE))
regex.containsMatchIn(value)
} else {
val regex = Regex(pattern.simpleGlobToRegExp(), setOf(RegexOption.DOT_MATCHES_ALL, RegexOption.IGNORE_CASE))
regex.matches(value)
}
} catch (e: Throwable) {
// e.g PatternSyntaxException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.matrix.android.sdk.api.session.pushrules.ContainsDisplayNameCondition
import org.matrix.android.sdk.api.session.pushrules.EventMatchCondition
import org.matrix.android.sdk.api.session.pushrules.Kind
import org.matrix.android.sdk.api.session.pushrules.RoomMemberCountCondition
import org.matrix.android.sdk.api.session.pushrules.RuleIds
import org.matrix.android.sdk.api.session.pushrules.SenderNotificationPermissionCondition
import timber.log.Timber

Expand Down Expand Up @@ -59,11 +58,11 @@ data class PushCondition(
val iz: String? = null
) {

fun asExecutableCondition(rule: PushRule): Condition? {
fun asExecutableCondition(): Condition? {
return when (Kind.fromString(kind)) {
Kind.EventMatch -> {
if (key != null && pattern != null) {
EventMatchCondition(key, pattern, rule.ruleId == RuleIds.RULE_ID_CONTAIN_USER_NAME)
EventMatchCondition(key, pattern)
} else {
Timber.e("Malformed Event match condition")
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.matrix.android.sdk.api.session.room.model.LocalRoomSummary
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.relation.RelationService
import org.matrix.android.sdk.api.session.room.notification.RoomPushRuleService
import org.matrix.android.sdk.api.session.room.poll.PollHistoryService
import org.matrix.android.sdk.api.session.room.read.ReadService
import org.matrix.android.sdk.api.session.room.reporting.ReportingService
import org.matrix.android.sdk.api.session.room.send.DraftService
Expand Down Expand Up @@ -181,4 +182,9 @@ interface Room {
* Get the LocationSharingService associated to this Room.
*/
fun locationSharingService(): LocationSharingService

/**
* Get the PollHistoryService associated to this Room.
*/
fun pollHistoryService(): PollHistoryService
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2023 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.api.session.room.poll

/**
* Represent the status of the loaded polls for a room.
*/
data class LoadedPollsStatus(
/**
* Indicate whether more polls can be loaded from timeline.
* A false value would mean the start of the timeline has been reached.
*/
val canLoadMore: Boolean,

/**
* Number of days of timeline events currently synced (fetched and stored in local).
*/
val daysSynced: Int,

/**
* Indicate whether a sync of timeline events has been completely done in backward. It would
* mean timeline events have been synced for at least a number of days defined by [PollHistoryService.loadingPeriodInDays].
*/
val hasCompletedASyncBackward: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2023 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.api.session.room.poll

import androidx.lifecycle.LiveData
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent

/**
* Expose methods to get history of polls in rooms.
*/
interface PollHistoryService {

/**
* The number of days covered when requesting to load more polls.
*/
val loadingPeriodInDays: Int

/**
* This must be called when you don't need the service anymore.
* It ensures the underlying database get closed.
*/
fun dispose()

/**
* Ask to load more polls starting from last loaded polls for a period defined by
* [loadingPeriodInDays].
*/
suspend fun loadMore(): LoadedPollsStatus

/**
* Get the current status of the loaded polls.
*/
suspend fun getLoadedPollsStatus(): LoadedPollsStatus

/**
* Sync polls from last loaded polls until now.
*/
suspend fun syncPolls()

/**
* Get currently loaded list of poll events. See [loadMore].
*/
fun getPollEvents(): LiveData<List<TimelineEvent>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ object RoomSummaryConstants {
EventType.REACTION
) +
EventType.POLL_START.values +
EventType.POLL_END.values +
EventType.STATE_ROOM_BEACON_INFO.values
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo046
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo047
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo048
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo049
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo050
import org.matrix.android.sdk.internal.util.Normalizer
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
import javax.inject.Inject
Expand All @@ -74,7 +75,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
private val normalizer: Normalizer
) : MatrixRealmMigration(
dbName = "Session",
schemaVersion = 49L,
schemaVersion = 50L,
) {
/**
* Forces all RealmSessionStoreMigration instances to be equal.
Expand Down Expand Up @@ -133,5 +134,6 @@ internal class RealmSessionStoreMigration @Inject constructor(
if (oldVersion < 47) MigrateSessionTo047(realm).perform()
if (oldVersion < 48) MigrateSessionTo048(realm).perform()
if (oldVersion < 49) MigrateSessionTo049(realm).perform()
if (oldVersion < 50) MigrateSessionTo050(realm).perform()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2023 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.migration

import io.realm.DynamicRealm
import org.matrix.android.sdk.internal.database.model.PollHistoryStatusEntityFields
import org.matrix.android.sdk.internal.util.database.RealmMigrator

/**
* Adding new entity PollHistoryStatusEntity.
*/
internal class MigrateSessionTo050(realm: DynamicRealm) : RealmMigrator(realm, 50) {

override fun doMigrate(realm: DynamicRealm) {
realm.schema.create("PollHistoryStatusEntity")
.addField(PollHistoryStatusEntityFields.ROOM_ID, String::class.java)
.addPrimaryKey(PollHistoryStatusEntityFields.ROOM_ID)
.setRequired(PollHistoryStatusEntityFields.ROOM_ID, true)
.addField(PollHistoryStatusEntityFields.CURRENT_TIMESTAMP_TARGET_BACKWARD_MS, Long::class.java)
.setNullable(PollHistoryStatusEntityFields.CURRENT_TIMESTAMP_TARGET_BACKWARD_MS, true)
.addField(PollHistoryStatusEntityFields.OLDEST_TIMESTAMP_TARGET_REACHED_MS, Long::class.java)
.setNullable(PollHistoryStatusEntityFields.OLDEST_TIMESTAMP_TARGET_REACHED_MS, true)
.addField(PollHistoryStatusEntityFields.OLDEST_EVENT_ID_REACHED, String::class.java)
.addField(PollHistoryStatusEntityFields.MOST_RECENT_EVENT_ID_REACHED, String::class.java)
.addField(PollHistoryStatusEntityFields.IS_END_OF_POLLS_BACKWARD, Boolean::class.java)
}
}
Loading

0 comments on commit b3ab19c

Please sign in to comment.