mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-19 16:13:42 +02:00
Room members: third-party invites can now be revoked
This commit is contained in:
@@ -798,7 +798,9 @@
|
||||
- (void)addRoomThirdPartyInviteToParticipants:(MXRoomThirdPartyInvite*)roomThirdPartyInvite roomState:(MXRoomState*)roomState
|
||||
{
|
||||
// If the homeserver has converted the 3pid invite into a room member, do no show it
|
||||
if (![roomState memberWithThirdPartyInviteToken:roomThirdPartyInvite.token])
|
||||
// If the invite has been revoked (null display name), do not show it too.
|
||||
if (![roomState memberWithThirdPartyInviteToken:roomThirdPartyInvite.token]
|
||||
&& roomThirdPartyInvite.displayname)
|
||||
{
|
||||
Contact *contact = [[Contact alloc] initMatrixContactWithDisplayName:roomThirdPartyInvite.displayname andMatrixID:nil];
|
||||
contact.isThirdPartyInvite = YES;
|
||||
@@ -1373,8 +1375,6 @@
|
||||
|
||||
if (section == participantsSection || section == invitedSection)
|
||||
{
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
if (currentAlert)
|
||||
{
|
||||
[currentAlert dismissViewControllerAnimated:NO completion:nil];
|
||||
@@ -1464,6 +1464,7 @@
|
||||
if (row < participants.count)
|
||||
{
|
||||
Contact *contact = participants[row];
|
||||
MXWeakify(self);
|
||||
|
||||
if (contact.mxMember)
|
||||
{
|
||||
@@ -1479,11 +1480,8 @@
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
}
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
}]];
|
||||
|
||||
@@ -1491,51 +1489,80 @@
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
|
||||
[self addPendingActionMask];
|
||||
[self.mxRoom kickUser:memberUserId
|
||||
reason:nil
|
||||
success:^{
|
||||
|
||||
[self removePendingActionMask];
|
||||
|
||||
[participants removeObjectAtIndex:row];
|
||||
|
||||
// Refresh display
|
||||
[self.tableView reloadData];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
[self removePendingActionMask];
|
||||
NSLog(@"[RoomParticipantsVC] Kick %@ failed", memberUserId);
|
||||
// Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
|
||||
}];
|
||||
}
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
[self addPendingActionMask];
|
||||
MXWeakify(self);
|
||||
[self.mxRoom kickUser:memberUserId
|
||||
reason:nil
|
||||
success:^{
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self removePendingActionMask];
|
||||
|
||||
[participants removeObjectAtIndex:row];
|
||||
|
||||
// Refresh display
|
||||
[self.tableView reloadData];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self removePendingActionMask];
|
||||
NSLog(@"[RoomParticipantsVC] Kick %@ failed", memberUserId);
|
||||
// Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
|
||||
}];
|
||||
|
||||
}]];
|
||||
}
|
||||
else
|
||||
else if (contact.mxThirdPartyInvite)
|
||||
{
|
||||
// This is a third-party invite, it could not be removed until the api exists
|
||||
// This is a third-party invite
|
||||
currentAlert = [UIAlertController alertControllerWithTitle:nil
|
||||
message:NSLocalizedStringFromTable(@"room_participants_remove_third_party_invite_msg", @"Vector", nil)
|
||||
message:NSLocalizedStringFromTable(@"room_participants_remove_third_party_invite_prompt_msg", @"Vector", nil)
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
}
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
}]];
|
||||
|
||||
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"remove", @"Vector", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
[self addPendingActionMask];
|
||||
MXWeakify(self);
|
||||
[self.mxRoom sendStateEventOfType:kMXEventTypeStringRoomThirdPartyInvite
|
||||
content:@{} stateKey:contact.mxThirdPartyInvite.token success:^(NSString *eventId) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self removePendingActionMask];
|
||||
|
||||
[participants removeObjectAtIndex:row];
|
||||
|
||||
// Refresh display
|
||||
[self.tableView reloadData];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self removePendingActionMask];
|
||||
NSLog(@"[RoomParticipantsVC] Revoke 3pid invite failed");
|
||||
// Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
|
||||
}];
|
||||
|
||||
}]];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user