@@ -36,6 +36,7 @@ use gtk::prelude::*;
3636use gtk:: subclass:: prelude:: * ;
3737use gtk:: { gio, glib, CompositeTemplate } ;
3838use std:: borrow:: Borrow ;
39+ use std:: fmt:: Debug ;
3940use std:: fs;
4041use std:: time:: { SystemTime , UNIX_EPOCH } ;
4142use tdlib:: enums:: { self , AuthorizationState , Update } ;
@@ -729,6 +730,35 @@ impl SessionManager {
729730 }
730731 }
731732
733+ pub ( crate ) fn handle_telegram_link ( & self , link : String ) {
734+ let client_id = self . active_logged_in_client_id ( ) ;
735+ if let Some ( client_id) = client_id {
736+ spawn ( clone ! ( @weak self as obj => async move {
737+ let result = functions:: get_internal_link_type( link, client_id) . await ;
738+ if let Some ( link_type) = result. ok( ) {
739+ use enums:: InternalLinkType :: * ;
740+ match link_type {
741+ PublicChat ( data) => obj. open_chat_by_username( data. chat_username) ,
742+ _ => ( ) ,
743+ }
744+ }
745+ } ) ) ;
746+ }
747+ }
748+
749+ pub ( crate ) fn open_chat_by_username ( & self , username : String ) {
750+ let client_id = self . active_logged_in_client_id ( ) ;
751+ if let Some ( client_id) = client_id {
752+ spawn ( clone ! ( @weak self as obj => async move {
753+ let result = functions:: search_public_chat( username, client_id) . await ;
754+ if let Ok ( chat) = result {
755+ let enums:: Chat :: Chat ( chat) = chat;
756+ obj. select_chat( client_id, chat. id) ;
757+ }
758+ } ) )
759+ }
760+ }
761+
732762 pub ( crate ) fn begin_chats_search ( & self ) {
733763 if let Some ( client_id) = self . active_logged_in_client_id ( ) {
734764 let clients = self . imp ( ) . clients . borrow ( ) ;
0 commit comments