test refresh

This commit is contained in:
2024-02-17 12:56:11 +09:00
parent 0183000dbb
commit 7c82fb1512
22 changed files with 97 additions and 35 deletions

View File

@ -6,8 +6,10 @@ use crate::bot::c_bot;
use crate::data::c_follow_all;
use crate::data::c_openai_key;
use crate::data::data_toml;
use crate::data::data_refresh;
use crate::data::url;
use crate::data::w_cfg;
use crate::data::w_refresh;
use data::ProfileIdentityResolve;
@ -280,12 +282,14 @@ fn token(c: &Context) {
if let Ok(p) = c.string_flag("password") {
if let Ok(s) = c.string_flag("server") {
let res = token::post_request(m.to_string(), p.to_string(), s.to_string()).await;
w_cfg(&s, &res)
w_cfg(&s, &res);
w_refresh(&res);
} else {
let res =
token::post_request(m.to_string(), p.to_string(), "bsky.social".to_string())
.await;
w_cfg(&"bsky.social", &res)
w_cfg(&"bsky.social", &res);
w_refresh(&res);
}
}
};
@ -294,15 +298,12 @@ fn token(c: &Context) {
}
fn refresh(_c: &Context) {
let server = data_toml(&"host");
let h = async {
let session = session::get_request().await;
if session == "err" {
let res = refresh::post_request().await;
println!("{}", res);
w_cfg(&server, &res)
} else {
println!("no refresh");
w_refresh(&res)
}
};
let res = tokio::runtime::Runtime::new().unwrap().block_on(h);
@ -497,7 +498,7 @@ fn reply(c: &Context) {
#[tokio::main]
async fn c_img_upload(c: &Context) -> reqwest::Result<()> {
let token = data_toml(&"access");
let token = data_refresh(&"access");
let atoken = "Authorization: Bearer ".to_owned() + &token;
let con = "Content-Type: image/png";
let url = url(&"upload_blob");