Skip to content

Commit

Permalink
Make it build again
Browse files Browse the repository at this point in the history
  • Loading branch information
LJ authored and LJ committed Sep 24, 2024
1 parent 8116405 commit 13ac92a
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tokio = "1"
# Platform specifics
resonite = { version = "0.3.2", features = [], default-features = false }
#resonite = { path = "../resonite", features = [] }
chilloutvr = { version = "0.5.0", features = [] }
chilloutvr = { version = "0.6.0", features = [] }
#chilloutvr = { path = "../chilloutvr_rs", features = [] }
vrc = { version = "0.5.0", features = [] }
#vrc = { path = "../vrc_rs", features = [] }
2 changes: 1 addition & 1 deletion onlivfe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ maintenance = { status = "experimental" }
[lib]
name = "onlivfe"
path = "src/lib.rs"
crate_type = ["lib", "dylib"]
crate-type = ["lib", "dylib"]

[features]
default = ["rand_util"]
Expand Down
2 changes: 1 addition & 1 deletion onlivfe/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ pub enum LoginCredentials {
/// CVR variant
ChilloutVR(Box<chilloutvr::query::LoginCredentials>),
/// Resonite variant
Resonite(Box<resonite::query::Authenticating>),
Resonite(Box<resonite::api_client::UserSessionQueryWithHeaders>),
}
crate::platform_specific!(LoginCredentials);
2 changes: 1 addition & 1 deletion onlivfe_cache_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ maintenance = { status = "experimental" }
[lib]
name = "onlivfe_cache_store"
path = "src/lib.rs"
crate_type = ["lib", "dylib"]
crate-type = ["lib", "dylib"]

[dependencies]
directories = "5.0.1"
Expand Down
2 changes: 1 addition & 1 deletion onlivfe_db_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ maintenance = { status = "experimental" }
[lib]
name = "onlivfe_db_store"
path = "src/lib.rs"
crate_type = ["lib", "dylib"]
crate-type = ["lib", "dylib"]

[dependencies]
num_cpus = "1.16.0"
Expand Down
2 changes: 1 addition & 1 deletion onlivfe_net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ maintenance = { status = "experimental" }
[lib]
name = "onlivfe_net"
path = "src/lib.rs"
crate_type = ["lib", "dylib"]
crate-type = ["lib", "dylib"]

[dependencies]
onlivfe = { workspace = true }
Expand Down
13 changes: 6 additions & 7 deletions onlivfe_net/src/cvr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ impl OnlivfeApiClient {
api_config.mature_content_enabled = true;

let mut rw_lock_guard = self.cvr.write().await;
let api = possible_existing
.and_then(|id| rw_lock_guard.remove(&id))
.map_or_else(
|| UnauthenticatedCVR::new(api_config),
AuthenticatedCVR::downgrade,
)
let api =
match possible_existing.and_then(|id| rw_lock_guard.remove(&id)) {
Some(api) => api.downgrade().await,
None => UnauthenticatedCVR::new(api_config),
}
.map_err(|_| {
"Internal error, Resonite API client creation failed".to_string()
})?;
Expand All @@ -115,7 +114,7 @@ impl OnlivfeApiClient {
user_auth.user_id.clone(),
query::SavedLoginCredentials::from(user_auth),
);
let api = api.upgrade(creds.clone()).map_err(|_| {
let api: AuthenticatedCVR = api.upgrade(creds.clone()).map_err(|_| {
"Internal error, authenticated CVR API client's creation failed"
.to_owned()
})?;
Expand Down
2 changes: 1 addition & 1 deletion onlivfe_net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl OnlivfeApiClient {
),
PlatformAccountId::Resonite(id) => Ok(
self
.friends_resonite(id)
.contacts_resonite(id)
.await?
.into_iter()
.map(|friend| {
Expand Down
58 changes: 36 additions & 22 deletions onlivfe_net/src/resonite.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
use resonite::{
api_client::{ApiClient, AuthenticatedResonite, UnauthenticatedResonite},
api_client::{
ApiClient,
AuthenticatedResonite,
AuthenticatingResonite,
UnauthenticatedResonite,
UserSessionQueryWithHeaders,
},
id,
model::{Contact, SessionInfo, User},
query::{self, Authentication, LoginCredentialsIdentifier},
Expand All @@ -12,11 +18,12 @@ impl OnlivfeApiClient {
pub(crate) async fn logout_resonite(
&self, id: &id::User,
) -> Result<(), String> {
if let Some(client) = self.resonite.write().await.remove(id) {
client.query(query::DestroyUserSession).await.map_err(|e| {
error!("Logout as {:?} failed: {:?}", id, e);
"Logout request failed, removing account anyway".to_string()
})?;
if let Some(_client) = self.resonite.write().await.remove(id) {
// TODO: Logout request
//client.query(query::DestroyUserSession).await.map_err(|e| {
// error!("Logout as {:?} failed: {:?}", id, e);
// "Logout request failed, removing account anyway".to_string()
//})?;
return Ok(());
}
warn!("Tried to log out of non-existent account {:?}", id);
Expand Down Expand Up @@ -117,30 +124,30 @@ impl OnlivfeApiClient {
}

#[instrument]
pub(crate) async fn Contacts_resonite(
pub(crate) async fn contacts_resonite(
&self, id: &id::User,
) -> Result<Vec<Contact>, String> {
trace!("Fetching Contacts as {:?}", id);
let rw_lock_guard = self.resonite.read().await;
let api = rw_lock_guard
.get(id)
.ok_or_else(|| "Resonite API not authenticated".to_owned())?;
let query = query::Contacts::default();
let Contacts = api.query(query).await.map_err(|e| {
let query = query::Contacts;
let contacts = api.query(query).await.map_err(|e| {
warn!("Contacts query failed: {:?}", &e);
"Resonite Contacts query failed".to_owned()
})?;

Ok(Contacts)
Ok(contacts)
}

#[instrument]
pub(crate) async fn login_resonite(
&self, auth: query::LoginCredentials,
&self, auth: UserSessionQueryWithHeaders,
) -> Result<(id::User, query::Authentication), String> {
trace!("Trying to login as {:?}", auth.identifier);
trace!("Trying to login as {:?}", auth.body.identifier);
let mut rw_lock_guard = self.resonite.write().await;
let api = match &auth.identifier {
let api = match &auth.body.identifier {
LoginCredentialsIdentifier::OwnerID(owner_id_str) => {
id::User::try_from(owner_id_str.clone())
.map(|user_id| rw_lock_guard.remove(&user_id))
Expand All @@ -157,20 +164,27 @@ impl OnlivfeApiClient {
.map_err(|_| {
"Internal error, Resonite API client creation failed".to_string()
})?;
let api = AuthenticatingResonite::from((api, auth.data));

let user_session = api.query(auth).await.map_err(|e| {
let result = api.query(auth.body).await.map_err(|e| {
warn!("Login query failed: {:?}", &e);
"Resonite authentication failed".to_owned()
})?;
trace!("Auth request for {:?} was successful", &user_session.user_id);
trace!(
"Auth request for {:?} was successful",
&result.user_session.user_id
);

let auth = query::Authentication::from(&user_session);
let user_id = result.user_session.user_id.clone();
let auth = query::Authentication::from(result.user_session);

let api = api.upgrade(auth.clone()).map_err(|_| {
"Internal error, authenticated Resonite API client's creation failed"
.to_owned()
})?;
rw_lock_guard.insert(user_session.user_id.clone(), api);
Ok((user_session.user_id, auth))
let api = UnauthenticatedResonite::from(api)
.upgrade(auth.clone())
.map_err(|_| {
"Internal error, authenticated Resonite API client's creation failed"
.to_owned()
})?;
rw_lock_guard.insert(user_id.clone(), api);
Ok((user_id, auth))
}
}
2 changes: 1 addition & 1 deletion onlivfe_wrapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ maintenance = { status = "experimental" }
[lib]
name = "onlivfe_wrapper"
path = "src/lib.rs"
crate_type = ["lib", "dylib"]
crate-type = ["lib", "dylib"]

[dependencies]
human-panic = "2.0.1"
Expand Down
14 changes: 8 additions & 6 deletions onlivfe_wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern crate tracing;

use std::sync::Arc;

use human_panic::Metadata;
use onlivfe::{
Authentication,
Instance,
Expand Down Expand Up @@ -63,12 +64,13 @@ pub fn init(
trace!("Initialized tracing");
}

human_panic::setup_panic!(Metadata {
name: name.into(),
version: version.into(),
authors: "Onlivfe contributors".into(),
homepage: "onlivfe.com".into(),
});
let name = name.into();
let version = version.into();
human_panic::setup_panic!(
Metadata::new(name.clone(), version.clone())
.authors("Onlivfe contributors")
.homepage("onlivfe.com")
);

Ok(())
}
Expand Down

0 comments on commit 13ac92a

Please sign in to comment.