public void UserAction(TLObject obj) { var chatBase = obj as TLChatBase; if (chatBase != null) { StateService.With = chatBase; StateService.AnimateTitle = true; NavigationService.UriFor <DialogDetailsViewModel>().Navigate(); return; } var userBase = obj as TLUserBase; if (userBase == null) { return; } if (NavigateToSecretChat) { CreateSecretChatAction(userBase); } else if (NavigateToDialogDetails) { StateService.With = userBase; StateService.AnimateTitle = true; NavigationService.UriFor <DialogDetailsViewModel>().Navigate(); } else { var user = userBase as TLUser; if (user != null && user.IsBot) { if (user.IsBotGroupsBlocked) { MessageBox.Show(AppResources.AddBotToGroupsError, AppResources.Error, MessageBoxButton.OK); return; } var userName = user.FirstName; if (TLString.IsNullOrEmpty(userName)) { userName = user.LastName; } var confirmation = MessageBox.Show(string.Format(AppResources.AddUserToTheGroup, userName, _currentChat.FullName), AppResources.AppName, MessageBoxButton.OKCancel); if (confirmation == MessageBoxResult.OK) { NavigateBackward(userBase); } return; } var channel = _currentChat as TLChannel; if (channel != null) { IsWorking = true; MTProtoService.GetParticipantAsync(channel.ToInputChannel(), userBase.ToInputUser(), result => BeginOnUIThread(() => { IsWorking = false; var participantKicked = result.Participant as TLChannelParticipantBanned; var participant = result.Participant as TLChannelParticipant; if (participant != null || participantKicked != null) { //if (_currentRole is TLChannelRoleEditor) { if (participantKicked != null) { var confirmation = channel.IsMegaGroup ? MessageBox.Show(string.Format(AppResources.InviteContactToGroupConfirmation, userBase.FullName), AppResources.AppName, MessageBoxButton.OKCancel) : MessageBox.Show(string.Format(AppResources.InviteContactConfirmation, userBase.FullName), AppResources.AppName, MessageBoxButton.OKCancel); if (confirmation != MessageBoxResult.OK) { return; } } NavigateBackward(userBase); } } }), error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("channels.getParticipant error " + error); if (error.TypeEquals(ErrorType.USER_NOT_PARTICIPANT)) { if (_currentAdminRights != null && (_currentAdminRights.InviteUsers || _currentAdminRights.InviteLinks)) { var confirmation = channel.IsMegaGroup ? MessageBox.Show(string.Format(AppResources.InviteContactToGroupConfirmation, userBase.FullName), AppResources.AppName, MessageBoxButton.OKCancel) : MessageBox.Show(string.Format(AppResources.InviteContactConfirmation, userBase.FullName), AppResources.AppName, MessageBoxButton.OKCancel); if (confirmation != MessageBoxResult.OK) { return; } } NavigateBackward(userBase); } })); return; } if (RequestForwardingCount) { _confirmation.Open(userBase, _currentChat, result => { if (result.Result == MessageBoxResult.OK) { NavigateBackward(userBase, result.ForwardingMessagesCount); } }); } else { NavigateBackward(userBase); } } }
public void UserAction(TLUserBase userBase) { if (userBase == null) { return; } var user = userBase as TLUser; if (user != null && user.IsBot) { if (user.IsBotGroupsBlocked) { MessageBox.Show(AppResources.AddBotToGroupsError, AppResources.Error, MessageBoxButton.OK); return; } var userName = user.FirstName; if (TLString.IsNullOrEmpty(userName)) { userName = user.LastName; } var confirmation = MessageBox.Show(string.Format(AppResources.AddUserToTheGroup, userName, _currentChat.FullName), AppResources.AppName, MessageBoxButton.OKCancel); if (confirmation == MessageBoxResult.OK) { NavigateBackward(userBase); } return; } var channel = _currentChat as TLChannel; if (channel != null) { IsWorking = true; MTProtoService.GetParticipantAsync(channel.ToInputChannel(), userBase.ToInputUser(), result => BeginOnUIThread(() => { IsWorking = false; var participantKicked = result.Participant as TLChannelParticipantKicked; var participant = result.Participant as TLChannelParticipant; if (participant != null || participantKicked != null) { if (_currentRole is TLChannelRoleEditor) { if (participantKicked != null) { var confirmation = MessageBox.Show(string.Format(AppResources.InviteContactConfirmation, userBase.FullName), AppResources.AppName, MessageBoxButton.OKCancel); if (confirmation != MessageBoxResult.OK) { return; } } NavigateBackward(userBase); } } }), error => BeginOnUIThread(() => { IsWorking = false; Telegram.Api.Helpers.Execute.ShowDebugMessage("channels.getParticipant error " + error); if (error.TypeEquals(ErrorType.USER_NOT_PARTICIPANT)) { if (_currentRole is TLChannelRoleEditor) { var confirmation = MessageBox.Show(string.Format(AppResources.InviteContactConfirmation, userBase.FullName), AppResources.AppName, MessageBoxButton.OKCancel); if (confirmation != MessageBoxResult.OK) { return; } } NavigateBackward(userBase); } })); return; } if (_requestForwardingCount) { _confirmation.Open(userBase, _currentChat, result => { if (result.Result == MessageBoxResult.OK) { NavigateBackward(userBase, result.ForwardingMessagesCount); } }); } else { NavigateBackward(userBase); } }