feat(people): add the devices/owner route
This commit is contained in:
parent
9f6fd3f17d
commit
9608823d06
1 changed files with 17 additions and 13 deletions
|
|
@ -261,6 +261,15 @@ struct GetOwnProfileData{
|
||||||
|
|
||||||
#[get("/v1/api/people/@me/profile")]
|
#[get("/v1/api/people/@me/profile")]
|
||||||
pub fn get_own_profile(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>>{
|
pub fn get_own_profile(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>>{
|
||||||
|
build_own_profile(user)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/v1/api/people/@me/devices/owner")]
|
||||||
|
pub fn get_device_owner(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>>{
|
||||||
|
build_own_profile(user)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_own_profile(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>> {
|
||||||
let User {
|
let User {
|
||||||
username,
|
username,
|
||||||
pid,
|
pid,
|
||||||
|
|
@ -283,10 +292,6 @@ pub fn get_own_profile(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>>{
|
||||||
|
|
||||||
let timezone_offset = (&*OFFSET_FROM_TIMEZONE).get(&timezone).unwrap().to_owned();
|
let timezone_offset = (&*OFFSET_FROM_TIMEZONE).get(&timezone).unwrap().to_owned();
|
||||||
|
|
||||||
// whenever we need an id or hash we just take the gxhash of the data cause i dont want data clutter
|
|
||||||
// this both avoids the data we have to store as well as data clutter whilest keeping the ids
|
|
||||||
// always the same
|
|
||||||
|
|
||||||
let mii_data = mii_data
|
let mii_data = mii_data
|
||||||
.replace("\n", "")
|
.replace("\n", "")
|
||||||
.replace("\t", "")
|
.replace("\t", "")
|
||||||
|
|
@ -319,13 +324,12 @@ pub fn get_own_profile(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>>{
|
||||||
},
|
},
|
||||||
mii: MiiDataOwnProfileData {
|
mii: MiiDataOwnProfileData {
|
||||||
id: gxhash32(mii_data.as_bytes(), 0),
|
id: gxhash32(mii_data.as_bytes(), 0),
|
||||||
// the bitmask here is to avoid causing an too big number as we dont know if the
|
|
||||||
// wii u uses a 64 bit int here
|
|
||||||
mii_hash: hex::encode(bytemuck::bytes_of(
|
mii_hash: hex::encode(bytemuck::bytes_of(
|
||||||
&(gxhash64(mii_data.as_bytes(), 1) & !(0x1000000000000000))
|
&(gxhash64(mii_data.as_bytes(), 1) & !(0x1000000000000000))
|
||||||
)),
|
)),
|
||||||
name: mii::MiiData::read(&mii_data)
|
name: mii::MiiData::read(&mii_data)
|
||||||
.map(|v| v.name).unwrap_or("INVALID".to_string()),
|
.map(|v| v.name)
|
||||||
|
.unwrap_or_else(|| "INVALID".to_string()),
|
||||||
primary: YesNoVal(true),
|
primary: YesNoVal(true),
|
||||||
data: mii_data,
|
data: mii_data,
|
||||||
status: "COMPLETED".to_string(),
|
status: "COMPLETED".to_string(),
|
||||||
|
|
@ -342,7 +346,6 @@ pub fn get_own_profile(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>>{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
off_device_flag: YesNoVal(off_device_allowed),
|
off_device_flag: YesNoVal(off_device_allowed),
|
||||||
region,
|
region,
|
||||||
utc_offset: timezone_offset,
|
utc_offset: timezone_offset,
|
||||||
|
|
@ -350,6 +353,7 @@ pub fn get_own_profile(user: Auth<false>) -> Ds<Xml<GetOwnProfileData>>{
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[put("/v1/api/people/@me/miis/@primary")]
|
#[put("/v1/api/people/@me/miis/@primary")]
|
||||||
pub fn change_mii() {
|
pub fn change_mii() {
|
||||||
// stubbed(tecnically requires auth but this doesnt do anything so theres no harm in not doing auth here rn)
|
// stubbed(tecnically requires auth but this doesnt do anything so theres no harm in not doing auth here rn)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue