Skip to content

Commit

Permalink
Edits history: Expose the new original event field
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed Jul 10, 2019
1 parent 309ec07 commit 9eaedea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) NSArray<MXEvent*> *chunk;
@property (nonatomic, readonly, nullable) NSString *nextBatch;

@property (nonatomic, readonly) MXEvent *originalEvent;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary

paginatedResponse->_chunk = chunk;
MXJSONModelSetString(paginatedResponse->_nextBatch, JSONDictionary[@"next_batch"])

MXJSONModelSetMXJSONModel(paginatedResponse->_originalEvent, MXEvent.class, JSONDictionary[@"original_event"])
}

return paginatedResponse;
Expand Down
12 changes: 12 additions & 0 deletions MatrixSDKTests/MXAggregatedEditsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,10 @@ - (void)addEdits:(NSUInteger)editsCount toEvent:(NSString*)eventId inRoom:(MXRoo
// - Edit the message 10 more times
// - Paginate one edit
// -> We must get an edit event and a nextBatch
// -> We must get the original event
// - Paginate more
// -> We must get all other edit events and no more nextBatch
// -> We must get the original event
- (void)testEditsHistory
{
// - Run the initial condition scenario
Expand All @@ -913,6 +915,11 @@ - (void)testEditsHistory
XCTAssertTrue(paginatedResponse.chunk.firstObject.isEditEvent);
XCTAssertNotNil(paginatedResponse.nextBatch);

// -> We must get the original event
XCTAssertNotNil(paginatedResponse.originalEvent);
XCTAssertEqualObjects(paginatedResponse.originalEvent.eventId, eventId);
XCTAssertEqualObjects(paginatedResponse.originalEvent.content[@"body"], kOriginalMessageText);

// - Paginate more
[mxSession.aggregations replaceEventsForEvent:eventId isEncrypted:NO inRoom:room.roomId from:paginatedResponse.nextBatch limit:20 success:^(MXAggregationPaginatedResponse *paginatedResponse) {

Expand All @@ -926,6 +933,11 @@ - (void)testEditsHistory
XCTAssertTrue(event.isEditEvent);
}

// -> We must get the original event
XCTAssertNotNil(paginatedResponse.originalEvent);
XCTAssertEqualObjects(paginatedResponse.originalEvent.eventId, eventId);
XCTAssertEqualObjects(paginatedResponse.originalEvent.content[@"body"], kOriginalMessageText);

[expectation fulfill];

} failure:^(NSError *error) {
Expand Down

0 comments on commit 9eaedea

Please sign in to comment.