ayrat555 / frankenstein

Telegram bot API client for Rust
Do What The F*ck You Want To Public License
268 stars 28 forks source link

Adds new_with_client() inteface to AsyncApi #66

Closed aserebryakov closed 2 years ago

aserebryakov commented 2 years ago

If you use self-signed certificate, the following error appears when you use AsyncTelegramApi:

Failed to get updates: HttpError(HttpError { code: 500, message: "error sending request for url (https://api.telegram.org/bot5322455292:AAF0lBHoR4x1HdwrG8eZ8iJwrp4DZhvWPdU/getUpdates): error trying to connect: invalid peer certificate contents: invalid peer certificate: UnknownIssuer" })

So I added an option to use REQWEST_USE_INSECURE_CERTS environment variable to be set (value doesn't matter) to allow using such certificates.

ayrat555 commented 2 years ago

@aserebryakov hello. Your changes look ok.

what do you think about passing a full client ? for example

   pub fn new_with_client(api_client: Client, api_url: String) -> Self {
        Self { api_url, client }
    }

and reqwest can be exported in the lib.rs so its client can be instantiated

#[doc(hidden)]
#[cfg(any(feature = "async-http-client"))]
pub use reqwest;
aserebryakov commented 2 years ago

I am quite new for Rust, but I can try to do that. Also I see that I need to fix failed checks.

I guess unwrap() isn't a good idea to be used in new() call.

aserebryakov commented 2 years ago

@arkada38, Please review changes. I finally implemented it.

ayrat555 commented 2 years ago

@aserebryakov @EdJoPaTo Thank you!

the changes were released in 0.15.1