public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm, TLPaymentRequestedInfo, TLPaymentsValidatedRequestedInfo, TLShippingOption>(from);

                Message     = tuple.Item1;
                Invoice     = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm = tuple.Item2;

                // TODO: real hint
                PasswordHint = Strings.Android.LoginPassword;

                if (_paymentForm.HasSavedCredentials && _paymentForm.SavedCredentials is TLPaymentSavedCredentialsCard savedCard)
                {
                    CredentialsTitle = savedCard.Title;
                }

                _info          = tuple.Item3;
                _requestedInfo = tuple.Item4;
                _shipping      = tuple.Item5;
            }

            return(Task.CompletedTask);
        }
Exemple #2
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm>(from);

                Message     = tuple.Item1;
                Invoice     = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm = tuple.Item2;

                var info = PaymentForm.HasSavedInfo ? PaymentForm.SavedInfo : new TLPaymentRequestedInfo();
                if (info.ShippingAddress == null)
                {
                    info.ShippingAddress = new TLPostAddress();
                }

                Info            = info;
                SelectedCountry = Country.Countries.FirstOrDefault(x => x.Code.Equals(info.ShippingAddress.CountryIso2, StringComparison.OrdinalIgnoreCase));
            }

            return(Task.CompletedTask);
        }
Exemple #3
0
        public static T OpenObjectFromMTProtoFile <T>(object syncRoot, string fileName) where T : TLObject
        {
            try
            {
                if (!File.Exists(FileUtils.GetFileName(fileName)))
                {
                    return(default(T));
                }

                lock (syncRoot)
                {
                    //using (var fileStream = FileUtils.GetLocalFileStreamForRead(fileName))
                    //{
                    //    if (fileStream.Length > 0)
                    //    {
                    using (var from = TLObjectSerializer.CreateReader(FileUtils.GetFileName(fileName)))
                    {
                        from.ReadUInt32();
                        return((T)Activator.CreateInstance(typeof(T), from));
                        //return TLFactory.Read<T>(from);
                    }
                    //    }
                    //}
                }
            }
            catch (Exception e)
            {
                WriteLine("MTPROTO FILE ERROR: cannot read " + typeof(T) + " from file " + fileName, LogSeverity.Error);
                WriteException(e);
            }

            return(default(T));
        }
Exemple #4
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm, TLPaymentRequestedInfo, TLPaymentsValidatedRequestedInfo, TLShippingOption>(from);

                Message     = tuple.Item1;
                Invoice     = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm = tuple.Item2;

                _info          = tuple.Item3;
                _requestedInfo = tuple.Item4;
                _shipping      = tuple.Item5;

                if (_paymentForm.HasNativeProvider && _paymentForm.HasNativeParams && _paymentForm.NativeProvider.Equals("stripe"))
                {
                    IsNativeUsed    = true;
                    SelectedCountry = null;

                    var json = JsonObject.Parse(_paymentForm.NativeParams.Data);

                    NeedCountry        = json.GetNamedBoolean("need_country", false);
                    NeedZip            = json.GetNamedBoolean("need_zip", false);
                    NeedCardholderName = json.GetNamedBoolean("need_cardholder_name", false);

                    _publishableKey = json.GetNamedString("publishable_key", string.Empty);
                }
                else
                {
                    IsNativeUsed = false;
                    RaisePropertyChanged("Navigate");
                }

                //var info = PaymentForm.HasSavedInfo ? PaymentForm.SavedInfo : new TLPaymentRequestedInfo();
                //if (info.ShippingAddress == null)
                //{
                //    info.ShippingAddress = new TLPostAddress();
                //}

                //Info = info;
                //SelectedCountry = null;
            }

            return(Task.CompletedTask);
        }
Exemple #5
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm, TLPaymentRequestedInfo, TLPaymentsValidatedRequestedInfo, TLShippingOption, string, string, bool>(from);

                Message          = tuple.Item1;
                Invoice          = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm      = tuple.Item2;
                Info             = tuple.Item3;
                Shipping         = tuple.Item5;
                CredentialsTitle = string.IsNullOrEmpty(tuple.Item6) ? null : tuple.Item6;
                Bot      = tuple.Item2.Users.FirstOrDefault(x => x.Id == tuple.Item2.BotId) as TLUser;
                Provider = tuple.Item2.Users.FirstOrDefault(x => x.Id == tuple.Item2.ProviderId) as TLUser;

                if (_paymentForm.HasSavedCredentials && _paymentForm.SavedCredentials is TLPaymentSavedCredentialsCard savedCard && _credentialsTitle == null)
                {
                    CredentialsTitle = savedCard.Title;
                }

                var amount = 0L;
                foreach (var price in _paymentForm.Invoice.Prices)
                {
                    amount += price.Amount;
                }

                if (_shipping != null)
                {
                    foreach (var price in _shipping.Prices)
                    {
                        amount += price.Amount;
                    }
                }

                TotalAmount = amount;

                _requestedInfo = tuple.Item4;
                _credentials   = tuple.Item7;
                _save          = tuple.Item8;
            }

            return(Task.CompletedTask);
        }
Exemple #6
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new ChatCreateStep2Tuple(from);

                _title = tuple.Item1;
                _photo = tuple.Item2;
            }

            RaisePropertyChanged(() => Title);
            return(base.OnNavigatedToAsync(parameter, mode, state));
        }
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentReceipt>(from);

                _message = tuple.Item1;
                Invoice  = tuple.Item1.Media as TLMessageMediaInvoice;
                Receipt  = tuple.Item2;
                Bot      = tuple.Item2.Users.FirstOrDefault(x => x.Id == tuple.Item2.BotId) as TLUser;
            }

            return(Task.CompletedTask);
        }
Exemple #8
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm, TLPaymentRequestedInfo, TLPaymentsValidatedRequestedInfo>(from);

                Message       = tuple.Item1;
                Invoice       = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm   = tuple.Item2;
                RequestedInfo = tuple.Item4;

                _info = tuple.Item3;
            }

            return(Task.CompletedTask);
        }
Exemple #9
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var buffer = TLSerializationService.Current.Deserialize((string)e.Parameter) as byte[];

            if (buffer == null)
            {
                return;
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <string, string, string, TLMessage>(from);

                _shareMessage = tuple.Item4;

                TitleLabel.Text    = tuple.Item1;
                UsernameLabel.Text = "@" + tuple.Item2;

                TitleLabel.Visibility    = string.IsNullOrWhiteSpace(tuple.Item1) ? Visibility.Collapsed : Visibility.Visible;
                UsernameLabel.Visibility = string.IsNullOrWhiteSpace(tuple.Item2) ? Visibility.Collapsed : Visibility.Visible;

                View.Navigate(new Uri(tuple.Item3));
            }
        }
Exemple #10
0
        private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
        {
            var deferral = args.GetDeferral();
            var message  = args.Request.Message;

            try
            {
                if (message.ContainsKey("caption") && message.ContainsKey("request"))
                {
                    var caption = message["caption"] as string;
                    var buffer  = message["request"] as string;
                    var req     = TLSerializationService.Current.Deserialize(buffer);

                    if (caption.Equals("voip.getUser") && req is TLPeerUser userPeer)
                    {
                        var user = InMemoryCacheService.Current.GetUser(userPeer.UserId);
                        if (user != null)
                        {
                            await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(user) } });
                        }
                        else
                        {
                            //await args.Request.SendResponseAsync(new ValueSet { { "error", TLSerializationService.Current.Serialize(new TLRPCError { ErrorMessage = "USER_NOT_FOUND", ErrorCode = 404 }) } });
                        }
                    }
                    else if (caption.Equals("voip.getConfig"))
                    {
                        var config = InMemoryCacheService.Current.GetConfig();
                        await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(config) } });
                    }
                    else if (caption.Equals("voip.callInfo") && req is byte[] data)
                    {
                        using (var from = TLObjectSerializer.CreateReader(data.AsBuffer()))
                        {
                            var tupleBase = new TLTuple <int, TLPhoneCallBase, TLUserBase, string>(from);
                            var tuple     = new TLTuple <TLPhoneCallState, TLPhoneCallBase, TLUserBase, string>((TLPhoneCallState)tupleBase.Item1, tupleBase.Item2, tupleBase.Item3, tupleBase.Item4);

                            if (tuple.Item2 is TLPhoneCallDiscarded)
                            {
                                if (_phoneView != null)
                                {
                                    var newView = _phoneView;
                                    _phoneViewExists = false;
                                    _phoneView       = null;

                                    await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                    {
                                        newView.SetCall(tuple);
                                        newView.Dispose();

                                        if (newView.Dialog != null)
                                        {
                                            newView.Dialog.Hide();
                                        }
                                        else
                                        {
                                            Window.Current.Close();
                                        }
                                    });
                                }

                                return;
                            }

                            if (_phoneViewExists == false)
                            {
                                VoIPCallTask.Log("Creating VoIP UI", "Creating VoIP UI");

                                _phoneViewExists = true;

                                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                                {
                                    if (ApplicationView.GetForCurrentView().IsCompactOverlaySupported())
                                    {
                                        var newView   = CoreApplication.CreateNewView();
                                        var newViewId = 0;
                                        await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                        {
                                            var newPlayer          = new PhoneCallPage(true);
                                            Window.Current.Content = newPlayer;
                                            Window.Current.Activate();
                                            newViewId = ApplicationView.GetForCurrentView().Id;

                                            newPlayer.Dialog = null;
                                            newPlayer.SetCall(tuple);
                                            _phoneView = newPlayer;
                                        });

                                        var preferences        = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                                        preferences.CustomSize = new Size(340, 200);

                                        var viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(newViewId, ApplicationViewMode.CompactOverlay, preferences);
                                    }
                                    else
                                    {
                                        var dialog = new ContentDialogBase();
                                        dialog.VerticalAlignment   = VerticalAlignment.Stretch;
                                        dialog.HorizontalAlignment = HorizontalAlignment.Stretch;

                                        var newPlayer    = new PhoneCallPage(false);
                                        newPlayer.Dialog = dialog;
                                        newPlayer.SetCall(tuple);
                                        _phoneView = newPlayer;

                                        dialog.Content = newPlayer;
                                        await dialog.ShowAsync();
                                    }
                                });
                            }
                            else if (_phoneView != null)
                            {
                                VoIPCallTask.Log("VoIP UI already exists", "VoIP UI already exists");

                                await _phoneView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                {
                                    _phoneView.SetCall(tuple);
                                });
                            }
                        }
                    }
                    else if (caption.Equals("voip.signalBars") && req is byte[] data2)
                    {
                        using (var from = TLObjectSerializer.CreateReader(data2.AsBuffer()))
                        {
                            var tuple = new TLTuple <int>(from);

                            if (_phoneView != null)
                            {
                                await _phoneView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                {
                                    _phoneView.SetSignalBars(tuple.Item1);
                                });
                            }
                        }
                    }
                    else if (caption.Equals("voip.setCallRating") && req is TLInputPhoneCall peer)
                    {
                        Execute.BeginOnUIThread(async() =>
                        {
                            var dialog  = new PhoneCallRatingView();
                            var confirm = await dialog.ShowQueuedAsync();
                            if (confirm == ContentDialogResult.Primary)
                            {
                                await MTProtoService.Current.SetCallRatingAsync(peer, dialog.Rating, dialog.Rating >= 0 && dialog.Rating <= 3 ? dialog.Comment : null);
                            }
                        });
                    }
                    else
                    {
                        var response = await MTProtoService.Current.SendRequestAsync <object>(caption, req as TLObject);

                        if (response.IsSucceeded)
                        {
                            await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(response.Result) } });
                        }
                        else
                        {
                            await args.Request.SendResponseAsync(new ValueSet { { "error", TLSerializationService.Current.Serialize(response.Error) } });
                        }
                    }
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
Exemple #11
0
        private static TLConfigSimple DecryptSimpleConfig(string dataString)
        {
            TLConfigSimple result = null;

            var base64Chars = dataString.Where(ch =>
            {
                var isGoodBase64 =
                    (ch == '+') || (ch == '=') || (ch == '/') ||
                    (ch >= 'a' && ch <= 'z') ||
                    (ch >= 'A' && ch <= 'Z') ||
                    (ch >= '0' && ch <= '9');

                return(isGoodBase64);
            }).ToArray();

            var       cleanDataString = new string(base64Chars);
            const int kGoodSizeBase64 = 344;

            if (cleanDataString.Length != kGoodSizeBase64)
            {
                Log(string.Format("Bad base64 size {0} required {1}", cleanDataString.Length, kGoodSizeBase64));
                return(null);
            }
            byte[] data = null;
            try
            {
                data = Convert.FromBase64String(cleanDataString);
            }
            catch (Exception ex)
            {
                Log("Bad base64 bytes");

                return(null);
            }
            const int kGoodSizeData = 256;

            if (data.Length != kGoodSizeData)
            {
                Log(string.Format("Bad data size {0} required {1}", data.Length, kGoodSizeData));

                return(null);
            }

            var rsa =
                "-----BEGIN RSA PUBLIC KEY-----\n" +
                "MIIBCgKCAQEAyr+18Rex2ohtVy8sroGPBwXD3DOoKCSpjDqYoXgCqB7ioln4eDCF\n" +
                "fOBUlfXUEvM/fnKCpF46VkAftlb4VuPDeQSS/ZxZYEGqHaywlroVnXHIjgqoxiAd\n" +
                "192xRGreuXIaUKmkwlM9JID9WS2jUsTpzQ91L8MEPLJ/4zrBwZua8W5fECwCCh2c\n" +
                "9G5IzzBm+otMS/YKwmR1olzRCyEkyAEjXWqBI9Ftv5eG8m0VkBzOG655WIYdyV0H\n" +
                "fDK/NWcvGqa0w/nriMD6mDjKOryamw0OP9QuYgMN0C9xMW9y8SmP4h92OAWodTYg\n" +
                "Y1hZCxdv6cs5UnW9+PWvS+WIbkh+GaWYxwIDAQAB\n" +
                "-----END RSA PUBLIC KEY-----";

            var text      = new StringReader(rsa);
            var reader    = new PemReader(text);
            var parameter = reader.ReadObject() as RsaKeyParameters;

            var modulus  = parameter.Modulus.ToByteArray();
            var exponent = parameter.Exponent.ToByteArray();

            var dataBI     = new BigInteger(data.Reverse().Concat(new byte[] { 0x00 }).ToArray());
            var exponentBI = new BigInteger(exponent.Reverse().Concat(new byte[] { 0x00 }).ToArray());
            var modulusBI  = new BigInteger(modulus.Reverse().Concat(new byte[] { 0x00 }).ToArray());

            var authKey = BigInteger.ModPow(dataBI, exponentBI, modulusBI).ToByteArray();

            if (authKey[authKey.Length - 1] == 0x00)
            {
                authKey = authKey.SubArray(0, authKey.Length - 1);
            }

            authKey = authKey.Reverse().ToArray();
            if (authKey.Length > 256)
            {
                var correctedAuth = new byte[256];
                Array.Copy(authKey, authKey.Length - 256, correctedAuth, 0, 256);
                authKey = correctedAuth;
            }
            else if (authKey.Length < 256)
            {
                var correctedAuth = new byte[256];
                Array.Copy(authKey, 0, correctedAuth, 256 - authKey.Length, authKey.Length);
                for (var i = 0; i < 256 - authKey.Length; i++)
                {
                    authKey[i] = 0;
                }
                authKey = correctedAuth;
            }

            var key           = authKey.SubArray(0, 32);
            var iv            = authKey.SubArray(16, 16);
            var encryptedData = authKey.SubArray(32, authKey.Length - 32);

            var cipher = CipherUtilities.GetCipher("AES/CBC/NOPADDING");
            var param  = new KeyParameter(key);

            cipher.Init(false, new ParametersWithIV(param, iv));
            var decryptedData = cipher.DoFinal(encryptedData);

            const int kDigestSize = 16;
            var       hash        = Utils.ComputeSHA256(decryptedData.SubArray(0, 208));

            for (var i = 0; i < kDigestSize; i++)
            {
                if (hash[i] != decryptedData[208 + i])
                {
                    Log("Bad digest");
                    return(null);
                }
            }

            using (var from = TLObjectSerializer.CreateReader(decryptedData.AsBuffer()))
            {
                var length = from.ReadInt32();
                if (length <= 0 || length > 208 || length % 4 != 0)
                {
                    Log(string.Format("Bad length {0}", length));
                    return(null);
                }

                try
                {
                    result = TLFactory.Read <TLConfigSimple>(from);
                }
                catch (Exception ex)
                {
                    Log("Could not read configSimple");
                    return(null);
                }

                if (from.Position != length)
                {
                    Log(string.Format("Bad read length {0} shoud be {1}", from.Position, length));
                    return(null);
                }
            }

            return(result);
        }
Exemple #12
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return;
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLPeerChannel, TLChannelParticipantBase>(from);
                if (tuple.Item2 is TLChannelParticipant participant)
                {
                    IsAdminAlready = false;

                    tuple.Item2 = new TLChannelParticipantAdmin
                    {
                        UserId      = participant.UserId,
                        Date        = participant.Date,
                        IsCanEdit   = true,
                        AdminRights = new TLChannelAdminRights
                        {
                            IsChangeInfo     = true,
                            IsPinMessages    = true,
                            IsInviteLink     = true,
                            IsInviteUsers    = true,
                            IsBanUsers       = true,
                            IsDeleteMessages = true,
                            IsEditMessages   = true,
                            IsPostMessages   = true,
                            IsAddAdmins      = false
                        }
                    };
                }
                else if (tuple.Item2 is TLChannelParticipantBanned banned)
                {
                    IsAdminAlready = false;

                    tuple.Item2 = new TLChannelParticipantAdmin
                    {
                        UserId      = banned.UserId,
                        Date        = banned.Date,
                        IsCanEdit   = true,
                        AdminRights = new TLChannelAdminRights
                        {
                            IsChangeInfo     = true,
                            IsPinMessages    = true,
                            IsInviteLink     = true,
                            IsInviteUsers    = true,
                            IsBanUsers       = true,
                            IsDeleteMessages = true,
                            IsEditMessages   = true,
                            IsPostMessages   = true,
                            IsAddAdmins      = false
                        }
                    };
                }

                Channel = CacheService.GetChat(tuple.Item1.ChannelId) as TLChannel;
                Item    = tuple.Item2 as TLChannelParticipantAdmin;

                IsAddAdmins      = _item.AdminRights.IsAddAdmins;
                IsPinMessages    = _item.AdminRights.IsPinMessages;
                IsInviteLink     = _item.AdminRights.IsInviteLink;
                IsInviteUsers    = _item.AdminRights.IsInviteUsers;
                IsBanUsers       = _item.AdminRights.IsBanUsers;
                IsDeleteMessages = _item.AdminRights.IsDeleteMessages;
                IsEditMessages   = _item.AdminRights.IsEditMessages;
                IsPostMessages   = _item.AdminRights.IsPostMessages;
                IsChangeInfo     = _item.AdminRights.IsChangeInfo;

                var user = tuple.Item2.User;
                if (user == null)
                {
                    return;
                }

                var full = CacheService.GetFullUser(user.Id);
                if (full == null)
                {
                    var response = await ProtoService.GetFullUserAsync(user.ToInputUser());

                    if (response.IsSucceeded)
                    {
                        full = response.Result;
                    }
                }

                Full = full;
            }
        }
Exemple #13
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return;
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLPeerChannel, TLChannelParticipantBase>(from);
                if (tuple.Item2 is TLChannelParticipant participant)
                {
                    IsBannedAlready = false;

                    tuple.Item2 = new TLChannelParticipantBanned
                    {
                        UserId       = participant.UserId,
                        Date         = participant.Date,
                        BannedRights = new TLChannelBannedRights
                        {
                            IsViewMessages = true,
                            IsSendMessages = false,
                            IsSendMedia    = false,
                            IsSendStickers = false,
                            IsSendGifs     = false,
                            IsSendGames    = false,
                            IsSendInline   = false,
                            IsEmbedLinks   = false
                        }
                    };
                }
                else if (tuple.Item2 is TLChannelParticipantAdmin admin)
                {
                    IsBannedAlready = false;

                    tuple.Item2 = new TLChannelParticipantBanned
                    {
                        UserId       = admin.UserId,
                        Date         = admin.Date,
                        BannedRights = new TLChannelBannedRights
                        {
                            IsViewMessages = true,
                            IsSendMessages = false,
                            IsSendMedia    = false,
                            IsSendStickers = false,
                            IsSendGifs     = false,
                            IsSendGames    = false,
                            IsSendInline   = false,
                            IsEmbedLinks   = false
                        }
                    };
                }

                Channel = CacheService.GetChat(tuple.Item1.ChannelId) as TLChannel;
                Item    = tuple.Item2 as TLChannelParticipantBanned;

                IsEmbedLinks   = _item.BannedRights.IsEmbedLinks;
                IsSendInline   = _item.BannedRights.IsSendInline;
                IsSendGames    = _item.BannedRights.IsSendGames;
                IsSendGifs     = _item.BannedRights.IsSendGifs;
                IsSendStickers = _item.BannedRights.IsSendStickers;
                IsSendMedia    = _item.BannedRights.IsSendMedia;
                IsSendMessages = _item.BannedRights.IsSendMessages;
                IsViewMessages = _item.BannedRights.IsViewMessages;

                var user = tuple.Item2.User;
                if (user == null)
                {
                    return;
                }

                var full = CacheService.GetFullUser(user.Id);
                if (full == null)
                {
                    var response = await ProtoService.GetFullUserAsync(user.ToInputUser());

                    if (response.IsSucceeded)
                    {
                        full = response.Result;
                    }
                }

                Full = full;
            }
        }