2
0

fix notify

This commit is contained in:
2026-03-30 12:48:35 +09:00
parent 4dd50c4937
commit 6351f71bda
3 changed files with 15 additions and 9 deletions

View File

@@ -94,8 +94,10 @@ async fn do_refresh(session: &Session, pds: &str) -> Result<Session> {
/// Refresh access token (OAuth-aware: tries OAuth first, falls back to legacy) /// Refresh access token (OAuth-aware: tries OAuth first, falls back to legacy)
pub async fn refresh_session() -> Result<Session> { pub async fn refresh_session() -> Result<Session> {
if oauth::has_oauth_session(false) { if oauth::has_oauth_session(false) {
let (_oauth, session) = oauth::refresh_oauth_session(false).await?; match oauth::refresh_oauth_session(false).await {
return Ok(session); Ok((_oauth, session)) => return Ok(session),
Err(_) => { /* OAuth failed, fall back to legacy */ }
}
} }
let session = token::load_session()?; let session = token::load_session()?;
@@ -110,8 +112,10 @@ pub async fn refresh_session() -> Result<Session> {
/// Refresh bot access token (OAuth-aware) /// Refresh bot access token (OAuth-aware)
pub async fn refresh_bot_session() -> Result<Session> { pub async fn refresh_bot_session() -> Result<Session> {
if oauth::has_oauth_session(true) { if oauth::has_oauth_session(true) {
let (_oauth, session) = oauth::refresh_oauth_session(true).await?; match oauth::refresh_oauth_session(true).await {
return Ok(session); Ok((_oauth, session)) => return Ok(session),
Err(_) => { /* OAuth failed, fall back to legacy */ }
}
} }
let session = token::load_bot_session()?; let session = token::load_bot_session()?;

View File

@@ -636,7 +636,6 @@ fn save_oauth_session(session: &OAuthSession, is_bot: bool) -> Result<()> {
let path = config_dir.join(filename); let path = config_dir.join(filename);
let content = serde_json::to_string_pretty(session)?; let content = serde_json::to_string_pretty(session)?;
std::fs::write(&path, content)?; std::fs::write(&path, content)?;
println!("OAuth session saved to {:?}", path);
Ok(()) Ok(())
} }

View File

@@ -203,13 +203,15 @@ impl XrpcClient {
async fn dpop_request_with_retry_proxy<B: Serialize, T: DeserializeOwned>( async fn dpop_request_with_retry_proxy<B: Serialize, T: DeserializeOwned>(
&self, &self,
oauth: &OAuthSession, oauth: &OAuthSession,
token: &str, _token: &str,
method: &str, method: &str,
url: &str, url: &str,
full_url: &str, full_url: &str,
body: Option<&B>, body: Option<&B>,
proxy: Option<&str>, proxy: Option<&str>,
) -> Result<T> { ) -> Result<T> {
// Use OAuth access_token for Authorization (must match DPoP ath)
let auth_token = &oauth.access_token;
let mut dpop_nonce: Option<String> = None; let mut dpop_nonce: Option<String> = None;
for _attempt in 0..2 { for _attempt in 0..2 {
@@ -237,7 +239,7 @@ impl XrpcClient {
} }
let res = builder let res = builder
.header("Authorization", format!("DPoP {}", token)) .header("Authorization", format!("DPoP {}", auth_token))
.header("DPoP", dpop_proof) .header("DPoP", dpop_proof)
.send() .send()
.await .await
@@ -270,12 +272,13 @@ impl XrpcClient {
async fn dpop_no_response_with_retry<B: Serialize>( async fn dpop_no_response_with_retry<B: Serialize>(
&self, &self,
oauth: &OAuthSession, oauth: &OAuthSession,
token: &str, _token: &str,
method: &str, method: &str,
url: &str, url: &str,
full_url: &str, full_url: &str,
body: &B, body: &B,
) -> Result<()> { ) -> Result<()> {
let auth_token = &oauth.access_token;
let mut dpop_nonce: Option<String> = None; let mut dpop_nonce: Option<String> = None;
for _attempt in 0..2 { for _attempt in 0..2 {
@@ -290,7 +293,7 @@ impl XrpcClient {
.inner .inner
.post(url) .post(url)
.json(body) .json(body)
.header("Authorization", format!("DPoP {}", token)) .header("Authorization", format!("DPoP {}", auth_token))
.header("DPoP", dpop_proof) .header("DPoP", dpop_proof)
.send() .send()
.await .await