Skip to content

Commit

Permalink
Redacting membership events should immediately reset the displayname …
Browse files Browse the repository at this point in the history
…& avatar of room members.

element-hq/element-ios#443

- Fix: The redacted state event was ignored in room state handling
- Add FIXME related to the blocker issue on server side SYN-724 ("prev_content is totally pruned by the server on redacted membership event").
  • Loading branch information
giomfo committed Jul 17, 2016
1 parent 7af3872 commit ae312a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
8 changes: 6 additions & 2 deletions MatrixSDK/Data/MXEventTimeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,12 @@ - (void)handleRedaction:(MXEvent*)redactionEvent
if (!redactedEvent || redactedEvent.isState)
{
// FIXME: Is @autoreleasepool block required or not here?
NSArray *stateEvents = _state.stateEvents;
NSMutableArray *stateEvents = [NSMutableArray arrayWithArray:_state.stateEvents];

for (MXEvent *stateEvent in stateEvents)
for (NSInteger index = 0; index < stateEvents.count; index++)
{
MXEvent *stateEvent = stateEvents[index];

if ([stateEvent.eventId isEqualToString:redactionEvent.redacts])
{
NSLog(@"[MXEventTimeline] the current room state has been modified by the event redaction.");
Expand All @@ -581,6 +583,8 @@ - (void)handleRedaction:(MXEvent*)redactionEvent
redactedEvent = [stateEvent prune];
redactedEvent.redactedBecause = redactionEvent.JSONDictionary;

[stateEvents replaceObjectAtIndex:index withObject:redactedEvent];

// Reset the room state. //FIXME: is it possible to handle only the redacted event?
_state = [[MXRoomState alloc] initWithRoomId:room.roomId andMatrixSession:room.mxSession andDirection:YES];
[self initialiseState:stateEvents];
Expand Down
21 changes: 13 additions & 8 deletions MatrixSDK/Data/MXRoomState.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ - (void)handleStateEvent:(MXEvent*)event
membersWithThirdPartyInviteTokenCache[roomMember.thirdPartyInviteToken] = roomMember;
}
}
else
else// FIXME: In case of redacted membership event (prev_content is missing see SYN-724),
// the room member is then nil: the client considers by mistake the user is no more part of the room...
{
// The user is no more part of the room. Remove him.
// This case happens during back pagination: we remove here users when they are not in the room yet.
Expand Down Expand Up @@ -550,13 +551,17 @@ - (NSString*)memberName:(NSString*)userId

if (!member)
{
// The user may not have joined the room yet. So try to resolve display name from presence data
// Note: This data may not be available
MXUser* user = [mxSession userWithUserId:userId];
if (user && user.displayname.length)
{
displayName = user.displayname;
}
// FIXME: In case of redacted membership event (prev_content is missing see SYN-724),
// the client considers by mistake that some users are no more part of the room.
// PATCH: we comment the following, else some redacted information re-appear spontaneously.

// // The user may not have joined the room yet. So try to resolve display name from presence data
// // Note: This data may not be available
// MXUser* user = [mxSession userWithUserId:userId];
// if (user && user.displayname.length)
// {
// displayName = user.displayname;
// }
}
else if (member.displayname.length)
{
Expand Down

0 comments on commit ae312a3

Please # to comment.