Add content type specification

This commit is contained in:
kozabrada123 2023-08-18 11:41:06 +02:00
parent d211b13166
commit 9ff3fc3efa
14 changed files with 36 additions and 10 deletions

View File

@ -22,7 +22,8 @@ impl Instance {
let chorus_request = ChorusRequest { let chorus_request = ChorusRequest {
request: Client::new() request: Client::new()
.post(endpoint_url) .post(endpoint_url)
.body(to_string(login_schema).unwrap()), .body(to_string(login_schema).unwrap())
.header("Content-Type", "application/json"),
limit_type: LimitType::AuthLogin, limit_type: LimitType::AuthLogin,
}; };
// We do not have a user yet, and the UserRateLimits will not be affected by a login // We do not have a user yet, and the UserRateLimits will not be affected by a login

View File

@ -27,7 +27,8 @@ impl Instance {
let chorus_request = ChorusRequest { let chorus_request = ChorusRequest {
request: Client::new() request: Client::new()
.post(endpoint_url) .post(endpoint_url)
.body(to_string(register_schema).unwrap()), .body(to_string(register_schema).unwrap())
.header("Content-Type", "application/json"),
limit_type: LimitType::AuthRegister, limit_type: LimitType::AuthRegister,
}; };
// We do not have a user yet, and the UserRateLimits will not be affected by a login // We do not have a user yet, and the UserRateLimits will not be affected by a login

View File

@ -75,6 +75,7 @@ impl Channel {
channel_id channel_id
)) ))
.header("Authorization", user.token()) .header("Authorization", user.token())
.header("Content-Type", "application/json")
.body(to_string(&modify_data).unwrap()), .body(to_string(&modify_data).unwrap()),
limit_type: LimitType::Channel(channel_id), limit_type: LimitType::Channel(channel_id),
}; };
@ -129,7 +130,8 @@ impl Channel {
self.id, self.id,
recipient_id recipient_id
)) ))
.header("Authorization", user.token()); .header("Authorization", user.token())
.header("Content-Type", "application/json");
if let Some(schema) = add_channel_recipient_schema { if let Some(schema) = add_channel_recipient_schema {
request = request.body(to_string(&schema).unwrap()); request = request.body(to_string(&schema).unwrap());
} }

View File

@ -27,7 +27,8 @@ impl Message {
request: Client::new() request: Client::new()
.post(format!("{}/channels/{}/messages", url_api, channel_id)) .post(format!("{}/channels/{}/messages", url_api, channel_id))
.header("Authorization", user.token()) .header("Authorization", user.token())
.body(to_string(&message).unwrap()), .body(to_string(&message).unwrap())
.header("Content-Type", "application/json"),
limit_type: LimitType::Channel(channel_id), limit_type: LimitType::Channel(channel_id),
}; };
chorus_request.deserialize_response::<Message>(user).await chorus_request.deserialize_response::<Message>(user).await

View File

@ -43,6 +43,7 @@ impl types::Channel {
request: Client::new() request: Client::new()
.put(url) .put(url)
.header("Authorization", user.token()) .header("Authorization", user.token())
.header("Content-Type", "application/json")
.body(body), .body(body),
limit_type: LimitType::Channel(channel_id), limit_type: LimitType::Channel(channel_id),
}; };

View File

@ -108,7 +108,10 @@ impl ReactionMeta {
emoji emoji
); );
let chorus_request = ChorusRequest { let chorus_request = ChorusRequest {
request: Client::new().put(url).header("Authorization", user.token()), request: Client::new()
.put(url)
.header("Authorization", user.token())
.header("Content-Type", "application/json"),
limit_type: LimitType::Channel(self.channel_id), limit_type: LimitType::Channel(self.channel_id),
}; };
chorus_request.handle_request_as_result(user).await chorus_request.handle_request_as_result(user).await

View File

@ -24,6 +24,7 @@ impl Guild {
request: Client::new() request: Client::new()
.post(url.clone()) .post(url.clone())
.header("Authorization", user.token.clone()) .header("Authorization", user.token.clone())
.header("Content-Type", "application/json")
.body(to_string(&guild_create_schema).unwrap()), .body(to_string(&guild_create_schema).unwrap()),
limit_type: LimitType::Global, limit_type: LimitType::Global,
}; };
@ -58,7 +59,8 @@ impl Guild {
let chorus_request = ChorusRequest { let chorus_request = ChorusRequest {
request: Client::new() request: Client::new()
.post(url.clone()) .post(url.clone())
.header("Authorization", user.token.clone()), .header("Authorization", user.token.clone())
.header("Content-Type", "application/json"),
limit_type: LimitType::Global, limit_type: LimitType::Global,
}; };
chorus_request.handle_request_as_result(user).await chorus_request.handle_request_as_result(user).await
@ -157,6 +159,7 @@ impl Channel {
guild_id guild_id
)) ))
.header("Authorization", user.token()) .header("Authorization", user.token())
.header("Content-Type", "application/json")
.body(to_string(&schema).unwrap()), .body(to_string(&schema).unwrap()),
limit_type: LimitType::Guild(guild_id), limit_type: LimitType::Guild(guild_id),
}; };

View File

@ -53,7 +53,10 @@ impl types::GuildMember {
role_id role_id
); );
let chorus_request = ChorusRequest { let chorus_request = ChorusRequest {
request: Client::new().put(url).header("Authorization", user.token()), request: Client::new()
.put(url)
.header("Authorization", user.token())
.header("Content-Type", "application/json"),
limit_type: LimitType::Guild(guild_id), limit_type: LimitType::Guild(guild_id),
}; };
chorus_request.handle_request_as_result(user).await chorus_request.handle_request_as_result(user).await

View File

@ -83,6 +83,7 @@ impl types::RoleObject {
request: Client::new() request: Client::new()
.post(url) .post(url)
.header("Authorization", user.token()) .header("Authorization", user.token())
.header("Content-Type", "application/json")
.body(body), .body(body),
limit_type: LimitType::Guild(guild_id), limit_type: LimitType::Guild(guild_id),
}; };
@ -115,6 +116,7 @@ impl types::RoleObject {
request: Client::new() request: Client::new()
.patch(url) .patch(url)
.header("Authorization", user.token()) .header("Authorization", user.token())
.header("Content-Type", "application/json")
.body(body), .body(body),
limit_type: LimitType::Guild(guild_id), limit_type: LimitType::Guild(guild_id),
}; };
@ -150,6 +152,7 @@ impl types::RoleObject {
request: Client::new() request: Client::new()
.patch(url) .patch(url)
.header("Authorization", user.token()) .header("Authorization", user.token())
.header("Content-Type", "application/json")
.body(body), .body(body),
limit_type: LimitType::Guild(guild_id), limit_type: LimitType::Guild(guild_id),
}; };

View File

@ -31,6 +31,7 @@ impl UserMeta {
if session_id.is_some() { if session_id.is_some() {
request.request = request request.request = request
.request .request
.header("Content-Type", "application/json")
.body(to_string(session_id.unwrap()).unwrap()); .body(to_string(session_id.unwrap()).unwrap());
} }
request.deserialize_response::<Invite>(self).await request.deserialize_response::<Invite>(self).await
@ -50,7 +51,8 @@ impl UserMeta {
self.belongs_to.borrow().urls.api self.belongs_to.borrow().urls.api
)) ))
.body(to_string(&code).unwrap()) .body(to_string(&code).unwrap())
.header("Authorization", self.token()), .header("Authorization", self.token())
.header("Content-Type", "application/json"),
limit_type: super::LimitType::Global, limit_type: super::LimitType::Global,
} }
.deserialize_response::<Invite>(self) .deserialize_response::<Invite>(self)
@ -77,6 +79,7 @@ impl UserMeta {
channel_id channel_id
)) ))
.header("Authorization", self.token()) .header("Authorization", self.token())
.header("Content-Type", "application/json")
.body(to_string(&create_channel_invite_schema).unwrap()), .body(to_string(&create_channel_invite_schema).unwrap()),
limit_type: super::LimitType::Channel(channel_id), limit_type: super::LimitType::Channel(channel_id),
} }

View File

@ -26,6 +26,7 @@ impl UserMeta {
request: Client::new() request: Client::new()
.post(url) .post(url)
.header("Authorization", self.token()) .header("Authorization", self.token())
.header("Content-Type", "application/json")
.body(to_string(&create_private_channel_schema).unwrap()), .body(to_string(&create_private_channel_schema).unwrap()),
limit_type: LimitType::Global, limit_type: LimitType::Global,
} }

View File

@ -23,6 +23,7 @@ impl UserMeta {
guild_id guild_id
)) ))
.header("Authorization", self.token()) .header("Authorization", self.token())
.header("Content-Type", "application/json")
.body(to_string(&lurking).unwrap()), .body(to_string(&lurking).unwrap()),
limit_type: crate::api::LimitType::Guild(*guild_id), limit_type: crate::api::LimitType::Guild(*guild_id),
} }

View File

@ -69,6 +69,7 @@ impl UserMeta {
request: Client::new() request: Client::new()
.post(url) .post(url)
.header("Authorization", self.token()) .header("Authorization", self.token())
.header("Content-Type", "application/json")
.body(body), .body(body),
limit_type: LimitType::Global, limit_type: LimitType::Global,
}; };

View File

@ -50,7 +50,8 @@ impl UserMeta {
let request = Client::new() let request = Client::new()
.patch(format!("{}/users/@me", self.belongs_to.borrow().urls.api)) .patch(format!("{}/users/@me", self.belongs_to.borrow().urls.api))
.body(to_string(&modify_schema).unwrap()) .body(to_string(&modify_schema).unwrap())
.header("Authorization", self.token()); .header("Authorization", self.token())
.header("Content-Type", "application/json");
let chorus_request = ChorusRequest { let chorus_request = ChorusRequest {
request, request,
limit_type: LimitType::default(), limit_type: LimitType::default(),
@ -68,7 +69,8 @@ impl UserMeta {
"{}/users/@me/delete", "{}/users/@me/delete",
self.belongs_to.borrow().urls.api self.belongs_to.borrow().urls.api
)) ))
.header("Authorization", self.token()); .header("Authorization", self.token())
.header("Content-Type", "application/json");
let chorus_request = ChorusRequest { let chorus_request = ChorusRequest {
request, request,
limit_type: LimitType::default(), limit_type: LimitType::default(),