Refactor create
This commit is contained in:
parent
d8d3bf5be6
commit
3cebafecf6
|
@ -122,19 +122,17 @@ impl Guild {
|
||||||
/// A `Result` containing a `reqwest::Response` if the request was successful, or an `InstanceServerError` if there was an error.
|
/// A `Result` containing a `reqwest::Response` if the request was successful, or an `InstanceServerError` if there was an error.
|
||||||
pub async fn create_channel(
|
pub async fn create_channel(
|
||||||
&self,
|
&self,
|
||||||
url_api: &str,
|
user: &mut UserMeta,
|
||||||
token: &str,
|
|
||||||
schema: ChannelCreateSchema,
|
schema: ChannelCreateSchema,
|
||||||
limits_user: &mut Limits,
|
|
||||||
limits_instance: &mut Limits,
|
|
||||||
) -> Result<Channel, InstanceServerError> {
|
) -> Result<Channel, InstanceServerError> {
|
||||||
Channel::create(
|
let mut belongs_to = user.belongs_to.borrow_mut();
|
||||||
token,
|
Channel::_create(
|
||||||
url_api,
|
&user.token,
|
||||||
|
&format!("{}", belongs_to.urls.get_api()),
|
||||||
&self.id.to_string(),
|
&self.id.to_string(),
|
||||||
schema,
|
schema,
|
||||||
limits_user,
|
&mut user.limits,
|
||||||
limits_instance,
|
&mut belongs_to.limits,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -261,6 +259,23 @@ impl Channel {
|
||||||
///
|
///
|
||||||
/// A `Result` containing a `reqwest::Response` if the request was successful, or an `InstanceServerError` if there was an error.
|
/// A `Result` containing a `reqwest::Response` if the request was successful, or an `InstanceServerError` if there was an error.
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
|
user: &mut UserMeta,
|
||||||
|
guild_id: &str,
|
||||||
|
schema: ChannelCreateSchema,
|
||||||
|
) -> Result<Channel, InstanceServerError> {
|
||||||
|
let mut belongs_to = user.belongs_to.borrow_mut();
|
||||||
|
Channel::_create(
|
||||||
|
&user.token,
|
||||||
|
&format!("{}", belongs_to.urls.get_api()),
|
||||||
|
guild_id,
|
||||||
|
schema,
|
||||||
|
&mut user.limits,
|
||||||
|
&mut belongs_to.limits,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn _create(
|
||||||
token: &str,
|
token: &str,
|
||||||
url_api: &str,
|
url_api: &str,
|
||||||
guild_id: &str,
|
guild_id: &str,
|
||||||
|
|
|
@ -66,16 +66,9 @@ pub async fn setup() -> TestBundle {
|
||||||
};
|
};
|
||||||
let mut user = instance.register_account(®).await.unwrap();
|
let mut user = instance.register_account(®).await.unwrap();
|
||||||
let guild = Guild::create(&mut user, guild_create_schema).await.unwrap();
|
let guild = Guild::create(&mut user, guild_create_schema).await.unwrap();
|
||||||
let channel = Channel::create(
|
let channel = Channel::create(&mut user, &guild.id.to_string(), channel_create_schema)
|
||||||
&user.token,
|
.await
|
||||||
urls.get_api(),
|
.unwrap();
|
||||||
&guild.id.to_string(),
|
|
||||||
channel_create_schema,
|
|
||||||
&mut user.limits,
|
|
||||||
&mut instance.limits,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
TestBundle {
|
TestBundle {
|
||||||
urls,
|
urls,
|
||||||
|
|
Loading…
Reference in New Issue