Refactor create
This commit is contained in:
parent
03e5a83d84
commit
671c5d6191
|
@ -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.
|
||||
pub async fn create_channel(
|
||||
&self,
|
||||
url_api: &str,
|
||||
token: &str,
|
||||
user: &mut UserMeta,
|
||||
schema: ChannelCreateSchema,
|
||||
limits_user: &mut Limits,
|
||||
limits_instance: &mut Limits,
|
||||
) -> Result<Channel, InstanceServerError> {
|
||||
Channel::create(
|
||||
token,
|
||||
url_api,
|
||||
let mut belongs_to = user.belongs_to.borrow_mut();
|
||||
Channel::_create(
|
||||
&user.token,
|
||||
&format!("{}", belongs_to.urls.get_api()),
|
||||
&self.id.to_string(),
|
||||
schema,
|
||||
limits_user,
|
||||
limits_instance,
|
||||
&mut user.limits,
|
||||
&mut belongs_to.limits,
|
||||
)
|
||||
.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.
|
||||
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,
|
||||
url_api: &str,
|
||||
guild_id: &str,
|
||||
|
|
|
@ -66,16 +66,9 @@ pub async fn setup() -> TestBundle {
|
|||
};
|
||||
let mut user = instance.register_account(®).await.unwrap();
|
||||
let guild = Guild::create(&mut user, guild_create_schema).await.unwrap();
|
||||
let channel = Channel::create(
|
||||
&user.token,
|
||||
urls.get_api(),
|
||||
&guild.id.to_string(),
|
||||
channel_create_schema,
|
||||
&mut user.limits,
|
||||
&mut instance.limits,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let channel = Channel::create(&mut user, &guild.id.to_string(), channel_create_schema)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
TestBundle {
|
||||
urls,
|
||||
|
|
Loading…
Reference in New Issue