Compare commits
1 Commits
9791b13921
...
413d26f015
Author | SHA1 | Date |
---|---|---|
kozabrada123 | 413d26f015 |
|
@ -12,10 +12,7 @@ use crate::{
|
||||||
instance::{ChorusUser, Instance},
|
instance::{ChorusUser, Instance},
|
||||||
ratelimiter::ChorusRequest,
|
ratelimiter::ChorusRequest,
|
||||||
types::{
|
types::{
|
||||||
DeleteDisableUserSchema, GetPomeloEligibilityReturn, GetPomeloSuggestionsReturn,
|
DeleteDisableUserSchema, GetPomeloEligibilityReturn, GetPomeloSuggestionsReturn, GetUserProfileSchema, LimitType, PublicUser, Snowflake, User, UserModifyProfileSchema, UserModifySchema, UserProfile, UserProfileMetadata, UserSettings, VerifyUserEmailChangeResponse, VerifyUserEmailChangeSchema
|
||||||
GetUserProfileSchema, LimitType, PublicUser, Snowflake, User, UserModifyProfileSchema,
|
|
||||||
UserModifySchema, UserProfile, UserProfileMetadata, UserSettings,
|
|
||||||
VerifyUserEmailChangeResponse, VerifyUserEmailChangeSchema,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -228,9 +225,6 @@ impl ChorusUser {
|
||||||
/// This endpoint returns a token which can be used with [Self::modify]
|
/// This endpoint returns a token which can be used with [Self::modify]
|
||||||
/// to set a new email address (email_token).
|
/// to set a new email address (email_token).
|
||||||
///
|
///
|
||||||
/// As of 2024/08/08, Spacebar does not yet implement this endpoint.
|
|
||||||
// FIXME: Does this mean PUT users/@me/email is different?
|
|
||||||
///
|
|
||||||
/// # Reference
|
/// # Reference
|
||||||
/// See <https://docs.discord.sex/resources/user#modify-user-email>
|
/// See <https://docs.discord.sex/resources/user#modify-user-email>
|
||||||
pub async fn verify_email_change(
|
pub async fn verify_email_change(
|
||||||
|
@ -264,8 +258,6 @@ impl ChorusUser {
|
||||||
/// If a user has already migrated, this endpoint will likely return a 401 Unauthorized
|
/// If a user has already migrated, this endpoint will likely return a 401 Unauthorized
|
||||||
/// ([ChorusError::NoPermission])
|
/// ([ChorusError::NoPermission])
|
||||||
///
|
///
|
||||||
/// As of 2024/08/08, Spacebar does not yet implement this endpoint.
|
|
||||||
///
|
|
||||||
/// See <https://docs.discord.sex/resources/user#get-pomelo-suggestions>
|
/// See <https://docs.discord.sex/resources/user#get-pomelo-suggestions>
|
||||||
pub async fn get_pomelo_suggestions(&mut self) -> ChorusResult<String> {
|
pub async fn get_pomelo_suggestions(&mut self) -> ChorusResult<String> {
|
||||||
let request = Client::new()
|
let request = Client::new()
|
||||||
|
@ -289,8 +281,6 @@ impl ChorusUser {
|
||||||
///
|
///
|
||||||
/// Returns whether the username is not taken yet.
|
/// Returns whether the username is not taken yet.
|
||||||
///
|
///
|
||||||
/// As of 2024/08/08, Spacebar does not yet implement this endpoint.
|
|
||||||
///
|
|
||||||
/// See <https://docs.discord.sex/resources/user#get-pomelo-eligibility>
|
/// See <https://docs.discord.sex/resources/user#get-pomelo-eligibility>
|
||||||
pub async fn get_pomelo_eligibility(&mut self, username: &String) -> ChorusResult<bool> {
|
pub async fn get_pomelo_eligibility(&mut self, username: &String) -> ChorusResult<bool> {
|
||||||
let request = Client::new()
|
let request = Client::new()
|
||||||
|
@ -312,52 +302,6 @@ impl ChorusUser {
|
||||||
.await
|
.await
|
||||||
.map(|returned| !returned.taken)
|
.map(|returned| !returned.taken)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Migrates the user from the username#discriminator to the unique username system.
|
|
||||||
///
|
|
||||||
/// Fires a [UserUpdate](crate::types::UserUpdate) gateway event.
|
|
||||||
///
|
|
||||||
/// Updates [Self::object] to an updated representation returned by the server.
|
|
||||||
// FIXME: Is this appropriate behaviour?
|
|
||||||
///
|
|
||||||
/// Note:
|
|
||||||
///
|
|
||||||
/// "This endpoint is used during the pomelo migration flow.
|
|
||||||
///
|
|
||||||
/// The user must be in the rollout to use this endpoint."
|
|
||||||
///
|
|
||||||
/// If a user has already migrated, this endpoint will likely return a 401 Unauthorized
|
|
||||||
/// ([ChorusError::NoPermission])
|
|
||||||
//
|
|
||||||
/// As of 2024/08/08, Spacebar does not yet implement this endpoint.
|
|
||||||
///
|
|
||||||
/// See <https://docs.discord.sex/resources/user#create-pomelo-migration>
|
|
||||||
pub async fn create_pomelo_migration(&mut self, username: &String) -> ChorusResult<()> {
|
|
||||||
let request = Client::new()
|
|
||||||
.post(format!(
|
|
||||||
"{}/users/@me/pomelo",
|
|
||||||
self.belongs_to.read().unwrap().urls.api
|
|
||||||
))
|
|
||||||
.header("Authorization", self.token())
|
|
||||||
// FIXME: should we create a type for this?
|
|
||||||
.body(format!(r#"{{ "username": {:?} }}"#, username))
|
|
||||||
.header("Content-Type", "application/json");
|
|
||||||
|
|
||||||
let chorus_request = ChorusRequest {
|
|
||||||
request,
|
|
||||||
limit_type: LimitType::default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = chorus_request.deserialize_response::<User>(self).await;
|
|
||||||
|
|
||||||
// FIXME: Does UserUpdate do this automatically? or would a user need to manually observe ChorusUser::object
|
|
||||||
if let Ok(new_object) = result {
|
|
||||||
*self.object.write().unwrap() = new_object;
|
|
||||||
return ChorusResult::Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
ChorusResult::Err(result.err().unwrap())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl User {
|
impl User {
|
||||||
|
|
Loading…
Reference in New Issue