|
|
|
@ -6,7 +6,7 @@ mod tests;
|
|
|
|
|
use chrono::Utc;
|
|
|
|
|
use derive_more::From;
|
|
|
|
|
use reqwest::StatusCode;
|
|
|
|
|
use rocket::http::{Cookie, CookieJar};
|
|
|
|
|
use rocket::http::{CookieJar, Cookie};
|
|
|
|
|
use serial::*;
|
|
|
|
|
|
|
|
|
|
use serde::Deserialize;
|
|
|
|
@ -42,7 +42,7 @@ impl User {
|
|
|
|
|
(response.status(), response.text().await)
|
|
|
|
|
};
|
|
|
|
|
if !status.is_success() {
|
|
|
|
|
return Err(GetUserError::DiscordError {
|
|
|
|
|
return Err(GetUserError::Discord {
|
|
|
|
|
status,
|
|
|
|
|
message: text.ok(),
|
|
|
|
|
});
|
|
|
|
@ -102,10 +102,10 @@ impl User {
|
|
|
|
|
|
|
|
|
|
#[derive(From, Debug)]
|
|
|
|
|
pub enum GetUserError {
|
|
|
|
|
ReqwestError(reqwest::Error),
|
|
|
|
|
DeserializeError(serde_json::Error),
|
|
|
|
|
Reqwest(reqwest::Error),
|
|
|
|
|
Deserialize(serde_json::Error),
|
|
|
|
|
#[allow(unused)]
|
|
|
|
|
DiscordError {
|
|
|
|
|
Discord {
|
|
|
|
|
status: StatusCode,
|
|
|
|
|
message: Option<String>,
|
|
|
|
|
},
|
|
|
|
@ -113,4 +113,4 @@ pub enum GetUserError {
|
|
|
|
|
|
|
|
|
|
fn parse_cookie_value<T: std::str::FromStr>(cookies: &CookieJar<'_>, name: &str) -> Option<T> {
|
|
|
|
|
cookies.get_private(name)?.value().parse().ok()
|
|
|
|
|
}
|
|
|
|
|
}
|