add support for the new friends api
All checks were successful
Build and Test / puyopuyo (push) Successful in 3m55s
Build and Test / wii-sports-club (push) Successful in 4m23s
Build and Test / terraria (push) Successful in 4m48s
Build and Test / splatoon-testfire (push) Successful in 5m3s
Build and Test / splatoon (push) Successful in 5m34s
Build and Test / fast-racing-neo (push) Successful in 6m19s
Build and Test / friends (push) Successful in 6m22s
Build and Test / wii-u-chat (push) Successful in 6m40s
Build and Test / mario-tennis (push) Successful in 6m40s
Build and Test / minecraft-wiiu (push) Successful in 7m17s
Build and Test / sonic-transformed (push) Successful in 6m3s
Build and Test / super-mario-maker (push) Successful in 4m9s
All checks were successful
Build and Test / puyopuyo (push) Successful in 3m55s
Build and Test / wii-sports-club (push) Successful in 4m23s
Build and Test / terraria (push) Successful in 4m48s
Build and Test / splatoon-testfire (push) Successful in 5m3s
Build and Test / splatoon (push) Successful in 5m34s
Build and Test / fast-racing-neo (push) Successful in 6m19s
Build and Test / friends (push) Successful in 6m22s
Build and Test / wii-u-chat (push) Successful in 6m40s
Build and Test / mario-tennis (push) Successful in 6m40s
Build and Test / minecraft-wiiu (push) Successful in 7m17s
Build and Test / sonic-transformed (push) Successful in 6m3s
Build and Test / super-mario-maker (push) Successful in 4m9s
This commit is contained in:
parent
dce1c0720e
commit
eff58c1f49
5 changed files with 47 additions and 10 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"rust-analyzer.cargo.features": [
|
||||
"v3-8-15", "splatoon", "prudpv1"
|
||||
"friends"
|
||||
]
|
||||
}
|
||||
14
Cargo.lock
generated
14
Cargo.lock
generated
|
|
@ -2514,10 +2514,12 @@ dependencies = [
|
|||
"rnex-rmc",
|
||||
"rnex-server",
|
||||
"rnex-util",
|
||||
"serde_json",
|
||||
"sqlx",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"ureq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3848,11 +3850,11 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
|||
|
||||
[[package]]
|
||||
name = "ureq"
|
||||
version = "3.3.0"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dea7109cdcd5864d4eeb1b58a1648dc9bf520360d7af16ec26d0a9354bafcfc0"
|
||||
checksum = "972d7902c8735f2695410b8aed7df6ed12a47394aa1c8d7af49f0497b731a94d"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"base64 0.23.1",
|
||||
"cookie_store",
|
||||
"der",
|
||||
"flate2",
|
||||
|
|
@ -3871,11 +3873,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ureq-proto"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e994ba84b0bd1b1b0cf92878b7ef898a5c1760108fe7b6010327e274917a808c"
|
||||
checksum = "da5f78b09e6941e1a0f2e30e695e4b120377b54d5e0aec11b594bb57b3971613"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"base64 0.23.1",
|
||||
"http 1.4.0",
|
||||
"httparse",
|
||||
"log",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ md-5 = "0.11.0"
|
|||
nex-account = { version = "0.2.4", registry = "spbr" }
|
||||
hex = "0.4.3"
|
||||
thiserror = "2.0.18"
|
||||
ureq = { version = "3.4.0", features = ["json"] }
|
||||
serde_json = "1.0.151"
|
||||
|
||||
[features]
|
||||
rmc_struct_header = []
|
||||
|
|
|
|||
|
|
@ -1280,11 +1280,17 @@ impl FriendsWiiU for FriendsUser {
|
|||
}
|
||||
|
||||
async fn update_presence(&self, mut presence: NintendoPresenceV2) -> Result<(), ErrorCode> {
|
||||
if !query!("select principal_preference_show_currently_playing_title from nintendo_network_accounts where pid = $1", self.pid).fetch_one(&self.fm.db).await.map_err(|_| ErrorCode::FPD_InvalidAccount)?.principal_preference_show_currently_playing_title{
|
||||
if !query!("select principal_preference_show_currently_playing_title from nintendo_network_accounts where pid = $1", self.pid)
|
||||
.fetch_one(&self.fm.db)
|
||||
.await
|
||||
.map_err(|_| ErrorCode::FPD_InvalidAccount)?
|
||||
.principal_preference_show_currently_playing_title
|
||||
{
|
||||
presence.game_server_id = 0;
|
||||
presence.game_key = friends_wiiu::GameKey::default();
|
||||
presence.app_data = vec![];
|
||||
}
|
||||
|
||||
if !query!(
|
||||
"select principal_preference_show_online from nintendo_network_accounts where pid = $1",
|
||||
self.pid
|
||||
|
|
@ -1295,15 +1301,40 @@ impl FriendsWiiU for FriendsUser {
|
|||
.principal_preference_show_online
|
||||
{
|
||||
presence.is_online = false;
|
||||
} else {
|
||||
presence.is_online = true;
|
||||
}
|
||||
|
||||
presence.is_online = true;
|
||||
println!("the presence that was sent is: {:?} from pid {:?}", presence, self.pid);
|
||||
let data = Any::new(&presence).expect("type error");
|
||||
let mut user_presence = self.presence.write().await;
|
||||
*user_presence = Some(presence);
|
||||
*user_presence = Some(presence.clone());
|
||||
drop(user_presence);
|
||||
|
||||
let pid_val = self.pid;
|
||||
let presence_payload = serde_json::json!({
|
||||
"pid": self.pid,
|
||||
"is_online": presence.is_online,
|
||||
"game_server_id": presence.game_server_id,
|
||||
"game_key": {
|
||||
"tid": presence.game_key.tid,
|
||||
"version": presence.game_key.version,
|
||||
},
|
||||
"app_data": presence.app_data,
|
||||
"message": presence.message,
|
||||
"changed_flags": presence.changed_flags
|
||||
});
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let presence_server_url = std::env::var("RNEX_PRESENCE_API_URL").unwrap_or_else(|_| "http://localhost:3000".to_string());
|
||||
let presence_server_secret = std::env::var("RNEX_PRESENCE_API_SECRET").unwrap_or_else(|_| "no-secret-defined".to_string());
|
||||
let _ = ureq::post(presence_server_url)
|
||||
.header("Authorization", &format!("Bearer {}", presence_server_secret))
|
||||
.send_json(serde_json::json!({
|
||||
"pid": pid_val,
|
||||
"presence": presence_payload
|
||||
}));
|
||||
});
|
||||
|
||||
let friends = self.maybe_remote_friend.read().await;
|
||||
for friend in friends.iter().filter_map(|f| f.1.upgrade()) {
|
||||
friend
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#[allow(unused)]
|
||||
#[allow(unused_imports)]
|
||||
use rnex_rmc::response::ErrorCode;
|
||||
use rnex_server::{ConnectionInitData, EnvVarError, RnexManager, RnexModule, env_var};
|
||||
use std::str::FromStr;
|
||||
|
|
|
|||
Loading…
Reference in a new issue