public static InputPeer PeerToInputPeer(Peer peer) { switch (peer.Constructor) { case Constructor.peerUser: // TODO: foreign and self cases return(TL.inputPeerContact(((PeerUserConstructor)peer).user_id)); case Constructor.peerChat: return(TL.inputPeerChat(((PeerChatConstructor)peer).chat_id)); default: throw new Exception("invalid constructor"); } }
private void OnDialogSelected(object sender, DialogModel model) { InputPeer inputPeer = null; if (!(model is DialogModelPlain)) { return; } DialogModelPlain dmp = (DialogModelPlain)model; if (fromMedia == 1) { MessageMedia media = MediaTransitionHelper.Instance.Media; InputMedia im = null; if (media.Constructor == Constructor.messageMediaPhoto) { MessageMediaPhotoConstructor mmpc = (MessageMediaPhotoConstructor)media; InputPhoto ip = TL.inputPhoto(((PhotoConstructor)mmpc.photo).id, ((PhotoConstructor)mmpc.photo).access_hash); im = TL.inputMediaPhoto(ip); } else if (media.Constructor == Constructor.messageMediaVideo) { MessageMediaVideoConstructor mmvc = (MessageMediaVideoConstructor)media; InputVideo iv = TL.inputVideo(((VideoConstructor)mmvc.video).id, ((VideoConstructor)mmvc.video).access_hash); im = TL.inputMediaVideo(iv); } else if (media.Constructor == Constructor.messageMediaGeo) { MessageMediaGeoConstructor mmgc = (MessageMediaGeoConstructor)media; GeoPointConstructor gpc = (GeoPointConstructor)mmgc.geo; InputGeoPoint point = TL.inputGeoPoint(gpc.lat, gpc.lng); im = TL.inputMediaGeoPoint(point); } if (im != null) { dmp.SendMedia(im); NavigationService.GoBack(); } return; } if (messageId.Count == 0) { logger.error("error forwarding, no messageId"); } Peer peer = model.Peer; if (model.IsChat) { inputPeer = TL.inputPeerChat(((PeerChatConstructor)peer).chat_id); } else { inputPeer = TL.inputPeerContact(((PeerUserConstructor)peer).user_id); } DoForwardMessages(inputPeer); int modelId = TelegramSession.Instance.Dialogs.Model.Dialogs.IndexOf(model); NavigationService.Navigate(new Uri("/UI/Pages/DialogPage.xaml?modelId=" + modelId, UriKind.Relative)); }