Skip to content

Commit

Permalink
BER-395: Sync origin with upstream v0.27.13 (#8)
Browse files Browse the repository at this point in the history
* Prepare for new sprint

* version++

* finish version++

* Prepare for new sprint

* Add own device creation ts in crypto API

* deviceCreationTs should be readonly

* version++

* finish version++

* Prepare for new sprint

* Sorting room list alphabetically case-insensitive. (matrix-org#1851)

* Sort Room list alphabetically but caseInsensitive

Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>

* Sort Room list alphabetically but caseInsensitive

Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>

* Sort Room list alphabetically but caseInsensitive

Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>

---------

Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>
Co-authored-by: Nicolas Buquet <nbuquet@buquet-net.com>

* Bump rust crypto sdk version 0.4.1

* update minimum ios platform 13.0

* Update min deployment target to 13.0

* Update osx min platform

* update podfile lock

* Fix test compilation

* Add changelog

* Invalidate crypto store cache when entering foreground

* Bump crypto sdk to 0.4.2

* Fix warnings

* Bump the Crypto version in the podspec as well

* version++

* finish version++

* Prepare for new sprint

* Fix | Share room keys with dehydrated devices with rust stack

* Add RestClient method for reporting rooms through MSC4151

* version++

* finish version++

* Prepare for new sprint

* Add a new state event type: "m.room.retention"

# Conflicts:
#	MatrixSDK/Contrib/Swift/JSONModels/MXEvent.swift
#	MatrixSDK/JSONModels/MXEvent.h
#	MatrixSDK/JSONModels/MXEvent.m
#	MatrixSDK/Utils/MXTools.m

* added some functions to remove messages

before a certain timestamp

* remove all messages sent

* fixing a compilation error

* version++

* finish version++

* Prepare for new sprint

* Update README. (matrix-org#1863)

* fix store issue

* version++

* finish version++

* Prepare for new sprint

* Fix CallKit audio session late init

Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>

* Expose MXRoomPowerLevels Swift wrappers to Element (matrix-org#1869)

Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>
Co-authored-by: Nicolas Buquet <nbuquet@buquet-net.com>

* implemented for the preview url API

* removing return used for testing

* using rest client instead of the home server directly

* added the access token to the media loader request

* implementation based on the server version

* access token fix

and using the stable endpoint prefix

* documentation

* code improvement

* version++

* finish version++

* Prepare for new sprint

* Add UTC timestamps to console logs

* Create 7472.change

* Bring in line with foundation DCO (matrix-org#1875)

* bring in line with foundation DCO

* add changelog entry

---------

Co-authored-by: Josh Simmons <git@josh.tel>

* Update format to include the time, Z cannot be applied to NSLog timestamps and doesn't do anything by itself

* Use the codecov token. (matrix-org#1877)

* Use the codecov token.

* Use codecov v4?

* version++

* finish version++

* BER-395: update changelog

---------

Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>
Co-authored-by: Mauro Romito <mauro.romito@element.io>
Co-authored-by: Stefan Ceriu <stefan.ceriu@gmail.com>
Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
Co-authored-by: Valere <bill.carson@valrsoft.com>
Co-authored-by: Valere <valeref@matrix.org>
Co-authored-by: Doug <douglase@element.io>
Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
Co-authored-by: Nicolas Buquet <github@buquet-net.com>
Co-authored-by: Nicolas Buquet <nbuquet@buquet-net.com>
Co-authored-by: Giom Foret <giom@matrix.org>
Co-authored-by: Mauro <34335419+Velin92@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Josh Simmons <josh@openchapters.tech>
Co-authored-by: Josh Simmons <git@josh.tel>
  • Loading branch information
15 people committed Sep 3, 2024
1 parent 47e9ab8 commit d873f60
Show file tree
Hide file tree
Showing 44 changed files with 587 additions and 111 deletions.
36 changes: 31 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
### Pull Request Checklist
**Context**
- Why do we want/need it?

<!-- Please read CONTRIBUTING.md before submitting your pull request -->
**Relevant issues**
- Closes ...(e.g. #138)

* [ ] Pull request is based on the develop branch
* [ ] Pull request contains a changelog file in ./changelog.d. See https://github.com/matrix-org/matrix-ios-sdk/blob/develop/CONTRIBUTING.md#changelog
* [ ] Pull request includes a [sign off](https://github.com/matrix-org/matrix-ios-sdk/blob/develop/CONTRIBUTING.md#sign-off)
**Changes**
- What does it do?
- In summary, what changes are made to the code?

**Known problems**
- What problems do still arise or are anticipated?
- Which part of the solution do you need help with?

**Extra attention**
- What do I need to pay extra attention to as a reviewer?

**Check-list**
- [ ] Acceptance criteria described in the issue are satisfied, or the bug(s) is/are fixed.
- [ ] Documentation present (relevant information is properly documented).
- [ ] Written tests for test suite (optional).
- [ ] CHANGELOG updated.

**Tested on devices**
- [ ] Minimum supported iOS version.
- [ ] Maximum supported iOS version.
- [ ] Lowest resolution supported.
- [ ] Highest resolution supported.
- [ ] Device with a notch.
- [ ] Device without a notch.

**Is this issue considered as Done?**
- [ ] It meets our [DoD](https://github.com/nedap/healthcare-mobile/wiki/DoD).
4 changes: 3 additions & 1 deletion .github/workflows/ci-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ jobs:

# Upload coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/ci-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ jobs:
path: build/test/MatrixSDK-macOS.xcresult/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
All notable changes specific for Berichten Matrix SDK will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [v0.1.4] - 02/09/2024
##### Added
- BER-395: Merge upstream MatrixSDK v0.27.13.

##### Fixed

##### Changed

## [v0.1.3] - 04/06/2024
##### Added
- BER-359: Merge upstream MatrixSDK v0.27.8.
Expand Down Expand Up @@ -37,6 +45,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

---

[v0.1.4]: https://github.com/nedap/matrix-ios-sdk/compare/nedap/0.1.3...nedap/0.1.4
[v0.1.3]: https://github.com/nedap/matrix-ios-sdk/compare/nedap/0.1.2...nedap/0.1.3
[v0.1.2]: https://github.com/nedap/matrix-ios-sdk/compare/nedap/0.1.1...nedap/0.1.2
[v0.1.1]: https://github.com/nedap/matrix-ios-sdk/compare/nedap/0.1.0...nedap/0.1.1
Expand Down
37 changes: 37 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## Changes in 0.27.13 (2024-08-20)

🙌 Improvements

- Add UTC timestamps to console log lines. ([#7472](https://github.com/vector-im/element-ios/issues/7472))

📄 Documentation

- Drop the requirement for "real" or "legally identifiable" name in order to contribute, in line with updated Foundation policy. ([#1875](https://github.com/matrix-org/matrix-ios-sdk/pull/1875))


## Changes in 0.27.12 (2024-07-23)

🙌 Improvements

- Expose MXRroomPowerLevels Swift wrappers to Element ([#1869](https://github.com/matrix-org/matrix-ios-sdk/pull/1869))

🐛 Bugfixes

- Fix CallKit audio session late init in VoIP call. ([#1866](https://github.com/matrix-org/matrix-ios-sdk/pull/1866))


## Changes in 0.27.11 (2024-06-18)

No significant changes.


## Changes in 0.27.10 (2024-06-17)

No significant changes.


## Changes in 0.27.9 (2024-06-13)

No significant changes.


## Changes in 0.27.8 (2024-05-29)

🙌 Improvements
Expand Down
5 changes: 0 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ include the line in your commit or pull request comment:
Signed-off-by: Your Name <your@email.example.org>
```

We accept contributions under a legally identifiable name, such as
your name on government documentation or common-law names (names
claimed by legitimate usage or repute). Unfortunately, we cannot
accept anonymous contributions at this time.

Git allows you to add this signoff automatically when using the `-s`
flag to `git commit`, which uses the name and email set in your
`user.name` and `user.email` git configs.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem "fastlane"
gem "cocoapods", '~>1.14.3'
gem "cocoapods", '~>1.15.2'
gem "xcode-install"
gem "slather"
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ GEM
bigdecimal (3.1.4)
claide (1.1.0)
clamp (1.3.2)
cocoapods (1.14.3)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
Expand All @@ -59,7 +59,7 @@ GEM
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.3)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
Expand Down Expand Up @@ -165,7 +165,7 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
ffi (1.16.3)
ffi (1.17.0)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
Expand Down Expand Up @@ -296,7 +296,7 @@ PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.14.3)
cocoapods (~> 1.15.2)
fastlane
slather
xcode-install
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.1.3"
s.version = "0.1.4"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down
6 changes: 5 additions & 1 deletion MatrixSDK/Background/MXBackgroundStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ class MXBackgroundStore: NSObject, MXStore {
func isRoomMarked(asUnread roomId: String) -> Bool {
return false
}

func removeAllMessagesSent(before limitTs: UInt64, inRoom roomId: String) -> Bool {
// Not sure if this needs to be implemented
false
}
}

// MARK: - MXRoomSummaryStore
Expand Down Expand Up @@ -334,5 +339,4 @@ extension MXBackgroundStore: MXRoomSummaryStore {
completion([])
}
}

}
24 changes: 24 additions & 0 deletions MatrixSDK/Categories/MXKeysQueryResponse+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,27 @@ extension MXKeysQueryResponse : MXSummable {
return keysQueryResponse as! Self
}
}


extension MXKeysQueryResponseRaw : MXSummable {

public static func +(lhs: MXKeysQueryResponseRaw, rhs: MXKeysQueryResponseRaw) -> Self {
let keysQueryResponse = MXKeysQueryResponseRaw()

// Casts to original objc NSDictionary are annoying
// but we want to reuse our implementation of NSDictionary.+
let deviceKeysMap = (lhs.deviceKeys as NSDictionary? ?? NSDictionary())
+ (rhs.deviceKeys as NSDictionary? ?? NSDictionary())
keysQueryResponse.deviceKeys = deviceKeysMap as? [String : Any]

let crossSigningKeys = (lhs.crossSigningKeys as NSDictionary? ?? NSDictionary())
+ (rhs.crossSigningKeys as NSDictionary? ?? NSDictionary())
keysQueryResponse.crossSigningKeys = crossSigningKeys as? [String: MXCrossSigningInfo]

let failures = (lhs.failures as NSDictionary? ?? NSDictionary())
+ (rhs.failures as NSDictionary? ?? NSDictionary())
keysQueryResponse.failures = failures as? [AnyHashable : Any]

return keysQueryResponse as! Self
}
}
71 changes: 71 additions & 0 deletions MatrixSDK/Categories/MXRestClient+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,75 @@ public extension MXRestClient {

return operation
}

/// Download users keys by chunks.
///
/// - Parameters:
/// - users: list of users to get keys for.
/// - token: sync token to pass in the query request, to help.
/// - chunkSize: max number of users to ask for in one CS API request.
/// - success: A block object called when the operation succeeds.
/// - failure: A block object called when the operation fails.
/// - Returns: a MXHTTPOperation instance.
func downloadKeysByChunkRaw(forUsers users: [String],
token: String?,
chunkSize: Int = 250,
success: @escaping (_ keysQueryResponse: MXKeysQueryResponseRaw) -> Void,
failure: @escaping (_ error: NSError?) -> Void) -> MXHTTPOperation {

// Do not chunk if not needed
if users.count <= chunkSize {
return self.downloadKeysRaw(forUsers: users, token: token) { response in
switch response {
case .success(let keysQueryResponse):
success(keysQueryResponse)
case .failure(let error):
failure(error as NSError)
}
}
}

MXLog.debug("[MXRestClient+Extensions] downloadKeysByChunk: \(users.count) users with chunkSize:\(chunkSize)")

// An arbitrary MXHTTPOperation. It will not cancel requests
// but it will avoid to call callbacks in case of a cancellation is requested
let operation = MXHTTPOperation()

let group = DispatchGroup()
var responses = [MXResponse<MXKeysQueryResponseRaw>]()
users.chunked(into: chunkSize).forEach { chunkedUsers in
group.enter()
self.downloadKeysRaw(forUsers: chunkedUsers, token: token) { response in
switch response {
case .success(let keysQueryResponse):
MXLog.debug("[MXRestClient+Extensions] downloadKeysByChunk: Got intermediate response. Got device keys for %@ users. Got cross-signing keys for %@ users \(String(describing: keysQueryResponse.deviceKeys.keys.count)) \(String(describing: keysQueryResponse.crossSigningKeys.count))")
case .failure(let error):
MXLog.debug("[MXRestClient+Extensions] downloadKeysByChunk: Got intermediate error. Error: \(error)")
}

responses.append(response)
group.leave()
}
}

group.notify(queue: self.completionQueue) {
MXLog.debug("[MXRestClient+Extensions] downloadKeysByChunk: Got all responses")

guard operation.isCancelled == false else {
MXLog.debug("[MXRestClient+Extensions] downloadKeysByChunk: Request was cancelled")
return
}

// Gather all responses in one
let response = responses.reduce(.success(MXKeysQueryResponseRaw()), +)
switch response {
case .success(let keysQueryResponse):
success(keysQueryResponse)
case .failure(let error):
failure(error as NSError)
}
}

return operation
}
}
4 changes: 3 additions & 1 deletion MatrixSDK/Contrib/Swift/JSONModels/MXEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public enum MXEventType: Equatable, Hashable {

case beaconInfo
case beacon
case roomRetention

case custom(String)

Expand Down Expand Up @@ -141,6 +142,7 @@ public enum MXEventType: Equatable, Hashable {
case .taggedEvents: return kMXEventTypeStringTaggedEvents
case .spaceChild: return kMXEventTypeStringSpaceChild
case .spaceOrder: return kMXEventTypeStringSpaceOrderMSC3230
case .roomRetention: return kMXEventTypeStringRoomRetention

case .pollStart: return kMXEventTypeStringPollStartMSC3381
case .pollResponse: return kMXEventTypeStringPollResponseMSC3381
Expand All @@ -157,7 +159,7 @@ public enum MXEventType: Equatable, Hashable {
}

public init(identifier: String) {
let events: [MXEventType] = [.roomName, .roomTopic, .roomAvatar, .roomMember, .roomCreate, .roomJoinRules, .roomPowerLevels, .roomAliases, .roomCanonicalAlias, .roomEncrypted, .roomEncryption, .roomGuestAccess, .roomHistoryVisibility, .roomKey, .roomForwardedKey, .roomKeyRequest, .roomMessage, .roomMessageFeedback, .roomRedaction, .roomThirdPartyInvite, .roomTag, .presence, .typing, .callInvite, .callCandidates, .callAnswer, .callSelectAnswer, .callHangup, .callReject, .callNegotiate, .callReplaces, .callRejectReplacement, .callAssertedIdentity, .callAssertedIdentityUnstable, .reaction, .receipt, .roomTombStone, .keyVerificationStart, .keyVerificationAccept, .keyVerificationKey, .keyVerificationMac, .keyVerificationCancel, .keyVerificationDone, .secretRequest, .secretSend, .secretStorageDefaultKey, .taggedEvents, .spaceChild, .spaceOrder, .pollStart, .pollResponse, .pollEnd, .beaconInfo, .beacon]
let events: [MXEventType] = [.roomName, .roomTopic, .roomAvatar, .roomMember, .roomCreate, .roomJoinRules, .roomPowerLevels, .roomAliases, .roomCanonicalAlias, .roomEncrypted, .roomEncryption, .roomGuestAccess, .roomHistoryVisibility, .roomKey, .roomForwardedKey, .roomKeyRequest, .roomMessage, .roomMessageFeedback, .roomRedaction, .roomThirdPartyInvite, .roomTag, .presence, .typing, .callInvite, .callCandidates, .callAnswer, .callSelectAnswer, .callHangup, .callReject, .callNegotiate, .callReplaces, .callRejectReplacement, .callAssertedIdentity, .callAssertedIdentityUnstable, .reaction, .receipt, .roomTombStone, .keyVerificationStart, .keyVerificationAccept, .keyVerificationKey, .keyVerificationMac, .keyVerificationCancel, .keyVerificationDone, .secretRequest, .secretSend, .secretStorageDefaultKey, .taggedEvents, .spaceChild, .spaceOrder, .pollStart, .pollResponse, .pollEnd, .beaconInfo, .beacon, .roomRetention]

if let type = events.first(where: { $0.identifier == identifier }) {
self = type
Expand Down
4 changes: 2 additions & 2 deletions MatrixSDK/Contrib/Swift/JSONModels/MXRoomPowerLevels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension MXRoomPowerLevels {
- parameter eventType: the type of event.
- returns: the required minimum power level.
*/
@nonobjc func minimumPowerLevelForSendingMessageEvent(_ eventType: MXEventType) -> Int {
@nonobjc public func minimumPowerLevelForSendingMessageEvent(_ eventType: MXEventType) -> Int {
return __minimumPowerLevelForSendingEvent(asMessage: eventType.identifier)
}

Expand All @@ -36,7 +36,7 @@ extension MXRoomPowerLevels {
- parameter eventType: the type of event.
- returns: the required minimum power level.
*/
@nonobjc func minimumPowerLevelForSendingStateEvent(_ eventType: MXEventType) -> Int {
@nonobjc public func minimumPowerLevelForSendingStateEvent(_ eventType: MXEventType) -> Int {
return __minimumPowerLevelForSendingEvent(asStateEvent: eventType.identifier)
}

Expand Down
4 changes: 4 additions & 0 deletions MatrixSDK/Contrib/Swift/MXRestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,10 @@ public extension MXRestClient {
return __downloadKeys(forUsers: userIds, token: token, success: currySuccess(completion), failure: curryFailure(completion))
}

@nonobjc @discardableResult func downloadKeysRaw(forUsers userIds: [String], token: String? = nil, completion: @escaping (_ response: MXResponse<MXKeysQueryResponseRaw>) -> Void) -> MXHTTPOperation {
return __downloadKeysRaw(forUsers: userIds, token: token, success: currySuccess(completion), failure: curryFailure(completion))
}


/**
Claim one-time keys.
Expand Down
6 changes: 3 additions & 3 deletions MatrixSDK/Crypto/CryptoMachine/MXCryptoRequests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import MatrixSDKCrypto
/// to the native REST API client
struct MXCryptoRequests {
private let restClient: MXRestClient
private let queryScheduler: MXKeysQueryScheduler<MXKeysQueryResponse>
private let queryScheduler: MXKeysQueryScheduler<MXKeysQueryResponseRaw>

init(restClient: MXRestClient) {
self.restClient = restClient
self.queryScheduler = .init { users in
try await performCallbackRequest { completion in
_ = restClient.downloadKeysByChunk(
_ = restClient.downloadKeysByChunkRaw(
forUsers: users,
token: nil,
success: {
Expand Down Expand Up @@ -96,7 +96,7 @@ struct MXCryptoRequests {
}
}

func queryKeys(users: [String]) async throws -> MXKeysQueryResponse {
func queryKeys(users: [String]) async throws -> MXKeysQueryResponseRaw {
try await queryScheduler.query(users: Set(users))
}

Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import "MatrixSDKSwiftHeader.h"
#import "MXFileRoomSummaryStore.h"

static NSUInteger const kMXFileVersion = 82; // Check getUnreadRoomFromStore if you update this value. Delete this comment after
static NSUInteger const kMXFileVersion = 83; // Check getUnreadRoomFromStore if you update this value. Delete this comment after

static NSString *const kMXFileStoreFolder = @"MXFileStore";
static NSString *const kMXFileStoreMedaDataFile = @"MXFileStore";
Expand Down
Loading

0 comments on commit d873f60

Please sign in to comment.