Refactor modify() to take less boilerplate args
This commit is contained in:
parent
808224d4fb
commit
a12573fe1c
|
@ -98,23 +98,25 @@ impl Channel {
|
|||
/// A `Result` that contains a `Channel` object if the request was successful, or an `InstanceServerError` if an error occurred during the request.
|
||||
pub async fn modify(
|
||||
modify_data: ChannelModifySchema,
|
||||
token: &str,
|
||||
url_api: &str,
|
||||
channel_id: &str,
|
||||
limits_user: &mut Limits,
|
||||
limits_instance: &mut Limits,
|
||||
user: &mut UserMeta,
|
||||
) -> Result<Channel, InstanceServerError> {
|
||||
let mut belongs_to = user.belongs_to.borrow_mut();
|
||||
let request = Client::new()
|
||||
.patch(format!("{}/channels/{}/", url_api, channel_id))
|
||||
.bearer_auth(token)
|
||||
.patch(format!(
|
||||
"{}/channels/{}/",
|
||||
belongs_to.urls.get_api(),
|
||||
channel_id
|
||||
))
|
||||
.bearer_auth(user.token())
|
||||
.body(to_string(&modify_data).unwrap());
|
||||
let channel = match LimitedRequester::new()
|
||||
.await
|
||||
.send_request(
|
||||
request,
|
||||
crate::api::limits::LimitType::Channel,
|
||||
limits_instance,
|
||||
limits_user,
|
||||
&mut belongs_to.limits,
|
||||
&mut user.limits,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
|
|
@ -48,11 +48,8 @@ async fn modify_channel() {
|
|||
};
|
||||
let result = Channel::modify(
|
||||
modify_data,
|
||||
&bundle.user.token,
|
||||
bundle.instance.urls.get_api(),
|
||||
&bundle.channel.id.to_string(),
|
||||
&mut bundle.user.limits,
|
||||
&mut bundle.instance.limits,
|
||||
&mut bundle.user,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
Loading…
Reference in New Issue