Skip to content

Commit 707e703

Browse files
committed
Merge branch 'release/0.22.6/master'
2 parents 8568c45 + 2ace3b7 commit 707e703

File tree

6 files changed

+91
-2
lines changed

6 files changed

+91
-2
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Changes in 0.22.6 (2022-03-14)
2+
3+
🙌 Improvements
4+
5+
- Room: API to ignore the sender of a room invite before the room is joined ([#5807](https://github.com/vector-im/element-ios/issues/5807))
6+
7+
18
## Changes in 0.22.5 (2022-03-08)
29

310
🙌 Improvements

MatrixSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "MatrixSDK"
4-
s.version = "0.22.5"
4+
s.version = "0.22.6"
55
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"
66

77
s.description = <<-DESC

MatrixSDK/Data/MXRoom.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ FOUNDATION_EXPORT NSString *const kMXRoomDidFlushDataNotification;
6969
*/
7070
FOUNDATION_EXPORT NSInteger const kMXRoomAlreadyJoinedErrorCode;
7171

72+
/**
73+
Error code when attempting to use a room invite sender which is invalid.
74+
*/
75+
FOUNDATION_EXPORT NSInteger const kMXRoomInvalidInviteSenderErrorCode;
76+
7277
/**
7378
`MXRoom` is the class
7479
*/
@@ -777,6 +782,18 @@ FOUNDATION_EXPORT NSInteger const kMXRoomAlreadyJoinedErrorCode;
777782
- (MXHTTPOperation*)leave:(void (^)(void))success
778783
failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
779784

785+
/**
786+
Ignore the user who sent the invite to this room. This user is then added to the current
787+
user's ignore list.
788+
789+
@param success A block object called when the operation is complete.
790+
@param failure A block object called when the operation fails.
791+
792+
@return a MXHTTPOperation instance.
793+
*/
794+
- (MXHTTPOperation*)ignoreInviteSender:(void (^)(void))success
795+
failure:(void (^)(NSError *error))failure;
796+
780797
/**
781798
Invite a user to this room.
782799

MatrixSDK/Data/MXRoom.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
NSString *const kMXRoomDidFlushDataNotification = @"kMXRoomDidFlushDataNotification";
4545
NSString *const kMXRoomInitialSyncNotification = @"kMXRoomInitialSyncNotification";
4646
NSInteger const kMXRoomAlreadyJoinedErrorCode = 9001;
47+
NSInteger const kMXRoomInvalidInviteSenderErrorCode = 9002;
4748

4849
@interface MXRoom ()
4950
{
@@ -1896,6 +1897,24 @@ - (MXHTTPOperation*)leave:(void (^)(void))success
18961897
return [mxSession leaveRoom:self.roomId success:success failure:failure];
18971898
}
18981899

1900+
- (MXHTTPOperation*)ignoreInviteSender:(void (^)(void))success
1901+
failure:(void (^)(NSError *))failure {
1902+
MXHTTPOperation *operation = [[MXHTTPOperation alloc] init];
1903+
[self state:^(MXRoomState *roomState) {
1904+
MXRoomMember *myUser = [roomState.members memberWithUserId:self.mxSession.myUserId];
1905+
NSString *inviteSenderID = myUser.originalEvent.sender;
1906+
if (!inviteSenderID || [inviteSenderID isEqualToString:myUser.userId]) {
1907+
NSError *error = [NSError errorWithDomain:kMXNSErrorDomain code:kMXRoomInvalidInviteSenderErrorCode userInfo:nil];
1908+
failure(error);
1909+
return;
1910+
}
1911+
1912+
MXHTTPOperation *operation2 = [self.mxSession ignoreUsers:@[inviteSenderID] success:success failure:failure];
1913+
[operation mutateTo:operation2];
1914+
}];
1915+
return operation;
1916+
}
1917+
18991918
- (MXHTTPOperation*)inviteUser:(NSString*)userId
19001919
success:(void (^)(void))success
19011920
failure:(void (^)(NSError *error))failure

MatrixSDK/MatrixSDKVersion.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19-
NSString *const MatrixSDKVersion = @"0.22.5";
19+
NSString *const MatrixSDKVersion = @"0.22.6";

MatrixSDKTests/MXRoomTests.m

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,52 @@ - (void)testLeave
191191
}];
192192
}
193193

194+
- (void)testIgnoreInviteSender
195+
{
196+
[matrixSDKTestsData doMXRestClientTestWithBobAndARoom:self readyToTest:^(MXRestClient *bobClient, NSString *roomId, XCTestExpectation *expectation) {
197+
198+
[matrixSDKTestsData doMXRestClientTestWithAlice:nil readyToTest:^(MXRestClient *aliceClient, XCTestExpectation *expectation2) {
199+
200+
MXSession *mxSession = [[MXSession alloc] initWithMatrixRestClient:aliceClient];
201+
[matrixSDKTestsData retain:mxSession];
202+
203+
[bobClient inviteUser:aliceClient.credentials.userId toRoom:roomId success:^{
204+
[mxSession startWithSyncFilter:[MXFilterJSONModel syncFilterWithMessageLimit:0]
205+
onServerSyncDone:^{
206+
207+
MXRoom *room = [mxSession roomWithRoomId:roomId];
208+
XCTAssertEqual(mxSession.ignoredUsers.count, 0);
209+
XCTAssertEqual([mxSession isUserIgnored:bobClient.credentials.userId], NO);
210+
211+
// Listen to mxSession.ignoredUsers changes where the successful assertion happens
212+
[[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionIgnoredUsersDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notif) {
213+
if (notif.object == mxSession)
214+
{
215+
XCTAssertEqual(mxSession.ignoredUsers.count, 1);
216+
XCTAssertEqual([mxSession isUserIgnored:bobClient.credentials.userId], YES);
217+
218+
[expectation fulfill];
219+
}
220+
}];
221+
222+
[room ignoreInviteSender:nil failure:^(NSError *error) {
223+
XCTFail(@"Failed to ignore invite sender - NSError: %@", error);
224+
[expectation fulfill];
225+
}];
226+
227+
} failure:^(NSError *error) {;
228+
XCTFail(@"Cannot set up intial test conditions - error: %@", error);
229+
[expectation fulfill];
230+
}];
231+
232+
} failure:^(NSError *error) {
233+
XCTFail(@"Cannot set up intial test conditions - error: %@", error);
234+
[expectation fulfill];
235+
}];
236+
}];
237+
}];
238+
}
239+
194240
- (void)testJoin
195241
{
196242
[matrixSDKTestsData doMXRestClientTestWithBobAndARoom:self readyToTest:^(MXRestClient *bobRestClient, NSString *roomId, XCTestExpectation *expectation) {

0 commit comments

Comments
 (0)