Skip to content

Commit

Permalink
Merge branch 'release/0.27.10/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jun 17, 2024
2 parents 28ef121 + 84be3e6 commit c64c052
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Changes in 0.27.10 (2024-06-17)

No significant changes.


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

No significant changes.
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.27.9"
s.version = "0.27.10"
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([])
}
}

}
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
10 changes: 10 additions & 0 deletions MatrixSDK/Data/Store/MXMemoryStore/MXMemoryRoomStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
*/
- (void)replaceEvent:(MXEvent*)event;

/**
Remove all the messages sent before a specific timestamp in a room.
The state events are not removed during this operation. We keep them in the timeline.
@param limitTs the timestamp from which the messages are kept.
@return YES if at least one event has been removed.
*/
- (BOOL)removeAllMessagesSentBefore:(uint64_t)limitTs;

/**
Get an event from this room.
Expand Down
27 changes: 27 additions & 0 deletions MatrixSDK/Data/Store/MXMemoryStore/MXMemoryRoomStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,31 @@ - (NSString *)description
return [NSString stringWithFormat:@"%tu messages - paginationToken: %@ - hasReachedHomeServerPaginationEnd: %@ - hasLoadedAllRoomMembersForRoom: %@", messages.count, _paginationToken, @(_hasReachedHomeServerPaginationEnd), @(_hasLoadedAllRoomMembersForRoom)];
}

- (BOOL)removeAllMessagesSentBefore:(uint64_t)limitTs
{
NSUInteger index = 0;
BOOL didChange = NO;
while (index < messages.count)
{
MXEvent *anEvent = [messages objectAtIndex:index];
if (anEvent.isState)
{
// Keep state event
index ++;
}
else if (anEvent.originServerTs < limitTs)
{
[messages removeObjectAtIndex:index];
[messagesByEventIds removeObjectForKey:anEvent.eventId];
didChange = YES;
}
else
{
// Break the loop, we've reached the first non-state event in the timeline which is not expired
break;
}
}
return didChange;
}

@end
6 changes: 6 additions & 0 deletions MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ - (void)replaceEvent:(MXEvent *)event inRoom:(NSString *)roomId
[roomStore replaceEvent:event];
}

- (BOOL)removeAllMessagesSentBefore:(uint64_t)limitTs inRoom:(nonnull NSString *)roomId
{
MXMemoryRoomStore *roomStore = [self getOrCreateRoomStore:roomId];
return [roomStore removeAllMessagesSentBefore:limitTs];
}

- (BOOL)eventExistsWithEventId:(NSString *)eventId inRoom:(NSString *)roomId
{
return (nil != [self eventWithEventId:eventId inRoom:roomId]);
Expand Down
11 changes: 11 additions & 0 deletions MatrixSDK/Data/Store/MXNoStore/MXNoStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ - (BOOL)eventExistsWithEventId:(NSString *)eventId inRoom:(NSString *)roomId
return NO;
}

- (BOOL)removeAllMessagesSentBefore:(uint64_t)limitTs inRoom:(nonnull NSString *)roomId
{
// Only the last message is stored
MXEvent *lastMessage = lastMessages[roomId];
if (!lastMessage.isState && lastMessage.originServerTs < limitTs) {
lastMessages[roomId] = nil;
return YES;
}
return NO;
}

- (MXEvent *)eventWithEventId:(NSString *)eventId inRoom:(NSString *)roomId
{
// Events are not stored. So, we cannot find it.
Expand Down
13 changes: 12 additions & 1 deletion MatrixSDK/Data/Store/MXStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,18 @@
*/
- (void)storeOutgoingMessageForRoom:(nonnull NSString*)roomId outgoingMessage:(nonnull MXEvent*)outgoingMessage;

/**
Remove all the messages sent before a specific timestamp in a room.
The state events are not removed during this operation. We keep them in the timeline.
This operation doesn't change the pagination token, and the flag indicating that the SDK has reached the end of pagination.
@param limitTs the timestamp from which the messages are kept.
@param roomId the id of the room.
@return YES if at least one event has been removed.
*/
- (BOOL)removeAllMessagesSentBefore:(uint64_t)limitTs inRoom:(nonnull NSString *)roomId;

/**
Remove all outgoing messages from a room.
Expand Down Expand Up @@ -593,5 +605,4 @@
success:(nonnull void (^)(NSString * _Nullable filterId))success
failure:(nullable void (^)(NSError * _Nullable error))failure;


@end
2 changes: 2 additions & 0 deletions MatrixSDK/JSONModels/MXEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ typedef NS_ENUM(NSInteger, MXEventType)
MXEventTypeSpaceOrder,
MXEventTypeBeaconInfo,
MXEventTypeBeacon,
MXEventTypeRoomRetention,

// The event is a custom event. Refer to its `MXEventTypeString` version
MXEventTypeCustom = 1000
Expand Down Expand Up @@ -163,6 +164,7 @@ FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceChild;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceOrder;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceOrderMSC3230;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceOrderKey;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringRoomRetention;

// Interactive key verification
FOUNDATION_EXPORT NSString *const kMXEventTypeStringKeyVerificationRequest;
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/JSONModels/MXEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
NSString *const kMXMessageTypeLocation = @"m.location";
NSString *const kMXMessageTypeFile = @"m.file";
NSString *const kMXMessageTypeServerNotice = @"m.server_notice";
NSString *const kMXEventTypeStringRoomRetention = @"m.room.retention";
NSString *const kMXMessageTypeKeyVerificationRequest = @"m.key.verification.request";

NSString *const kMXMessageBodyKey = @"body";
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/MatrixSDKVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

#import <Foundation/Foundation.h>

NSString *const MatrixSDKVersion = @"0.27.8";
NSString *const MatrixSDKVersion = @"0.27.10";
3 changes: 2 additions & 1 deletion MatrixSDK/Utils/MXTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ + (void)initialize
kMXEventTypeStringBeaconInfoMSC3672 : @(MXEventTypeBeaconInfo),
kMXEventTypeStringBeaconInfo : @(MXEventTypeBeaconInfo),
kMXEventTypeStringBeaconMSC3672 : @(MXEventTypeBeacon),
kMXEventTypeStringBeacon : @(MXEventTypeBeacon)
kMXEventTypeStringBeacon : @(MXEventTypeBeacon),
kMXEventTypeStringRoomRetention: @(MXEventTypeRoomRetention),
};

isEmailAddressRegex = [NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@"^%@$", kMXToolsRegexStringForEmailAddress]
Expand Down

0 comments on commit c64c052

Please sign in to comment.