Skip to content

Commit

Permalink
Merge branch 'release/0.23.5/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed May 18, 2022
2 parents d7027c0 + 044fa13 commit 6cb7100
Show file tree
Hide file tree
Showing 38 changed files with 749 additions and 61 deletions.
19 changes: 19 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## Changes in 0.23.5 (2022-05-18)

✨ Features

- Add `io.element.video` room type. ([#6149](https://github.com/vector-im/element-ios/issues/6149))

🙌 Improvements

- Rooms: support for attributedPartialTextMessage storage ([#3526](https://github.com/vector-im/element-ios/issues/3526))

🚧 In development 🚧

- MXBeaconInfoSummary: Add room id and support device id update after start location sharing. ([#5722](https://github.com/vector-im/element-ios/issues/5722))

Others

- Update check for server-side threads support to match spec. ([#1460](https://github.com/matrix-org/matrix-ios-sdk/pull/1460))


## Changes in 0.23.4 (2022-05-05)

🙌 Improvements
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.23.4"
s.version = "0.23.5"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down
30 changes: 24 additions & 6 deletions MatrixSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

33 changes: 24 additions & 9 deletions MatrixSDK/Aggregations/LocationSharing/MXBeaconAggregations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class MXBeaconAggregations: NSObject {

private unowned let session: MXSession

private var listeners: [MXBeaconInfoSummaryListener] = []
private var perRoomListeners: [MXBeaconInfoSummaryPerRoomListener] = []
private var allRoomListeners: [MXBeaconInfoSummaryAllRoomListener] = []

private var beaconInfoSummaryStore: MXBeaconInfoSummaryStoreProtocol

Expand Down Expand Up @@ -104,20 +105,30 @@ public class MXBeaconAggregations: NSObject {

// MARK: Data update listener

public func listenToBeaconInfoSummaryUpdateInRoom(withId roomId: String, handler: @escaping (MXBeaconInfoSummaryProtocol) -> Void) -> Any? {
let listener = MXBeaconInfoSummaryListener(roomId: roomId, notificationHandler: handler)
/// Listen to all beacon info summary updates in a room
public func listenToBeaconInfoSummaryUpdateInRoom(withId roomId: String, handler: @escaping (MXBeaconInfoSummaryProtocol) -> Void) -> AnyObject? {
let listener = MXBeaconInfoSummaryPerRoomListener(roomId: roomId, notificationHandler: handler)

listeners.append(listener)
perRoomListeners.append(listener)

return listener
}

/// Listen to all beacon info summary update in all rooms
public func listenToBeaconInfoSummaryUpdate(handler: @escaping (_ roomId: String, MXBeaconInfoSummaryProtocol) -> Void) -> AnyObject? {
let listener = MXBeaconInfoSummaryAllRoomListener(notificationHandler: handler)

allRoomListeners.append(listener)

return listener
}

public func removeListener(_ listener: Any) {
guard let beaconInfoSummaryListener = listener as? MXBeaconInfoSummaryListener else {
return
if let perRoomListener = listener as? MXBeaconInfoSummaryPerRoomListener {
perRoomListeners.removeAll(where: { $0 === perRoomListener })
} else if let allRoomListener = listener as? MXBeaconInfoSummaryAllRoomListener {
allRoomListeners.removeAll(where: { $0 === allRoomListener })
}

listeners.removeAll(where: { $0 === beaconInfoSummaryListener })
}

// MARK: - Private
Expand Down Expand Up @@ -174,9 +185,13 @@ public class MXBeaconAggregations: NSObject {

private func notifyBeaconInfoSummaryListeners(ofRoomWithId roomId: String, beaconInfoSummary: MXBeaconInfoSummary) {

for listener in listeners where listener.roomId == roomId {
for listener in perRoomListeners where listener.roomId == roomId {
listener.notificationHandler(beaconInfoSummary)
}

for listener in allRoomListeners {
listener.notificationHandler(roomId, beaconInfoSummary)
}
}

/// Get MXBeaconInfoSummary class instead of MXBeaconInfoSummaryProtocol to have access to internal methods
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// 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.
//

import Foundation

@objcMembers
public class MXBeaconInfoSummaryAllRoomListener: NSObject {

// MARK: - Properties

let notificationHandler: ((_ roomId: String, MXBeaconInfoSummaryProtocol) -> Void)

// MARK: - Setup

init(notificationHandler: @escaping ((_ roomId: String, MXBeaconInfoSummaryProtocol) -> Void)) {
self.notificationHandler = notificationHandler
super.init()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright 2022 The Matrix.org Foundation C.I.C
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,12 +17,12 @@
import Foundation

@objcMembers
public class MXBeaconInfoSummaryListener: NSObject {
public class MXBeaconInfoSummaryPerRoomListener: NSObject {

// MARK: - Properties

let roomId: String
let notificationHandler: ((MXBeaconInfoSummary) -> Void)
let notificationHandler: ((MXBeaconInfoSummaryProtocol) -> Void)

// MARK: - Setup

Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Aggregations/MXAggregations.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ - (void)removeListener:(id)listener
{
[self.aggregatedEditsUpdater removeListener:listener];
}
else if ([listener isKindOfClass:[MXBeaconInfoSummaryListener class]])
else if ([listener isKindOfClass:[MXBeaconInfoSummaryPerRoomListener class]] || [listener isKindOfClass:[MXBeaconInfoSummaryAllRoomListener class]])
{
[self.beaconAggregations removeListener:listener];
}
Expand Down
13 changes: 11 additions & 2 deletions MatrixSDK/Background/MXBackgroundStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,22 @@ class MXBackgroundStore: NSObject, MXStore {

func deleteGroup(_ groupId: String) {
}


@available(*, deprecated, message: "use storePartialAttributedTextMessage")
func storePartialTextMessage(forRoom roomId: String, partialTextMessage: String) {
}


@available(*, deprecated, message: "use partialAttributedTextMessage")
func partialTextMessage(ofRoom roomId: String) -> String? {
return nil
}

func storePartialAttributedTextMessage(forRoom roomId: String, partialAttributedTextMessage: NSAttributedString) {
}

func partialAttributedTextMessage(ofRoom roomId: String) -> NSAttributedString? {
return nil
}

func getEventReceipts(_ roomId: String, eventId: String, sorted sort: Bool, completion: @escaping ([MXReceiptData]) -> Void) {
DispatchQueue.main.async {
Expand Down
8 changes: 1 addition & 7 deletions MatrixSDK/Background/MXBackgroundSyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public enum MXBackgroundSyncServiceError: Error {
return
}

let sharedHistory = (content[kMXSharedHistoryKeyName] as? Bool) ?? isRoomSharingHistory(roomId: roomId)
let sharedHistory = (content[kMXSharedHistoryKeyName] as? Bool) ?? false
olmDevice.addInboundGroupSession(sessionId,
sessionKey: sessionKey,
roomId: roomId,
Expand All @@ -590,12 +590,6 @@ public enum MXBackgroundSyncServiceError: Error {
sharedHistory: sharedHistory)
}

private func isRoomSharingHistory(roomId: String) -> Bool {
let summary = roomSummary(forRoomId: roomId)
let visibility = MXRoomHistoryVisibility(identifier: summary?.historyVisibility)
return visibility == .worldReadable || visibility == .shared
}

private func updateBackgroundServiceStoresIfNeeded() {
var outdatedStore = false

Expand Down
5 changes: 3 additions & 2 deletions MatrixSDK/Crypto/Algorithms/Megolm/MXMegolmDecryption.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ - (void)onRoomKeyEvent:(MXEvent *)event
NSArray<NSString*> *forwardingKeyChain;
BOOL exportFormat = NO;
NSDictionary *keysClaimed;
BOOL sharedHistory = [crypto isRoomSharingHistory:roomId];
if (content[kMXSharedHistoryKeyName] != nil) {
BOOL sharedHistory = NO;
if (content[kMXSharedHistoryKeyName] != nil)
{
MXJSONModelSetBoolean(sharedHistory, content[kMXSharedHistoryKeyName]);
}

Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Crypto/Algorithms/Megolm/MXMegolmEncryption.m
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ - (MXHTTPOperation*)shareKey:(MXOutboundSessionInfo*)session
{
NSString *sessionKey = session.session.sessionKey;
NSUInteger chainIndex = session.session.messageIndex;
BOOL sharedHistory = [self isSessionSharingHistory:session];
BOOL sharedHistory = MXSDKOptions.sharedInstance.enableRoomSharedHistoryOnInvite && [self isSessionSharingHistory:session];

NSDictionary *payload = @{
@"type": kMXEventTypeStringRoomKey,
Expand Down
4 changes: 2 additions & 2 deletions MatrixSDK/Crypto/Data/MXOlmInboundGroupSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder
_senderKey = [aDecoder decodeObjectForKey:@"senderKey"];
_forwardingCurve25519KeyChain = [aDecoder decodeObjectForKey:@"forwardingCurve25519KeyChain"];
_keysClaimed = [aDecoder decodeObjectForKey:@"keysClaimed"];
_sharedHistory = [[aDecoder decodeObjectForKey:@"sharedHistory"] boolValue];
_sharedHistory = [[aDecoder decodeObjectForKey:@"sharedHistory_v2"] boolValue];
}
return self;
}
Expand All @@ -127,7 +127,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
[aCoder encodeObject:_senderKey forKey:@"senderKey"];
[aCoder encodeObject:_keysClaimed forKey:@"keysClaimed"];
[aCoder encodeObject:_forwardingCurve25519KeyChain forKey:@"forwardingCurve25519KeyChain"];
[aCoder encodeObject:@(_sharedHistory) forKey:@"sharedHistory"];
[aCoder encodeObject:@(_sharedHistory) forKey:@"sharedHistory_v2"];
}

@end
Expand Down
3 changes: 2 additions & 1 deletion MatrixSDK/Crypto/KeyBackup/MXKeyBackup.m
Original file line number Diff line number Diff line change
Expand Up @@ -1607,13 +1607,14 @@ - (MXKeyBackupData*)encryptGroupSession:(MXOlmInboundGroupSession*)session
return nil;
}

BOOL sharedHistory = MXSDKOptions.sharedInstance.enableRoomSharedHistoryOnInvite && sessionData.sharedHistory;
NSDictionary *sessionBackupData = @{
@"algorithm": sessionData.algorithm,
@"sender_key": sessionData.senderKey,
@"sender_claimed_keys": sessionData.senderClaimedKeys,
@"forwarding_curve25519_key_chain": sessionData.forwardingCurve25519KeyChain ? sessionData.forwardingCurve25519KeyChain : @[],
@"session_key": sessionData.sessionKey,
kMXSharedHistoryKeyName: @(sessionData.sharedHistory)
kMXSharedHistoryKeyName: @(sharedHistory)
};
OLMPkMessage *encryptedSessionBackupData = [_backupKey encryptMessage:[MXTools serialiseJSONObject:sessionBackupData] error:nil];
if (![self checkOLMPkMessage:encryptedSessionBackupData])
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Crypto/MXCrypto.m
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ - (BOOL)isRoomEncrypted:(NSString *)roomId

- (BOOL)isRoomSharingHistory:(NSString *)roomId
{
MXRoom *room = [_mxSession roomWithRoomId:roomId];
MXRoom *room = [self.mxSession roomWithRoomId:roomId];
MXRoomHistoryVisibility visibility = room.summary.historyVisibility;
return [visibility isEqualToString:kMXRoomHistoryVisibilityWorldReadable] || [visibility isEqualToString:kMXRoomHistoryVisibilityShared];
}
Expand Down
16 changes: 14 additions & 2 deletions MatrixSDK/Crypto/MXOlmDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,12 @@ - (BOOL)addInboundGroupSession:(NSString*)sessionId
session.roomId = roomId;
session.keysClaimed = keysClaimed;
session.forwardingCurve25519KeyChain = forwardingCurve25519KeyChain;
session.sharedHistory = sharedHistory;

// If we already have a session stored, the sharedHistory flag will not be overwritten
if (!existingSession && MXSDKOptions.sharedInstance.enableRoomSharedHistoryOnInvite)
{
session.sharedHistory = sharedHistory;
}

[store storeInboundGroupSessions:@[session]];

Expand Down Expand Up @@ -425,6 +430,12 @@ - (BOOL)addInboundGroupSession:(NSString*)sessionId
MXLogDebug(@"[MXOlmDevice] importInboundGroupSessions: Skip it. The index of the incoming session is higher (%@ vs %@)", @(session.session.firstKnownIndex), @(existingSession.session.firstKnownIndex));
continue;
}

if (existingSession.sharedHistory != session.sharedHistory)
{
MXLogDebug(@"[MXOlmDevice] importInboundGroupSessions: Existing value of sharedHistory = %d is not allowed to be overriden by the updated session", existingSession.sharedHistory);
session.sharedHistory = existingSession.sharedHistory;
}
}

[sessions addObject:session];
Expand Down Expand Up @@ -594,13 +605,14 @@ - (NSDictionary*)getInboundGroupSessionKey:(NSString*)roomId senderKey:(NSString

MXMegolmSessionData *sessionData = [session exportSessionDataAtMessageIndex:[messageIndex unsignedIntegerValue]];
NSArray<NSString*> *forwardingCurve25519KeyChain = sessionData.forwardingCurve25519KeyChain;
BOOL sharedHistory = MXSDKOptions.sharedInstance.enableRoomSharedHistoryOnInvite && sessionData.sharedHistory;

inboundGroupSessionKey = @{
@"chain_index": messageIndex,
@"key": sessionData.sessionKey,
@"forwarding_curve25519_key_chain": forwardingCurve25519KeyChain ? forwardingCurve25519KeyChain : @[],
@"sender_claimed_ed25519_key": senderEd25519Key ? senderEd25519Key : [NSNull null],
@"shared_history": @(sessionData.sharedHistory)
@"shared_history": @(sharedHistory)
};
}

Expand Down
11 changes: 10 additions & 1 deletion MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,22 @@ FOUNDATION_EXPORT NSInteger const kMXRoomInvalidInviteSenderErrorCode;
success:(void (^)(void))success
failure:(void (^)(NSError *))failure NS_REFINED_FOR_SWIFT;

/**
The text message partially typed by the user but not yet sent.
The value is stored by the session store. Thus, it can be retrieved
when the application restarts.
@deprecated use partialAttributedTextMessage
*/
@property (nonatomic) NSString *partialTextMessage __deprecated_msg("use partialAttributedTextMessage");

/**
The text message partially typed by the user but not yet sent.
The value is stored by the session store. Thus, it can be retrieved
when the application restarts.
*/
// @TODO(summary): Move to MXRoomSummary
@property (nonatomic) NSString *partialTextMessage;
@property (nonatomic) NSAttributedString *partialAttributedTextMessage;

/**
The list of ids of users currently typing in this room.
Expand Down
10 changes: 10 additions & 0 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,16 @@ - (NSString *)partialTextMessage
return [mxSession.store partialTextMessageOfRoom:self.roomId];
}

- (void)setPartialAttributedTextMessage:(NSAttributedString *)partialAttributedTextMessage
{
[mxSession.store storePartialAttributedTextMessageForRoom:self.roomId partialAttributedTextMessage:partialAttributedTextMessage];
}

- (NSAttributedString *)partialAttributedTextMessage
{
return [mxSession.store partialAttributedTextMessageOfRoom:self.roomId];
}


#pragma mark - Sync
- (void)handleJoinedRoomSync:(MXRoomSync *)roomSync onComplete:(void (^)(void))onComplete
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXRoomState.m
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ - (MXRoomTombStoneContent*)tombStoneContent
return roomTombStoneContent;
}

- (NSArray<MXBeaconInfo*>*)beaconInfoEvents
- (NSArray<MXBeaconInfo*>*)beaconInfos
{
NSMutableArray *beaconInfoEvents = [NSMutableArray new];

Expand Down
2 changes: 2 additions & 0 deletions MatrixSDK/Data/MXRoomType.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ typedef NS_ENUM(NSInteger, MXRoomType) {
MXRoomTypeNone,
MXRoomTypeRoom,
MXRoomTypeSpace,
MXRoomTypeVideo,
// The room type is custom. Refer to the room type string version.
MXRoomTypeCustom
};
Expand All @@ -30,3 +31,4 @@ typedef NSString *const MXRoomTypeString NS_TYPED_EXTENSIBLE_ENUM;
static MXRoomTypeString const MXRoomTypeStringRoomMSC1840 = @"org.matrix.msc1840.messaging";
static MXRoomTypeString const MXRoomTypeStringRoom = @"m.message";
static MXRoomTypeString const MXRoomTypeStringSpace = @"m.space";
static MXRoomTypeString const MXRoomTypeStringVideo = @"io.element.video";
6 changes: 6 additions & 0 deletions MatrixSDK/Data/Store/MXFileStore/MXFileRoomStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ - (id)initWithCoder:(NSCoder *)aDecoder

self.partialTextMessage = [aDecoder decodeObjectForKey:@"partialTextMessage"];

self.partialAttributedTextMessage = [aDecoder decodeObjectForKey:@"partialAttributedTextMessage"];

// Rebuild the messagesByEventIds cache
for (MXEvent *event in messages)
{
Expand Down Expand Up @@ -69,6 +71,10 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.partialTextMessage forKey:@"partialTextMessage"];
}
if (self.partialAttributedTextMessage)
{
[aCoder encodeObject:self.partialAttributedTextMessage forKey:@"partialAttributedTextMessage"];
}
}

@end
Loading

0 comments on commit 6cb7100

Please sign in to comment.