mirror of
https://github.com/FluxaMedia/fluxa-core.git
synced 2026-08-18 21:18:16 +00:00
Add Anilist auth provider to profile token merge
This commit is contained in:
parent
7ac59c9bc9
commit
b196e61f48
1 changed files with 21 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ enum AuthProvider {
|
|||
Trakt,
|
||||
Mal,
|
||||
Simkl,
|
||||
Anilist,
|
||||
Stremio,
|
||||
Unknown,
|
||||
}
|
||||
|
|
@ -36,6 +37,7 @@ impl From<&str> for AuthProvider {
|
|||
"trakt" => AuthProvider::Trakt,
|
||||
"mal" => AuthProvider::Mal,
|
||||
"simkl" => AuthProvider::Simkl,
|
||||
"anilist" => AuthProvider::Anilist,
|
||||
"stremio" | "account" => AuthProvider::Stremio,
|
||||
_ => AuthProvider::Unknown,
|
||||
}
|
||||
|
|
@ -159,6 +161,25 @@ pub(crate) fn token_merge_plan_json(request_json: &str) -> Option<String> {
|
|||
obj.insert("simklAccessToken".to_string(), t.clone());
|
||||
}
|
||||
}
|
||||
AuthProvider::Anilist => {
|
||||
let token = auth.get("accessToken").or_else(|| auth.get("access_token"));
|
||||
let refresh = auth
|
||||
.get("refreshToken")
|
||||
.or_else(|| auth.get("refresh_token"));
|
||||
let expires_at = auth
|
||||
.get("expiresAt")
|
||||
.or_else(|| auth.get("expires_at"))
|
||||
.or_else(|| auth.get("anilistTokenExpiresAt"));
|
||||
if let Some(t) = token {
|
||||
obj.insert("anilistAccessToken".to_string(), t.clone());
|
||||
}
|
||||
if let Some(r) = refresh {
|
||||
obj.insert("anilistRefreshToken".to_string(), r.clone());
|
||||
}
|
||||
if let Some(e) = expires_at {
|
||||
obj.insert("anilistTokenExpiresAt".to_string(), e.clone());
|
||||
}
|
||||
}
|
||||
AuthProvider::Stremio => {
|
||||
if let Some(auth_key) = auth.get("authKey").or_else(|| auth.get("apiKey")) {
|
||||
obj.insert("authKey".to_string(), auth_key.clone());
|
||||
|
|
|
|||
Loading…
Reference in a new issue