From 9ff3fc3efad25948edb1a374ee0e4c0c3404ebd8 Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Fri, 18 Aug 2023 11:41:06 +0200 Subject: [PATCH] Add content type specification --- src/api/auth/login.rs | 3 ++- src/api/auth/register.rs | 3 ++- src/api/channels/channels.rs | 4 +++- src/api/channels/messages.rs | 3 ++- src/api/channels/permissions.rs | 1 + src/api/channels/reactions.rs | 5 ++++- src/api/guilds/guilds.rs | 5 ++++- src/api/guilds/member.rs | 5 ++++- src/api/guilds/roles.rs | 3 +++ src/api/invites/mod.rs | 5 ++++- src/api/users/channels.rs | 1 + src/api/users/guilds.rs | 1 + src/api/users/relationships.rs | 1 + src/api/users/users.rs | 6 ++++-- 14 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/api/auth/login.rs b/src/api/auth/login.rs index 3b3ffc6..34a873b 100644 --- a/src/api/auth/login.rs +++ b/src/api/auth/login.rs @@ -22,7 +22,8 @@ impl Instance { let chorus_request = ChorusRequest { request: Client::new() .post(endpoint_url) - .body(to_string(login_schema).unwrap()), + .body(to_string(login_schema).unwrap()) + .header("Content-Type", "application/json"), limit_type: LimitType::AuthLogin, }; // We do not have a user yet, and the UserRateLimits will not be affected by a login diff --git a/src/api/auth/register.rs b/src/api/auth/register.rs index 7beaa76..b4350d2 100644 --- a/src/api/auth/register.rs +++ b/src/api/auth/register.rs @@ -27,7 +27,8 @@ impl Instance { let chorus_request = ChorusRequest { request: Client::new() .post(endpoint_url) - .body(to_string(register_schema).unwrap()), + .body(to_string(register_schema).unwrap()) + .header("Content-Type", "application/json"), limit_type: LimitType::AuthRegister, }; // We do not have a user yet, and the UserRateLimits will not be affected by a login diff --git a/src/api/channels/channels.rs b/src/api/channels/channels.rs index 276636f..14c295a 100644 --- a/src/api/channels/channels.rs +++ b/src/api/channels/channels.rs @@ -75,6 +75,7 @@ impl Channel { channel_id )) .header("Authorization", user.token()) + .header("Content-Type", "application/json") .body(to_string(&modify_data).unwrap()), limit_type: LimitType::Channel(channel_id), }; @@ -129,7 +130,8 @@ impl Channel { self.id, recipient_id )) - .header("Authorization", user.token()); + .header("Authorization", user.token()) + .header("Content-Type", "application/json"); if let Some(schema) = add_channel_recipient_schema { request = request.body(to_string(&schema).unwrap()); } diff --git a/src/api/channels/messages.rs b/src/api/channels/messages.rs index 25995f9..9487100 100644 --- a/src/api/channels/messages.rs +++ b/src/api/channels/messages.rs @@ -27,7 +27,8 @@ impl Message { request: Client::new() .post(format!("{}/channels/{}/messages", url_api, channel_id)) .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), }; chorus_request.deserialize_response::(user).await diff --git a/src/api/channels/permissions.rs b/src/api/channels/permissions.rs index b445876..8a6316f 100644 --- a/src/api/channels/permissions.rs +++ b/src/api/channels/permissions.rs @@ -43,6 +43,7 @@ impl types::Channel { request: Client::new() .put(url) .header("Authorization", user.token()) + .header("Content-Type", "application/json") .body(body), limit_type: LimitType::Channel(channel_id), }; diff --git a/src/api/channels/reactions.rs b/src/api/channels/reactions.rs index f9b7541..519da12 100644 --- a/src/api/channels/reactions.rs +++ b/src/api/channels/reactions.rs @@ -108,7 +108,10 @@ impl ReactionMeta { emoji ); 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), }; chorus_request.handle_request_as_result(user).await diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index 9031563..9c67831 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -24,6 +24,7 @@ impl Guild { request: Client::new() .post(url.clone()) .header("Authorization", user.token.clone()) + .header("Content-Type", "application/json") .body(to_string(&guild_create_schema).unwrap()), limit_type: LimitType::Global, }; @@ -58,7 +59,8 @@ impl Guild { let chorus_request = ChorusRequest { request: Client::new() .post(url.clone()) - .header("Authorization", user.token.clone()), + .header("Authorization", user.token.clone()) + .header("Content-Type", "application/json"), limit_type: LimitType::Global, }; chorus_request.handle_request_as_result(user).await @@ -157,6 +159,7 @@ impl Channel { guild_id )) .header("Authorization", user.token()) + .header("Content-Type", "application/json") .body(to_string(&schema).unwrap()), limit_type: LimitType::Guild(guild_id), }; diff --git a/src/api/guilds/member.rs b/src/api/guilds/member.rs index dcced7e..f9f02dc 100644 --- a/src/api/guilds/member.rs +++ b/src/api/guilds/member.rs @@ -53,7 +53,10 @@ impl types::GuildMember { role_id ); 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), }; chorus_request.handle_request_as_result(user).await diff --git a/src/api/guilds/roles.rs b/src/api/guilds/roles.rs index c0893a8..678450c 100644 --- a/src/api/guilds/roles.rs +++ b/src/api/guilds/roles.rs @@ -83,6 +83,7 @@ impl types::RoleObject { request: Client::new() .post(url) .header("Authorization", user.token()) + .header("Content-Type", "application/json") .body(body), limit_type: LimitType::Guild(guild_id), }; @@ -115,6 +116,7 @@ impl types::RoleObject { request: Client::new() .patch(url) .header("Authorization", user.token()) + .header("Content-Type", "application/json") .body(body), limit_type: LimitType::Guild(guild_id), }; @@ -150,6 +152,7 @@ impl types::RoleObject { request: Client::new() .patch(url) .header("Authorization", user.token()) + .header("Content-Type", "application/json") .body(body), limit_type: LimitType::Guild(guild_id), }; diff --git a/src/api/invites/mod.rs b/src/api/invites/mod.rs index c32d30a..8742c3f 100644 --- a/src/api/invites/mod.rs +++ b/src/api/invites/mod.rs @@ -31,6 +31,7 @@ impl UserMeta { if session_id.is_some() { request.request = request .request + .header("Content-Type", "application/json") .body(to_string(session_id.unwrap()).unwrap()); } request.deserialize_response::(self).await @@ -50,7 +51,8 @@ impl UserMeta { self.belongs_to.borrow().urls.api )) .body(to_string(&code).unwrap()) - .header("Authorization", self.token()), + .header("Authorization", self.token()) + .header("Content-Type", "application/json"), limit_type: super::LimitType::Global, } .deserialize_response::(self) @@ -77,6 +79,7 @@ impl UserMeta { channel_id )) .header("Authorization", self.token()) + .header("Content-Type", "application/json") .body(to_string(&create_channel_invite_schema).unwrap()), limit_type: super::LimitType::Channel(channel_id), } diff --git a/src/api/users/channels.rs b/src/api/users/channels.rs index 74f7484..5a33c6c 100644 --- a/src/api/users/channels.rs +++ b/src/api/users/channels.rs @@ -26,6 +26,7 @@ impl UserMeta { request: Client::new() .post(url) .header("Authorization", self.token()) + .header("Content-Type", "application/json") .body(to_string(&create_private_channel_schema).unwrap()), limit_type: LimitType::Global, } diff --git a/src/api/users/guilds.rs b/src/api/users/guilds.rs index f1e586d..355f38c 100644 --- a/src/api/users/guilds.rs +++ b/src/api/users/guilds.rs @@ -23,6 +23,7 @@ impl UserMeta { guild_id )) .header("Authorization", self.token()) + .header("Content-Type", "application/json") .body(to_string(&lurking).unwrap()), limit_type: crate::api::LimitType::Guild(*guild_id), } diff --git a/src/api/users/relationships.rs b/src/api/users/relationships.rs index 2cf0c6c..e08f414 100644 --- a/src/api/users/relationships.rs +++ b/src/api/users/relationships.rs @@ -69,6 +69,7 @@ impl UserMeta { request: Client::new() .post(url) .header("Authorization", self.token()) + .header("Content-Type", "application/json") .body(body), limit_type: LimitType::Global, }; diff --git a/src/api/users/users.rs b/src/api/users/users.rs index 1ba4e84..41af054 100644 --- a/src/api/users/users.rs +++ b/src/api/users/users.rs @@ -50,7 +50,8 @@ impl UserMeta { let request = Client::new() .patch(format!("{}/users/@me", self.belongs_to.borrow().urls.api)) .body(to_string(&modify_schema).unwrap()) - .header("Authorization", self.token()); + .header("Authorization", self.token()) + .header("Content-Type", "application/json"); let chorus_request = ChorusRequest { request, limit_type: LimitType::default(), @@ -68,7 +69,8 @@ impl UserMeta { "{}/users/@me/delete", self.belongs_to.borrow().urls.api )) - .header("Authorization", self.token()); + .header("Authorization", self.token()) + .header("Content-Type", "application/json"); let chorus_request = ChorusRequest { request, limit_type: LimitType::default(),