private async void RevokeExecute()
        {
            var confirm = await TLMessageDialog.ShowAsync(Strings.Android.RevokeAlert, Strings.Android.RevokeLink, Strings.Android.RevokeButton, Strings.Android.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                Task <MTProtoResponse <TLExportedChatInviteBase> > task = null;

                if (_peer is TLPeerChannel peerChannel)
                {
                    var channel = CacheService.GetChat(peerChannel.ChannelId) as TLChannel;
                    if (channel != null)
                    {
                        task = ProtoService.ExportInviteAsync(channel.ToInputChannel());
                    }
                }
                else if (_peer is TLPeerChat peerChat)
                {
                    var chat = CacheService.GetChat(peerChat.ChatId) as TLChat;
                    if (chat != null)
                    {
                        task = ProtoService.ExportChatInviteAsync(chat.Id);
                    }
                }

                if (task != null)
                {
                    var response = await task;
                    if (response.IsSucceeded)
                    {
                        _exportedInvite = response.Result;

                        if (_full != null)
                        {
                            _full.ExportedInvite = response.Result;
                        }

                        var invite = response.Result as TLChatInviteExported;
                        if (invite != null && !string.IsNullOrEmpty(invite.Link))
                        {
                            InviteLink = invite.Link;

                            await TLMessageDialog.ShowAsync(Strings.Android.RevokeAlertNewLink, Strings.Android.RevokeLink, Strings.Android.OK);
                        }
                    }
                    else
                    {
                        Execute.ShowDebugMessage("channels.exportInvite error " + response.Error);
                    }
                }
            }
        }
Example #2
0
        private async void RevokeExecute()
        {
            var confirm = await TLMessageDialog.ShowAsync("Are you sure you want to revoke this link? Once you do, no one will be able to join the group using it.", "Telegram", "Revoke", "Cancel");

            if (confirm == ContentDialogResult.Primary)
            {
                Task <MTProtoResponse <TLExportedChatInviteBase> > task = null;

                if (_peer is TLPeerChannel peerChannel)
                {
                    var channel = CacheService.GetChat(peerChannel.ChannelId) as TLChannel;
                    if (channel != null)
                    {
                        task = ProtoService.ExportInviteAsync(channel.ToInputChannel());
                    }
                }
                else if (_peer is TLPeerChat peerChat)
                {
                    var chat = CacheService.GetChat(peerChat.ChatId) as TLChat;
                    if (chat != null)
                    {
                        task = ProtoService.ExportChatInviteAsync(chat.Id);
                    }
                }

                if (task != null)
                {
                    var response = await task;
                    if (response.IsSucceeded)
                    {
                        _exportedInvite = response.Result;

                        var invite = response.Result as TLChatInviteExported;
                        if (invite != null && !string.IsNullOrEmpty(invite.Link))
                        {
                            InviteLink = invite.Link;

                            await TLMessageDialog.ShowAsync("The previous invite link is now inactive. A new invite link has just been generated.", "Telegram", "OK");
                        }
                    }
                    else
                    {
                        Execute.ShowDebugMessage("channels.exportInvite error " + response.Error);
                    }
                }
            }
        }
Example #3
0
        private async void ExportInvite()
        {
            var response = await ProtoService.ExportInviteAsync(_item.ToInputChannel());

            if (response.IsSucceeded)
            {
                _exportedInvite = response.Result;

                var invite = response.Result as TLChatInviteExported;
                if (invite != null && !string.IsNullOrEmpty(invite.Link))
                {
                    InviteLink = invite.Link;
                }
            }
            else
            {
                Execute.ShowDebugMessage("channels.exportInvite error " + response.Error);
            }
        }
Example #4
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            Task <MTProtoResponse <TLExportedChatInviteBase> > task = null;

            if (parameter is TLPeerChannel peerChannel)
            {
                _peer = peerChannel;

                var channel = CacheService.GetChat(peerChannel.ChannelId) as TLChannel;
                if (channel != null)
                {
                    Item = channel;

                    var full = CacheService.GetFullChat(channel.Id) as TLChannelFull;
                    if (full == null)
                    {
                        var response = await ProtoService.GetFullChannelAsync(channel.ToInputChannel());

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

                    if (full != null)
                    {
                        _exportedInvite = full.ExportedInvite;

                        if (full.ExportedInvite is TLChatInviteExported invite)
                        {
                            InviteLink = invite.Link;
                        }
                        else
                        {
                            task = ProtoService.ExportInviteAsync(channel.ToInputChannel());
                        }
                    }
                }
            }
            else if (parameter is TLPeerChat peerChat)
            {
                _peer = peerChat;

                var chat = CacheService.GetChat(peerChat.ChatId) as TLChat;
                if (chat != null)
                {
                    Item = chat;

                    var full = CacheService.GetFullChat(chat.Id) as TLChannelFull;
                    if (full == null)
                    {
                        var response = await ProtoService.GetFullChatAsync(chat.Id);

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

                    if (full != null)
                    {
                        _exportedInvite = full.ExportedInvite;

                        if (full.ExportedInvite is TLChatInviteExported invite)
                        {
                            InviteLink = invite.Link;
                        }
                        else
                        {
                            task = ProtoService.ExportChatInviteAsync(chat.Id);
                        }
                    }
                }
            }

            if (task != null)
            {
                var response = await task;
                if (response.IsSucceeded)
                {
                    _exportedInvite = response.Result;

                    var invite = response.Result as TLChatInviteExported;
                    if (invite != null && !string.IsNullOrEmpty(invite.Link))
                    {
                        InviteLink = invite.Link;
                    }
                }
                else
                {
                    Execute.ShowDebugMessage("channels.exportInvite error " + response.Error);
                }
            }
        }