(&self)
| 177 | } |
| 178 | |
| 179 | async fn get_api_client(&self) -> RwLockReadGuard<'_, Option<ApiClient>> { |
| 180 | if let Some(expired) = self |
| 181 | .api_client |
| 182 | .read() |
| 183 | .await |
| 184 | .as_ref() |
| 185 | .map(|api_client| api_client.token_expiry <= Instant::now()) |
| 186 | { |
| 187 | if expired { |
| 188 | tracing::info!( |
| 189 | "youtube token expired. refreshing {:?}", |
| 190 | self.api_client |
| 191 | .read() |
| 192 | .await |
| 193 | .as_ref() |
| 194 | .map(|api_client| api_client.token_expiry) |
| 195 | ); |
| 196 | |
| 197 | let _ = self.refresh_login().await; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | self.api_client.read().await |
| 202 | } |
| 203 | |
| 204 | #[tracing::instrument(level = "debug", skip(self))] |
| 205 | async fn refresh_login(&self) -> Result<()> { |
no test coverage detected