From 38efc7de29415a5f87f0c8bce90cad6df28c8886 Mon Sep 17 00:00:00 2001 From: CMahaff Date: Sat, 8 Jul 2023 17:11:24 -0400 Subject: [PATCH] Fix Issue #4 Set a user-agent so we don't get blocked by lemmy.ml. --- Cargo.toml | 2 +- README.md | 2 +- src/lemmy/api.rs | 9 +++++++-- src/ui/app.slint | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f477b67..2e95979 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lasim" authors = ["Connor Mahaffey"] -version = "0.1.0" +version = "0.1.1" edition = "2021" license = "MIT" publish = false diff --git a/README.md b/README.md index 7d8917b..4f67459 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,4 @@ ## Version Support | LASIM Version | LASIM Profile Version | Supported Lemmy BE API Version | | ------------- | --------------------- | ------------------------------ | -| 0.1.0 | 1 | 0.18.1-rc.9+ | +| 0.1.\* | 1 | 0.18.1 (rc.9+) | diff --git a/src/lemmy/api.rs b/src/lemmy/api.rs index c0e1752..f3bffef 100644 --- a/src/lemmy/api.rs +++ b/src/lemmy/api.rs @@ -4,6 +4,7 @@ use lemmy_api_common::site; use lemmy_api_common::community; use lemmy_api_common::lemmy_db_schema::newtypes; use reqwest::Client; +use reqwest::ClientBuilder; use reqwest::Response; use reqwest::Error; use url::Url; @@ -16,8 +17,12 @@ pub struct API { impl API { pub fn new(instance: Url) -> API { - API { - client: Client::new(), + let mut client_builder = ClientBuilder::new(); + client_builder = client_builder.user_agent("LASIM - https://github.com/CMahaff/lasim"); + let new_client = client_builder.build().unwrap(); + + return API { + client: new_client, instance, } } diff --git a/src/ui/app.slint b/src/ui/app.slint index 08debcd..4b40d76 100644 --- a/src/ui/app.slint +++ b/src/ui/app.slint @@ -45,7 +45,7 @@ export component App inherits Window { Text { font-size: 20px; font-weight: 900; - text: "LASIM 0.1.0"; + text: "LASIM 0.1.1"; } Text { text: "Lemmy BE API Version 0.18.1-rc.9";