Closed seguidor777 closed 3 years ago
I just realized that the session already persists and the auth_key_id is used for subsequent connections. I just don't know where is it stored locally and how the telegram client is able to read it and send it. The method that I'm requesting is really irrelevant in this case. I would appreciate if you can give me some info about how the client handles session persistence
Your references link is telegram bot api. not telegram client (tdjson) api. the tdjson documents is here https://core.telegram.org/tdlib/docs/classes.html
About your question. in tdlib, I think the session data is store in sqlite db. the path is your set use set_tdlib_parameters
https://github.com/fewensa/telegram-client/blob/684d84df82f64c8e5cbcd4df4f3053ababd4f0df/examples/client_event.rs#L75
/// The path to the directory for the persistent database; if empty, the current working directory will be used
database_directory: String,
But I don't know how to read it. maybe tdjson has some api to read, and you can look for it from the api or go to td repository to raise an issue.
If there are any questions or progress, you can also tell me.
tdlib $ ls -l
total 4588
drwxrwxr-x 2 user user 0 Aug 21 17:53 animations
-rw-rw-r-- 1 user user 507904 Aug 21 21:28 db.sqlite
-rw-rw-r-- 1 user user 32768 Aug 22 23:54 db.sqlite-shm
-rw-rw-r-- 1 user user 4120032 Aug 22 23:55 db.sqlite-wal
drwxrwxr-x 2 user user 0 Aug 21 17:53 documents
drwxrwxr-x 2 user user 0 Aug 21 17:53 music
drwxrwxr-x 2 user user 0 Aug 21 17:53 passport
drwxrwxr-x 2 user user 0 Aug 21 17:53 photos
drwxrwxr-x 2 user user 0 Aug 21 17:53 profile_photos
drwxrwxr-x 2 user user 0 Aug 21 17:53 secret
drwxrwxr-x 2 user user 0 Aug 21 17:53 secret_thumbnails
drwxrwxr-x 2 user user 0 Aug 21 17:53 stickers
-rw-rw-r-- 1 user user 36360 Aug 22 23:55 td.binlog
drwxrwxr-x 2 user user 0 Aug 22 15:57 temp
drwxrwxr-x 2 user user 0 Aug 22 15:57 thumbnails
drwxrwxr-x 2 user user 0 Aug 21 17:53 video_notes
drwxrwxr-x 2 user user 0 Aug 21 17:53 videos
drwxrwxr-x 2 user user 0 Aug 21 17:53 voice
drwxrwxr-x 2 user user 0 Aug 21 17:53 wallpapers
This is list of tdlib path
db.sqlite
db.sqlite-shm
db.sqlite-wal
these files is stored by td, all login session will save to there
Ok, got it. I already saw that directory but didn't imagine that the session was stored there. Thanks for pointing me to the right direction. Cheers
Hi,
I would like to know if this method is available in this crate, I think is useful to make the session persistent between restarts by reusing the auth_key_id
References: https://core.telegram.org/method/auth.importAuthorization https://core.telegram.org/api/auth#we-are-authorized