diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index f8fe3a6a5..3ae80b689 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -255,7 +255,11 @@ "room_event_action_permalink" = "Permalink"; "room_event_action_view_source" = "View Source"; "room_event_action_report" = "Report content"; +"room_event_action_kick" = "Kick user"; +"room_event_action_ban" = "Ban user"; "room_event_action_report_prompt_reason" = "Reason for reporting this content"; +"room_event_action_kick_prompt_reason" = "Reason for kicking this user"; +"room_event_action_ban_prompt_reason" = "Reason for banning this user"; "room_event_action_report_prompt_ignore_user" = "Do you want to hide all messages from this user?"; "room_event_action_save" = "Save"; "room_event_action_resend" = "Resend"; diff --git a/Riot/ViewController/RoomMemberDetailsViewController.m b/Riot/ViewController/RoomMemberDetailsViewController.m index 0f61f22fa..27f07620b 100644 --- a/Riot/ViewController/RoomMemberDetailsViewController.m +++ b/Riot/ViewController/RoomMemberDetailsViewController.m @@ -938,6 +938,130 @@ [self setPowerLevel:kRiotRoomAdminLevel promptUser:YES]; break; } + case MXKRoomMemberDetailsActionBan: + { + __weak typeof(self) weakSelf = self; + + // Ban + currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_event_action_ban_prompt_reason", @"Vector", nil) + message:nil + preferredStyle:UIAlertControllerStyleAlert]; + + [currentAlert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { + textField.secureTextEntry = NO; + textField.placeholder = nil; + textField.keyboardType = UIKeyboardTypeDefault; + }]; + + [currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + + if (weakSelf) + { + typeof(self) self = weakSelf; + self->currentAlert = nil; + } + + }]]; + + [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"ban", @"Vector", nil) + style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + + if (weakSelf) + { + typeof(self) self = weakSelf; + self->currentAlert = nil; + + [self startActivityIndicator]; + + // kick user + UITextField *textField = [self->currentAlert textFields].firstObject; + [self.mxRoom banUser:self.mxRoomMember.userId reason:textField.text success:^{ + + __strong __typeof(weakSelf)self = weakSelf; + [self stopActivityIndicator]; + + } failure:^(NSError *error) { + + __strong __typeof(weakSelf)self = weakSelf; + [self stopActivityIndicator]; + + NSLog(@"[RoomMemberDetailVC] Ban user (%@) failed", self.mxRoomMember.userId); + //Alert user + [[AppDelegate theDelegate] showErrorAsAlert:error]; + + }]; + } + + }]]; + + [currentAlert mxk_setAccessibilityIdentifier:@"RoomMemberDetailsVCBanAlert"]; + [self presentViewController:currentAlert animated:YES completion:nil]; + break; + } + case MXKRoomMemberDetailsActionKick: + { + __weak typeof(self) weakSelf = self; + + // Kick + currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_event_action_kick_prompt_reason", @"Vector", nil) + message:nil + preferredStyle:UIAlertControllerStyleAlert]; + + [currentAlert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { + textField.secureTextEntry = NO; + textField.placeholder = nil; + textField.keyboardType = UIKeyboardTypeDefault; + }]; + + [currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + + if (weakSelf) + { + typeof(self) self = weakSelf; + self->currentAlert = nil; + } + + }]]; + + [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"remove", @"Vector", nil) + style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + + if (weakSelf) + { + typeof(self) self = weakSelf; + self->currentAlert = nil; + + [self startActivityIndicator]; + + // kick user + UITextField *textField = [self->currentAlert textFields].firstObject; + [self.mxRoom kickUser:self.mxRoomMember.userId reason:textField.text success:^{ + + __strong __typeof(weakSelf)self = weakSelf; + [self stopActivityIndicator]; + + } failure:^(NSError *error) { + + __strong __typeof(weakSelf)self = weakSelf; + [self stopActivityIndicator]; + + NSLog(@"[RoomMemberDetailVC] Removing user (%@) failed", self.mxRoomMember.userId); + //Alert user + [[AppDelegate theDelegate] showErrorAsAlert:error]; + + }]; + } + + }]]; + + [currentAlert mxk_setAccessibilityIdentifier:@"RoomMemberDetailsVCKickAlert"]; + [self presentViewController:currentAlert animated:YES completion:nil]; + break; + } default: { [super onActionButtonPressed:sender];