Update TokenService client

This commit is contained in:
toast 2024-03-27 10:15:47 +11:00
parent 00ad90be28
commit 907d805577
3 changed files with 12 additions and 10 deletions

16
Cargo.lock generated
View File

@ -910,9 +910,9 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.10" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
@ -1430,9 +1430,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.8.2" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
[[package]] [[package]]
name = "reqwest" name = "reqwest"
@ -1745,9 +1745,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.114" version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -2063,9 +2063,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokenservice-client" name = "tokenservice-client"
version = "0.1.0" version = "0.2.0"
source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/" source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/"
checksum = "7da0d635427394e32f228f3c0c7642e1ffd3fe1f668739b1435fd737bb9f58e6" checksum = "ce6d723554b87f8068463a7aae14ed604e2804a8a0827d251d7ac08850bac18e"
dependencies = [ dependencies = [
"reqwest 0.12.2", "reqwest 0.12.2",
"serde", "serde",

View File

@ -9,7 +9,7 @@ once_cell = "1.19.0"
poise = "0.6.1" poise = "0.6.1"
sysinfo = "0.30.7" sysinfo = "0.30.7"
tempfile = "3.10.1" tempfile = "3.10.1"
tokenservice-client = { version = "0.1.0", registry = "gitea" } tokenservice-client = { version = "0.2.0", registry = "gitea" }
tokio = { version = "1.36.0", features = ["macros", "signal", "rt-multi-thread"] } tokio = { version = "1.36.0", features = ["macros", "signal", "rt-multi-thread"] }
tokio-postgres = "0.7.10" tokio-postgres = "0.7.10"
uptime_lib = "0.3.0" uptime_lib = "0.3.0"

View File

@ -6,8 +6,10 @@ pub struct TSClient {
impl TSClient { impl TSClient {
pub fn new() -> Self { pub fn new() -> Self {
let args: Vec<String> = std::env::args().collect();
let service = if args.len() > 1 { args[1].as_str() } else { "pgbot" };
TSClient { TSClient {
client: TokenService::new("pgbot") client: TokenService::new(service)
} }
} }
pub async fn get(&self) -> Result<TokenServiceApi, Box<dyn std::error::Error>> { pub async fn get(&self) -> Result<TokenServiceApi, Box<dyn std::error::Error>> {