public Task ClickUserInformationPrimaryAction(string address)
        {
            return(Task.Factory.StartNew(() =>
            {
                if (address == null)
                {
                    return;
                }

                var user = _dialogs.GetUser(uint.Parse(address));
                var phoneNumber = TelegramUtils.GetUserPhoneNumber(user);
                if (!string.IsNullOrWhiteSpace(phoneNumber))
                {
                    Platform.DialContact(
                        TelegramUtils.ConvertTelegramPhoneNumberIntoInternational(phoneNumber));
                    return;
                }
            }));
        }
Exemple #2
0
 public Task ClickUserInformationSecondaryAction(string address)
 {
     return(Task.Factory.StartNew(() =>
     {
         foreach (var user in _dialogs.Users)
         {
             var userId = TelegramUtils.GetUserId(user);
             if (userId == address)
             {
                 var phoneNumber = TelegramUtils.GetUserPhoneNumber(user);
                 if (!string.IsNullOrWhiteSpace(phoneNumber))
                 {
                     Platform.OpenContact(
                         TelegramUtils.ConvertTelegramPhoneNumberIntoInternational(phoneNumber));
                     return;
                 }
             }
         }
     }));
 }
Exemple #3
0
        public Task GetUserInformation(string address, Action <Disa.Framework.UserInformation> result)
        {
            return(Task.Factory.StartNew(async() =>
            {
                foreach (var user in _dialogs.Users)
                {
                    var userId = TelegramUtils.GetUserId(user);
                    if (userId == address)
                    {
                        using (var client = new FullClientDisposable(this))
                        {
                            var inputUser = TelegramUtils.CastUserToInputUser(user);
                            var updatedUser = await GetUser(inputUser, client.Client);
                            var name = TelegramUtils.GetUserName(updatedUser);
                            var lastSeen = TelegramUtils.GetLastSeenTime(updatedUser);
                            var presence = TelegramUtils.GetAvailable(updatedUser);
                            var phoneNumber = TelegramUtils.GetUserPhoneNumber(updatedUser);

                            if (string.IsNullOrWhiteSpace(name))
                            {
                                result(null);  //TODO: ensure this doesn't crash Disa
                                return;
                            }
                            result(new UserInformation
                            {
                                Title = name,
                                SubtitleType = string.IsNullOrWhiteSpace(phoneNumber) ?
                                               UserInformation.TypeSubtitle.Other : UserInformation.TypeSubtitle.PhoneNumber,
                                Subtitle = string.IsNullOrWhiteSpace(phoneNumber) ?
                                           address : TelegramUtils.ConvertTelegramPhoneNumberIntoInternational(phoneNumber),
                                LastSeen = lastSeen,
                                Presence = presence,
                            });
                            return;
                        }
                    }
                }
                result(null);  //TODO: ensure this doesn't crash Disa
            }));
        }
        public Task GetUserInformation(string address, Action <Disa.Framework.UserInformation> result)
        {
            return(Task.Factory.StartNew(() =>
            {
                if (address == null)
                {
                    return;
                }

                var user = _dialogs.GetUser(uint.Parse(address));
                using (var client = new FullClientDisposable(this))
                {
                    var name = TelegramUtils.GetUserName(user);
                    var lastSeen = TelegramUtils.GetLastSeenTime(user);
                    var presence = TelegramUtils.GetAvailable(user);
                    var phoneNumber = TelegramUtils.GetUserPhoneNumber(user);

                    if (string.IsNullOrWhiteSpace(name))
                    {
                        result(null); //TODO: ensure this doesn't crash Disa
                        return;
                    }
                    result(new UserInformation
                    {
                        Title = name,
                        SubtitleType = string.IsNullOrWhiteSpace(phoneNumber)
                            ? UserInformation.TypeSubtitle.Other
                            : UserInformation.TypeSubtitle.PhoneNumber,
                        Subtitle = string.IsNullOrWhiteSpace(phoneNumber)
                            ? TelegramUtils.GetUserHandle(user)
                            : TelegramUtils.ConvertTelegramPhoneNumberIntoInternational(phoneNumber),
                        LastSeen = lastSeen,
                        Presence = presence,
                        UserHandle = TelegramUtils.GetUserHandle(user),
                    });
                }
            }));
        }