public async void SendDocument(StorageFile file)
        {
            var chat = Chat as TLEncryptedChat;

            if (chat == null)
            {
                return;
            }

            if (file == null)
            {
                return;
            }

            var properties = await file.GetBasicPropertiesAsync();

            var size = properties.Size;

            if (!DialogDetailsViewModel.CheckDocumentSize(size))
            {
                MessageBox.Show(string.Format(AppResources.MaximumFileSizeExceeded, MediaSizeConverter.Convert((int)Telegram.Api.Constants.MaximumUploadedFileSize)), AppResources.Error, MessageBoxButton.OK);
                return;
            }

            DialogDetailsViewModel.AddFileToFutureAccessList(file);

            var thumb = await DialogDetailsViewModel.GetFileThumbAsync(file) as TLPhotoSize;

            var dcId       = TLInt.Random();
            var id         = TLLong.Random();
            var accessHash = TLLong.Random();

            var fileLocation = new TLEncryptedFile
            {
                Id             = id,
                AccessHash     = accessHash,
                DCId           = dcId,
                Size           = new TLInt((int)size),
                KeyFingerprint = new TLInt(0),
                FileName       = new TLString(Path.GetFileName(file.Name))
            };

            var keyIV = GenerateKeyIV();

            var decryptedMediaDocumentBase = GetDecryptedMediaDocument(file, chat, thumb, size, keyIV, fileLocation);
            var decryptedMediaDocument45   = decryptedMediaDocumentBase as TLDecryptedMessageMediaDocument45;

            if (decryptedMediaDocument45 != null)
            {
                if (string.Equals(decryptedMediaDocument45.FileExt, "webp", StringComparison.OrdinalIgnoreCase) &&
                    decryptedMediaDocument45.DocumentSize < Telegram.Api.Constants.StickerMaxSize)
                {
                    decryptedMediaDocument45.MimeType = new TLString("image/webp");
                    decryptedMediaDocument45.Attributes.Add(new TLDocumentAttributeSticker29 {
                        Alt = TLString.Empty, Stickerset = new TLInputStickerSetEmpty()
                    });

                    var fileName = decryptedMediaDocument45.GetFileName();
                    await file.CopyAsync(ApplicationData.Current.LocalFolder, fileName, NameCollisionOption.ReplaceExisting);
                }
                else if (string.Equals(decryptedMediaDocument45.FileExt, "mp3", StringComparison.OrdinalIgnoreCase))
                {
                    var musicProperties = await file.Properties.GetMusicPropertiesAsync();

                    if (musicProperties != null)
                    {
                        var documentAttributeAudio = new TLDocumentAttributeAudio32 {
                            Duration = new TLInt(0), Title = TLString.Empty, Performer = TLString.Empty
                        };
                        documentAttributeAudio.Duration = new TLInt((int)musicProperties.Duration.TotalSeconds);
                        if (!string.IsNullOrEmpty(musicProperties.Title))
                        {
                            documentAttributeAudio.Title = new TLString(musicProperties.Title);
                        }
                        if (!string.IsNullOrEmpty(musicProperties.Artist))
                        {
                            documentAttributeAudio.Performer = new TLString(musicProperties.Artist);
                        }
                        decryptedMediaDocument45.Attributes.Add(documentAttributeAudio);
                    }
                }
            }
            var decryptedTuple = GetDecryptedMessageAndObject(TLString.Empty, decryptedMediaDocumentBase, chat, true);

            BeginOnUIThread(() =>
            {
                InsertSendingMessage(decryptedTuple.Item1);
                RaiseScrollToBottom();
                NotifyOfPropertyChange(() => DescriptionVisibility);

                BeginOnThreadPool(() =>
                                  CacheService.SyncDecryptedMessage(decryptedTuple.Item1, chat,
                                                                    cachedMessage => SendDocumentInternal(file, decryptedTuple.Item2)));
            });
        }
        public async void SendDocument(StorageFile file)
        {
            var chat = Chat as TLEncryptedChat;

            if (chat == null)
            {
                return;
            }

            if (file == null)
            {
                return;
            }

            var properties = await file.GetBasicPropertiesAsync();

            var size = properties.Size;

            if (!DialogDetailsViewModel.CheckDocumentSize(size))
            {
                MessageBox.Show(string.Format(AppResources.MaximumFileSizeExceeded, MediaSizeConverter.Convert((int)Telegram.Api.Constants.MaximumUploadedFileSize)), AppResources.Error, MessageBoxButton.OK);
                return;
            }

            DialogDetailsViewModel.AddFileToFutureAccessList(file);

            var thumb = await DialogDetailsViewModel.GetFileThumbAsync(file) as TLPhotoSize;

            var dcId       = TLInt.Random();
            var id         = TLLong.Random();
            var accessHash = TLLong.Random();

            var fileLocation = new TLEncryptedFile
            {
                Id             = id,
                AccessHash     = accessHash,
                DCId           = dcId,
                Size           = new TLInt((int)size),
                KeyFingerprint = new TLInt(0),
                FileName       = new TLString(Path.GetFileName(file.Name))
            };

            var keyIV = GenerateKeyIV();

            var decryptedMediaDocument = new TLDecryptedMessageMediaDocument
            {
                Thumb    = thumb != null? thumb.Bytes : TLString.Empty,
                ThumbW   = thumb != null? thumb.W : new TLInt(0),
                ThumbH   = thumb != null? thumb.H : new TLInt(0),
                FileName = new TLString(Path.GetFileName(file.Name)),
                MimeType = new TLString(file.ContentType),
                Size     = new TLInt((int)size),
                Key      = keyIV.Item1,
                IV       = keyIV.Item2,

                File        = fileLocation,
                StorageFile = file,

                UploadingProgress = 0.001
            };

            var decryptedTuple = GetDecryptedMessageAndObject(TLString.Empty, decryptedMediaDocument, chat, true);

            BeginOnUIThread(() =>
            {
                Items.Insert(0, decryptedTuple.Item1);
                RaiseScrollToBottom();
                NotifyOfPropertyChange(() => DescriptionVisibility);

                BeginOnThreadPool(() =>
                                  CacheService.SyncDecryptedMessage(decryptedTuple.Item1, chat,
                                                                    cachedMessage => SendDocumentInternal(file, decryptedTuple.Item2)));
            });
        }