Make ChorusUser `Clone`
This commit is contained in:
parent
2b203f1a42
commit
17fe4f004f
|
@ -84,7 +84,7 @@ impl fmt::Display for Token {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
/// A ChorusUser is a representation of an authenticated user on an [Instance].
|
||||
/// It is used for most authenticated actions on a Spacebar server.
|
||||
/// It also has its own [Gateway] connection.
|
||||
|
@ -94,7 +94,7 @@ pub struct ChorusUser {
|
|||
pub limits: Option<HashMap<LimitType, Limit>>,
|
||||
pub settings: Arc<RwLock<UserSettings>>,
|
||||
pub object: Arc<RwLock<User>>,
|
||||
pub gateway: GatewayHandle,
|
||||
pub gateway: Arc<GatewayHandle>, // TODO: Can this be an Arc<GatewayHandle>? That way we could have Clone implemented on ChorusUser
|
||||
}
|
||||
|
||||
impl ChorusUser {
|
||||
|
@ -117,7 +117,7 @@ impl ChorusUser {
|
|||
limits: Option<HashMap<LimitType, Limit>>,
|
||||
settings: Arc<RwLock<UserSettings>>,
|
||||
object: Arc<RwLock<User>>,
|
||||
gateway: GatewayHandle,
|
||||
gateway: Arc<GatewayHandle>,
|
||||
) -> ChorusUser {
|
||||
ChorusUser {
|
||||
belongs_to,
|
||||
|
@ -139,7 +139,7 @@ impl ChorusUser {
|
|||
let object = Arc::new(RwLock::new(User::default()));
|
||||
let wss_url = instance.read().unwrap().urls.wss.clone();
|
||||
// Dummy gateway object
|
||||
let gateway = Gateway::new(wss_url).await.unwrap();
|
||||
let gateway = Arc::new(Gateway::new(wss_url).await.unwrap());
|
||||
ChorusUser {
|
||||
token,
|
||||
belongs_to: instance.clone(),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct RegisterSchema {
|
||||
pub username: String,
|
||||
|
@ -15,7 +15,7 @@ pub struct RegisterSchema {
|
|||
pub promotional_email_opt_in: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct LoginSchema {
|
||||
/// For Discord, usernames must be between 2 and 32 characters,
|
||||
|
@ -30,7 +30,7 @@ pub struct LoginSchema {
|
|||
pub gift_code_sku_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct TotpSchema {
|
||||
code: String,
|
||||
|
|
|
@ -42,7 +42,7 @@ impl TestBundle {
|
|||
limits: self.user.limits.clone(),
|
||||
settings: self.user.settings.clone(),
|
||||
object: self.user.object.clone(),
|
||||
gateway: Gateway::new(self.instance.urls.wss.clone()).await.unwrap(),
|
||||
gateway: Arc::new(Gateway::new(self.instance.urls.wss.clone()).await.unwrap()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue