From e0518db6a9db3e26adcf3eb11647da2258d1a82d Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 10:09:55 -0400 Subject: [PATCH 01/23] Add features to Cargo.toml --- Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 19c5fdc..a7029fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,10 @@ version = "0.1.0" license = "AGPL-3" edition = "2021" +[features] +backend = ["poem", "sqlx"] +client = [] + [dependencies] tokio = {version = "1.28.1", features = ["rt", "macros", "rt-multi-thread", "full"]} serde = {version = "1.0.162", features = ["derive"]} From 38503aea57894b8701a39fae75e0f619ea82a725 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 10:16:08 -0400 Subject: [PATCH 02/23] Lock client specific code behind feature --- src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index aa73302..4fa8f57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,15 @@ +#[cfg(feature = "client")] pub mod api; +#[cfg(feature = "client")] pub mod errors; +#[cfg(feature = "client")] pub mod gateway; +#[cfg(feature = "client")] pub mod instance; +#[cfg(feature = "client")] pub mod limit; pub mod types; +#[cfg(feature = "client")] pub mod voice; use url::{ParseError, Url}; From 351d0ae6d214f932d4cbf996f72301a377513a1f Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 10:16:24 -0400 Subject: [PATCH 03/23] Make client feature default --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index a7029fc..f910e0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ license = "AGPL-3" edition = "2021" [features] +default = ["client"] backend = ["poem", "sqlx"] client = [] From d00f21cd3f94c0406ef1afa2ba7bb313bb406b82 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 10:23:11 -0400 Subject: [PATCH 04/23] Un-lock mod errors --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4fa8f57..a849188 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #[cfg(feature = "client")] pub mod api; -#[cfg(feature = "client")] pub mod errors; #[cfg(feature = "client")] pub mod gateway; From 02d1cc3b97945b98be2fa441d1f2650368f725e2 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 11:44:02 -0400 Subject: [PATCH 05/23] Simplify locks --- src/types/entities/application.rs | 4 +--- src/types/entities/attachment.rs | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types/entities/application.rs b/src/types/entities/application.rs index 2ab3f99..748e8ff 100644 --- a/src/types/entities/application.rs +++ b/src/types/entities/application.rs @@ -2,11 +2,9 @@ use crate::types::utils::Snowflake; use bitflags::{bitflags, Flags}; use serde::{Deserialize, Serialize}; use serde_json::Value; -#[cfg(feature = "sqlx")] -use sqlx::FromRow; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[cfg_attr(feature = "sqlx", derive(FromRow))] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Application { pub id: Snowflake, pub name: String, diff --git a/src/types/entities/attachment.rs b/src/types/entities/attachment.rs index c93ab8f..03dfe13 100644 --- a/src/types/entities/attachment.rs +++ b/src/types/entities/attachment.rs @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Attachment { pub id: Snowflake, pub filename: String, @@ -18,6 +19,7 @@ pub struct Attachment { pub duration_secs: Option, pub waveform: Option, #[serde(skip_serializing)] + #[cfg_attr(feature = "sqlx", sqlx(default)] pub content: Vec, } From 0d5e592ea49fb6f71cefd37f9c512a48627fc2de Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 11:54:07 -0400 Subject: [PATCH 06/23] Simplify locks --- src/types/entities/attachment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/entities/attachment.rs b/src/types/entities/attachment.rs index 03dfe13..1be5579 100644 --- a/src/types/entities/attachment.rs +++ b/src/types/entities/attachment.rs @@ -19,7 +19,7 @@ pub struct Attachment { pub duration_secs: Option, pub waveform: Option, #[serde(skip_serializing)] - #[cfg_attr(feature = "sqlx", sqlx(default)] + #[cfg_attr(feature = "sqlx", sqlx(default))] pub content: Vec, } From bb7b7a57e393e80ed985db5726355a9f784c6dde Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 13:02:07 -0400 Subject: [PATCH 07/23] Use patched version of sqlx --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f910e0f..cc0c4b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ bigdecimal = "0.3.1" num-bigint = "0.4.3" lazy_static = "1.4.0" poem = { version = "1.3.55", optional = true } -sqlx = { version = "0.6.3", features = ["mysql", "sqlite", "json", "chrono", "ipnetwork", "runtime-tokio-native-tls", "any"], optional = true } +sqlx = { git = "https://github.com/zert3x/sqlx", branch="feature/skip", features = ["mysql", "sqlite", "json", "chrono", "ipnetwork", "runtime-tokio-native-tls", "any"], optional = true } thiserror = "1.0.40" jsonwebtoken = "8.3.0" From 986caf1110093e2d0f97ce98455757c030c673d2 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 14:08:53 -0400 Subject: [PATCH 08/23] Add feature locks to Channel --- src/types/entities/channel.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index e408968..973023e 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -1,3 +1,4 @@ +use chrono::Utc; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; @@ -7,12 +8,17 @@ use crate::types::{ }; #[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Channel { pub id: Snowflake, + pub created_at: chrono::DateTime, #[serde(rename = "type")] pub channel_type: ChannelType, pub guild_id: Option, pub position: Option, + #[cfg(feature = "sqlx")] + pub permission_overwrites: Option>>, + #[cfg(not(feature = "sqlx"))] pub permission_overwrites: Option>, pub name: Option, pub topic: Option, @@ -21,6 +27,7 @@ pub struct Channel { pub bitrate: Option, pub user_limit: Option, pub rate_limit_per_user: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub recipients: Option>, pub icon: Option, pub owner_id: Option, @@ -31,14 +38,25 @@ pub struct Channel { pub video_quality_mode: Option, pub message_count: Option, pub member_count: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub thread_metadata: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub member: Option, pub default_auto_archive_duration: Option, pub permissions: Option, pub flags: Option, pub total_message_sent: Option, + #[cfg(feature = "sqlx")] + pub available_tags: Option>>, + #[cfg(not(feature = "sqlx"))] pub available_tags: Option>, + #[cfg(feature = "sqlx")] + pub applied_tags: Option>>, + #[cfg(not(feature = "sqlx"))] pub applied_tags: Option>, + #[cfg(feature = "sqlx")] + pub default_reaction_emoji: Option>, + #[cfg(not(feature = "sqlx"))] pub default_reaction_emoji: Option, pub default_thread_rate_limit_per_user: Option, pub default_sort_order: Option, @@ -89,6 +107,7 @@ pub struct DefaultReaction { } #[derive(Default, Clone, Copy, Debug, Serialize_repr, Deserialize_repr, PartialEq, Eq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[repr(i32)] pub enum ChannelType { From 297ef50b36e4f7d0c1469870621c9189b85d6251 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 14:09:03 -0400 Subject: [PATCH 09/23] Add feature locks to Emoji --- src/types/entities/emoji.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/types/entities/emoji.rs b/src/types/entities/emoji.rs index cf56f1f..c02bd50 100644 --- a/src/types/entities/emoji.rs +++ b/src/types/entities/emoji.rs @@ -1,12 +1,24 @@ use serde::{Deserialize, Serialize}; use crate::types::entities::User; +use crate::types::{Guild, Snowflake}; #[derive(Debug, Deserialize, Serialize, Default, Clone)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Emoji { - pub id: Option, + pub id: Option, pub name: Option, - pub roles: Option>, + #[cfg(feature = "sqlx")] + pub roles: Option>>, + #[cfg(not(feature = "sqlx"))] + pub roles: Option>, + #[cfg(feature = "sqlx")] + pub guild_id: Snowflake, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub guild: Guild, + #[cfg(feature = "sqlx")] + pub user_id: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, pub require_colons: Option, pub managed: Option, From b885e139224fe66405762b1e8536673ff159cbc8 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 15:25:40 -0400 Subject: [PATCH 10/23] Flesh out and properly feature lock fields on Application --- src/types/entities/application.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/types/entities/application.rs b/src/types/entities/application.rs index 748e8ff..a85ccc8 100644 --- a/src/types/entities/application.rs +++ b/src/types/entities/application.rs @@ -1,4 +1,5 @@ use crate::types::utils::Snowflake; +use crate::types::{Team, User}; use bitflags::{bitflags, Flags}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -19,6 +20,9 @@ pub struct Application { pub bot_public: bool, pub bot_require_code_grant: bool, pub verify_key: String, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub owner: User, + #[cfg(feature = "sqlx")] pub owner_id: Snowflake, pub flags: u64, #[cfg(feature = "sqlx")] @@ -33,7 +37,10 @@ pub struct Application { pub integration_require_code_grant: bool, pub discoverability_state: i64, pub discovery_eligibility_flags: i64, - pub bot_user_id: Snowflake, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub bot_user: Option, + #[cfg(feature = "sqlx")] + pub bot_user_id: Option, #[cfg(feature = "sqlx")] pub tags: Option>>, #[cfg(not(feature = "sqlx"))] @@ -45,6 +52,9 @@ pub struct Application { pub install_params: Option, pub terms_of_service_url: Option, pub privacy_policy_url: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub team: Option, + #[cfg(feature = "sqlx")] pub team_id: Option, } From 8fcd64f87d01d9d3cc18c247dc0d5a6cef52c916 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 16:00:15 -0400 Subject: [PATCH 11/23] Flesh out and properly feature lock fields on Attachment --- src/types/entities/attachment.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/types/entities/attachment.rs b/src/types/entities/attachment.rs index 1be5579..89b2ebf 100644 --- a/src/types/entities/attachment.rs +++ b/src/types/entities/attachment.rs @@ -1,3 +1,4 @@ +use crate::types::Message; use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; @@ -14,7 +15,10 @@ pub struct Attachment { pub proxy_url: String, pub height: Option, pub width: Option, - pub message_id: Snowflake, + #[cfg(feature = "sqlx")] + pub message_id: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub message: Option, pub ephemeral: Option, pub duration_secs: Option, pub waveform: Option, From 86dcfb2c3b0a401f17e34b87833464c047875785 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 16:23:33 -0400 Subject: [PATCH 12/23] serde(skip) ids where full objects are returned --- src/types/entities/application.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/entities/application.rs b/src/types/entities/application.rs index a85ccc8..3ad0af2 100644 --- a/src/types/entities/application.rs +++ b/src/types/entities/application.rs @@ -23,6 +23,7 @@ pub struct Application { #[cfg_attr(feature = "sqlx", sqlx(skip))] pub owner: User, #[cfg(feature = "sqlx")] + #[serde(skip)] pub owner_id: Snowflake, pub flags: u64, #[cfg(feature = "sqlx")] @@ -40,6 +41,7 @@ pub struct Application { #[cfg_attr(feature = "sqlx", sqlx(skip))] pub bot_user: Option, #[cfg(feature = "sqlx")] + #[serde(skip)] pub bot_user_id: Option, #[cfg(feature = "sqlx")] pub tags: Option>>, @@ -55,6 +57,7 @@ pub struct Application { #[cfg_attr(feature = "sqlx", sqlx(skip))] pub team: Option, #[cfg(feature = "sqlx")] + #[serde(skip)] pub team_id: Option, } From 1420ba1696458d25687d256fa16cfa854ff27ec6 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 16:24:42 -0400 Subject: [PATCH 13/23] serde(skip) ids where full objects are returned --- src/types/entities/emoji.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/entities/emoji.rs b/src/types/entities/emoji.rs index c02bd50..01c4aca 100644 --- a/src/types/entities/emoji.rs +++ b/src/types/entities/emoji.rs @@ -13,10 +13,12 @@ pub struct Emoji { #[cfg(not(feature = "sqlx"))] pub roles: Option>, #[cfg(feature = "sqlx")] + #[serde(skip)] pub guild_id: Snowflake, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub guild: Guild, #[cfg(feature = "sqlx")] + #[serde(skip)] pub user_id: Option, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, From bbefab926cf9c00c546509db048d13e669cb3d96 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 22:29:20 -0400 Subject: [PATCH 14/23] Extract private fields to symfonia, type lock fields --- src/types/entities/application.rs | 11 -- src/types/entities/attachment.rs | 2 - src/types/entities/channel.rs | 5 +- src/types/entities/emoji.rs | 8 -- src/types/entities/guild.rs | 39 +++--- src/types/entities/integration.rs | 4 + src/types/entities/message.rs | 127 +++++++++++-------- src/types/entities/role.rs | 5 +- src/types/entities/security_key.rs | 1 + src/types/entities/sticker.rs | 8 +- src/types/entities/team.rs | 13 +- src/types/entities/template.rs | 7 +- src/types/entities/user.rs | 56 ++++---- src/types/entities/user_settings.rs | 26 +++- src/types/entities/voice_state.rs | 8 +- src/types/entities/webhook.rs | 17 +-- src/types/interfaces/guild_welcome_screen.rs | 4 +- 17 files changed, 185 insertions(+), 156 deletions(-) diff --git a/src/types/entities/application.rs b/src/types/entities/application.rs index 3ad0af2..9844e6d 100644 --- a/src/types/entities/application.rs +++ b/src/types/entities/application.rs @@ -22,9 +22,6 @@ pub struct Application { pub verify_key: String, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub owner: User, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub owner_id: Snowflake, pub flags: u64, #[cfg(feature = "sqlx")] pub redirect_uris: Option>>, @@ -38,11 +35,6 @@ pub struct Application { pub integration_require_code_grant: bool, pub discoverability_state: i64, pub discovery_eligibility_flags: i64, - #[cfg_attr(feature = "sqlx", sqlx(skip))] - pub bot_user: Option, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub bot_user_id: Option, #[cfg(feature = "sqlx")] pub tags: Option>>, #[cfg(not(feature = "sqlx"))] @@ -56,9 +48,6 @@ pub struct Application { pub privacy_policy_url: Option, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub team: Option, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub team_id: Option, } impl Application { diff --git a/src/types/entities/attachment.rs b/src/types/entities/attachment.rs index 89b2ebf..26b50a3 100644 --- a/src/types/entities/attachment.rs +++ b/src/types/entities/attachment.rs @@ -15,8 +15,6 @@ pub struct Attachment { pub proxy_url: String, pub height: Option, pub width: Option, - #[cfg(feature = "sqlx")] - pub message_id: Option, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub message: Option, pub ephemeral: Option, diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index 973023e..596bdbf 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -30,8 +30,9 @@ pub struct Channel { #[cfg_attr(feature = "sqlx", sqlx(skip))] pub recipients: Option>, pub icon: Option, - pub owner_id: Option, - pub application_id: Option, + pub owner_id: Option, + pub application_id: Option, + pub managed: Option, pub parent_id: Option, pub last_pin_timestamp: Option, pub rtc_region: Option, diff --git a/src/types/entities/emoji.rs b/src/types/entities/emoji.rs index 01c4aca..0524d1b 100644 --- a/src/types/entities/emoji.rs +++ b/src/types/entities/emoji.rs @@ -12,14 +12,6 @@ pub struct Emoji { pub roles: Option>>, #[cfg(not(feature = "sqlx"))] pub roles: Option>, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub guild_id: Snowflake, - #[cfg_attr(feature = "sqlx", sqlx(skip))] - pub guild: Guild, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub user_id: Option, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, pub require_colons: Option, diff --git a/src/types/entities/guild.rs b/src/types/entities/guild.rs index b2da5c1..1e73cc4 100644 --- a/src/types/entities/guild.rs +++ b/src/types/entities/guild.rs @@ -8,7 +8,8 @@ use crate::types::{ }; /// See https://discord.com/developers/docs/resources/guild -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Guild { pub id: Snowflake, pub name: String, @@ -16,24 +17,27 @@ pub struct Guild { pub icon_hash: Option, pub splash: Option, pub discovery_splash: Option, - pub owner: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub owner: bool, // True if requesting user is owner pub owner_id: Option, pub permissions: Option, pub afk_channel_id: Option, pub afk_timeout: Option, pub widget_enabled: Option, pub widget_channel_id: Option, - pub widget_channel: Option, pub verification_level: Option, pub default_message_notifications: Option, pub explicit_content_filter: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub roles: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub emojis: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub features: Vec, pub application_id: Option, pub system_channel_id: Option, pub system_channel_flags: Option, - pub rules_channel_id: Option, + pub rules_channel_id: Option, pub rules_channel: Option, pub max_presences: Option, pub max_members: Option, @@ -44,47 +48,48 @@ pub struct Guild { pub premium_subscription_count: Option, pub preferred_locale: Option, pub public_updates_channel_id: Option, - pub public_updates_channel: Option, pub max_video_channel_users: Option, pub max_stage_video_channel_users: Option, pub approximate_member_count: Option, pub approximate_presence_count: Option, - pub member_count: Option, - pub presence_count: Option, + #[cfg(feature = "sqlx")] + pub welcome_screen: Option>, + #[cfg(not(feature = "sqlx"))] pub welcome_screen: Option, pub nsfw_level: u8, - pub nsfw: bool, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub stickers: Option>, pub premium_progress_bar_enabled: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub joined_at: String, - pub afk_channel: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub bans: Option>, pub primary_category_id: Option, pub large: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub channels: Option>, - pub template_id: Option, - pub template: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub invites: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub voice_states: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub webhooks: Option>, pub mfa_level: Option, pub region: Option, - pub unavailable: bool, - pub parent: Option, } /// See https://docs.spacebar.chat/routes/#get-/guilds/-guild_id-/bans/-user- -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct GuildBan { - pub id: Snowflake, pub user_id: Snowflake, pub guild_id: Snowflake, - pub executor_id: Snowflake, pub reason: Option, } /// See https://docs.spacebar.chat/routes/#cmp--schemas-invite -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct GuildInvite { pub code: String, pub temporary: Option, diff --git a/src/types/entities/integration.rs b/src/types/entities/integration.rs index d4ed911..8076e70 100644 --- a/src/types/entities/integration.rs +++ b/src/types/entities/integration.rs @@ -7,6 +7,7 @@ use crate::types::{ }; #[derive(Default, Debug, Deserialize, Serialize, Clone)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] /// See https://discord.com/developers/docs/resources/guild#integration-object-integration-structure pub struct Integration { pub id: Snowflake, @@ -19,11 +20,14 @@ pub struct Integration { pub enabled_emoticons: Option, pub expire_behaviour: Option, pub expire_grace_period: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub account: IntegrationAccount, pub synced_at: Option>, pub subscriber_count: Option, pub revoked: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub application: Option, pub scopes: Option>, } diff --git a/src/types/entities/message.rs b/src/types/entities/message.rs index e384e61..55cb92f 100644 --- a/src/types/entities/message.rs +++ b/src/types/entities/message.rs @@ -8,43 +8,62 @@ use crate::types::{ utils::Snowflake, }; -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Message { - id: Snowflake, + pub id: Snowflake, pub channel_id: Snowflake, - author: User, - content: String, - timestamp: String, - edited_timestamp: Option, - tts: bool, - mention_everyone: bool, - mentions: Vec, - mention_roles: Vec, - mention_channels: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub author: User, + pub content: String, + pub timestamp: String, + pub edited_timestamp: Option, + pub tts: bool, + pub mention_everyone: bool, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub mentions: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub mention_roles: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub mention_channels: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub attachments: Vec, - embeds: Vec, - reactions: Option>, - nonce: Option, - pinned: bool, - webhook_id: Option, + #[cfg(feature = "sqlx")] + pub embeds: Vec>, + #[cfg(not(feature = "sqlx"))] + pub embeds: Vec, + #[cfg(feature = "sqlx")] + pub reactions: Option>>, + #[cfg(not(feature = "sqlx"))] + pub reactions: Option>, + pub nonce: Option, + pub pinned: bool, + pub webhook_id: Option, #[serde(rename = "type")] - message_type: i32, - activity: Option, - application: Option, - application_id: Option, - message_reference: Option, - flags: Option, - referenced_message: Option>, - interaction: Option, - thread: Option, - components: Option>, - sticker_items: Option>, - stickers: Option>, - position: Option, - role_subscription_data: Option, + pub message_type: i32, + #[cfg(feature = "sqlx")] + pub activity: Option>, + #[cfg(not(feature = "sqlx"))] + pub activity: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub application: Option, + pub application_id: Option, + #[cfg(feature = "sqlx")] + pub message_reference: Option>, + #[cfg(not(feature = "sqlx"))] + pub message_reference: Option, + pub flags: Option, + pub referenced_message: Option>, + pub interaction: Option, + pub thread: Option, + pub components: Option>, + pub sticker_items: Option>, + pub stickers: Option>, + pub position: Option, + pub role_subscription_data: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct MessageReference { pub message_id: Snowflake, pub channel_id: Snowflake, @@ -52,7 +71,7 @@ pub struct MessageReference { pub fail_if_not_exists: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] pub struct MessageInteraction { pub id: Snowflake, #[serde(rename = "type")] @@ -62,7 +81,7 @@ pub struct MessageInteraction { pub member: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct AllowedMention { parse: Vec, roles: Vec, @@ -70,7 +89,7 @@ pub struct AllowedMention { replied_user: bool, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum AllowedMentionType { Roles, @@ -78,16 +97,16 @@ pub enum AllowedMentionType { Everyone, } -#[derive(Debug, Serialize, Deserialize)] -struct ChannelMention { - id: Snowflake, - guild_id: Snowflake, +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct ChannelMention { + pub id: Snowflake, + pub guild_id: Snowflake, #[serde(rename = "type")] channel_type: i32, name: String, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct Embed { title: Option, #[serde(rename = "type")] @@ -105,30 +124,30 @@ pub struct Embed { fields: Option>, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedFooter { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedFooter { text: String, icon_url: Option, proxy_icon_url: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedImage { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedImage { url: String, proxy_url: String, height: Option, width: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedThumbnail { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedThumbnail { url: String, proxy_url: Option, height: Option, width: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] struct EmbedVideo { url: Option, proxy_url: Option, @@ -136,29 +155,29 @@ struct EmbedVideo { width: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedProvider { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedProvider { name: Option, url: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedAuthor { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedAuthor { name: String, url: Option, icon_url: Option, proxy_icon_url: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -struct EmbedField { +pub struct EmbedField { name: String, value: String, inline: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct Reaction { pub count: i32, pub me: bool, @@ -177,7 +196,7 @@ pub enum Component { ChannelSelect = 8, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct MessageActivity { #[serde(rename = "type")] pub activity_type: i64, diff --git a/src/types/entities/role.rs b/src/types/entities/role.rs index 708be00..f427dc9 100644 --- a/src/types/entities/role.rs +++ b/src/types/entities/role.rs @@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] /// See https://discord.com/developers/docs/topics/permissions#role-object pub struct RoleObject { pub id: Snowflake, @@ -19,7 +20,7 @@ pub struct RoleObject { //pub tags: Option } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct RoleSubscriptionData { pub role_subscription_listing_id: Snowflake, pub tier_name: String, diff --git a/src/types/entities/security_key.rs b/src/types/entities/security_key.rs index 09112cc..2cf8f66 100644 --- a/src/types/entities/security_key.rs +++ b/src/types/entities/security_key.rs @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct SecurityKey { pub id: String, pub user_id: String, diff --git a/src/types/entities/sticker.rs b/src/types/entities/sticker.rs index d8f2803..3c4a9d2 100644 --- a/src/types/entities/sticker.rs +++ b/src/types/entities/sticker.rs @@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize}; use crate::types::{entities::User, utils::Snowflake}; -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Sticker { pub id: Snowflake, pub pack_id: Option, @@ -14,12 +15,13 @@ pub struct Sticker { pub sticker_type: u8, pub format_type: u8, pub available: Option, - pub guild_id: Option, + pub guild_id: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, pub sort_value: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct StickerItem { pub id: Snowflake, pub name: String, diff --git a/src/types/entities/team.rs b/src/types/entities/team.rs index 7c381a6..a6f2ef1 100644 --- a/src/types/entities/team.rs +++ b/src/types/entities/team.rs @@ -1,20 +1,23 @@ use serde::{Deserialize, Serialize}; use crate::types::entities::User; +use crate::types::Snowflake; -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Team { pub icon: Option, - pub id: u64, + pub id: Snowflake, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub members: Vec, pub name: String, - pub owner_user_id: u64, + pub owner_user_id: Snowflake, } -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] pub struct TeamMember { pub membership_state: u8, pub permissions: Vec, - pub team_id: u64, + pub team_id: Snowflake, pub user: User, } diff --git a/src/types/entities/template.rs b/src/types/entities/template.rs index dfbd98a..aa87251 100644 --- a/src/types/entities/template.rs +++ b/src/types/entities/template.rs @@ -7,18 +7,21 @@ use crate::types::{ }; /// See https://docs.spacebar.chat/routes/#cmp--schemas-template -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct GuildTemplate { pub code: String, pub name: String, pub description: Option, pub usage_count: Option, pub creator_id: Snowflake, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub creator: User, pub created_at: DateTime, pub updated_at: DateTime, pub source_guild_id: String, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub source_guild: Vec, // Unsure how a {recursive: Guild} looks like, might be a Vec? + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub serialized_source_guild: Vec, - id: Snowflake, } diff --git a/src/types/entities/user.rs b/src/types/entities/user.rs index 1c8b102..ee3702d 100644 --- a/src/types/entities/user.rs +++ b/src/types/entities/user.rs @@ -1,8 +1,6 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; -#[cfg(feature = "sqlx")] -use sqlx::{FromRow, Type}; use crate::types::{ errors::Error, @@ -10,7 +8,7 @@ use crate::types::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] -#[cfg_attr(feature = "sqlx", derive(Type))] +#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] pub struct UserData { pub valid_tokens_since: DateTime, pub hash: Option, @@ -23,32 +21,34 @@ impl User { } #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct User { pub id: Snowflake, - username: String, - discriminator: String, - avatar: Option, - bot: bool, - system: Option, - mfa_enabled: Option, - accent_color: Option, - locale: Option, - verified: Option, - email: Option, - flags: String, - premium_since: Option>, - premium_type: u8, - pronouns: Option, - public_flags: Option, - banner: Option, - bio: String, - theme_colors: Option>, - phone: Option, - nsfw_allowed: bool, - premium: bool, - purchased_flags: i32, - premium_usage_flags: i32, - disabled: Option, + pub username: String, + pub discriminator: String, + pub avatar: Option, + pub bot: bool, + pub system: Option, + pub mfa_enabled: Option, + pub accent_color: Option, + #[cfg_attr(feature = "sqlx", sqlx(default))] + pub locale: Option, + pub verified: Option, + pub email: Option, + pub flags: String, + pub premium_since: Option>, + pub premium_type: u8, + pub pronouns: Option, + pub public_flags: Option, + pub banner: Option, + pub bio: String, + pub theme_colors: Option>, + pub phone: Option, + pub nsfw_allowed: bool, + pub premium: bool, + pub purchased_flags: i32, + pub premium_usage_flags: i32, + pub disabled: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -92,7 +92,7 @@ const CUSTOM_USER_FLAG_OFFSET: u64 = 1 << 32; bitflags::bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] - #[cfg_attr(feature = "sqlx", derive(Type))] + #[cfg_attr(feature = "sqlx", derive(sqlx::Type))] pub struct UserFlags: u64 { const DISCORD_EMPLOYEE = 1 << 0; const PARTNERED_SERVER_OWNER = 1 << 1; diff --git a/src/types/entities/user_settings.rs b/src/types/entities/user_settings.rs index 6f3ac53..1445c31 100644 --- a/src/types/entities/user_settings.rs +++ b/src/types/entities/user_settings.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] +#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[serde(rename_all = "lowercase")] pub enum UserStatus { #[default] @@ -23,6 +24,7 @@ pub enum UserTheme { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct UserSettings { pub afk_timeout: u16, pub allow_accessibility_detection: bool, @@ -30,6 +32,9 @@ pub struct UserSettings { pub animate_stickers: u8, pub contact_sync_enabled: bool, pub convert_emoticons: bool, + #[cfg(feature = "sqlx")] + pub custom_status: Option>, + #[cfg(not(feature = "sqlx"))] pub custom_status: Option, pub default_guilds_restricted: bool, pub detect_platform_accounts: bool, @@ -37,10 +42,19 @@ pub struct UserSettings { pub disable_games_tab: bool, pub enable_tts_command: bool, pub explicit_content_filter: u8, + #[cfg(feature = "sqlx")] + pub friend_source_flags: sqlx::types::Json, + #[cfg(not(feature = "sqlx"))] pub friend_source_flags: FriendSourceFlags, pub gateway_connected: bool, pub gif_auto_play: bool, + #[cfg(feature = "sqlx")] + pub guild_folders: sqlx::types::Json>, + #[cfg(not(feature = "sqlx"))] pub guild_folders: Vec, + #[cfg(feature = "sqlx")] + pub guild_positions: sqlx::types::Json>, + #[cfg(not(feature = "sqlx"))] pub guild_positions: Vec, pub inline_attachment_media: bool, pub inline_embed_media: bool, @@ -49,6 +63,9 @@ pub struct UserSettings { pub native_phone_integration_enabled: bool, pub render_embeds: bool, pub render_reactions: bool, + #[cfg(feature = "sqlx")] + pub restricted_guilds: sqlx::types::Json>, + #[cfg(not(feature = "sqlx"))] pub restricted_guilds: Vec, pub show_current_game: bool, pub status: UserStatus, @@ -73,11 +90,11 @@ impl Default for UserSettings { disable_games_tab: true, enable_tts_command: false, explicit_content_filter: 0, - friend_source_flags: FriendSourceFlags::default(), + friend_source_flags: Default::default(), gateway_connected: false, gif_auto_play: false, - guild_folders: Vec::new(), - guild_positions: Vec::new(), + guild_folders: Default::default(), + guild_positions: Default::default(), inline_attachment_media: true, inline_embed_media: true, locale: "en-US".to_string(), @@ -85,7 +102,7 @@ impl Default for UserSettings { native_phone_integration_enabled: true, render_embeds: true, render_reactions: true, - restricted_guilds: Vec::new(), + restricted_guilds: Default::default(), show_current_game: true, status: UserStatus::Online, stream_notifications_enabled: false, @@ -96,6 +113,7 @@ impl Default for UserSettings { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct CustomStatus { pub emoji_id: Option, pub emoji_name: Option, diff --git a/src/types/entities/voice_state.rs b/src/types/entities/voice_state.rs index 68e2051..fd81ba8 100644 --- a/src/types/entities/voice_state.rs +++ b/src/types/entities/voice_state.rs @@ -7,17 +7,14 @@ use crate::types::{ }; /// See https://docs.spacebar.chat/routes/#cmp--schemas-voicestate -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct VoiceState { pub guild_id: Snowflake, - pub guild: Option, pub channel_id: Snowflake, - pub channel: Option, pub user_id: Snowflake, - pub user: Option, pub member: Option, pub session_id: Snowflake, - pub token: String, pub deaf: bool, pub mute: bool, pub self_deaf: bool, @@ -26,5 +23,4 @@ pub struct VoiceState { pub self_video: bool, pub suppress: bool, pub request_to_speak_timestamp: Option>, - pub id: Snowflake, } diff --git a/src/types/entities/webhook.rs b/src/types/entities/webhook.rs index 26fa81f..0097d81 100644 --- a/src/types/entities/webhook.rs +++ b/src/types/entities/webhook.rs @@ -6,27 +6,24 @@ use crate::types::{ }; /// See https://docs.spacebar.chat/routes/#cmp--schemas-webhook -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Webhook { + pub id: Snowflake, #[serde(rename = "type")] pub webhook_type: i32, pub name: String, pub avatar: String, pub token: String, pub guild_id: Snowflake, - #[serde(skip_serializing_if = "Option::is_none")] - pub guild: Option, pub channel_id: Snowflake, - #[serde(skip_serializing_if = "Option::is_none")] - pub channel: Option, pub application_id: Snowflake, #[serde(skip_serializing_if = "Option::is_none")] - pub application: Option, - pub user_id: Snowflake, - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, - pub source_guild_id: Snowflake, #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub source_guild: Option, - pub id: Snowflake, + #[serde(skip_serializing_if = "Option::is_none")] + pub url: Option, } diff --git a/src/types/interfaces/guild_welcome_screen.rs b/src/types/interfaces/guild_welcome_screen.rs index f799b1d..0260ab3 100644 --- a/src/types/interfaces/guild_welcome_screen.rs +++ b/src/types/interfaces/guild_welcome_screen.rs @@ -1,14 +1,14 @@ use crate::types::utils::Snowflake; use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] pub struct WelcomeScreenObject { pub enabled: bool, pub description: Option, pub welcome_channels: Vec, } -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] pub struct WelcomeScreenChannel { pub channel_id: Snowflake, pub description: String, From 0bdae8f7e3fb7552e3705d69fb694786f29c9f97 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 22:37:20 -0400 Subject: [PATCH 15/23] Add forgotten derives to Emoji --- src/types/entities/emoji.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/entities/emoji.rs b/src/types/entities/emoji.rs index 0524d1b..752d373 100644 --- a/src/types/entities/emoji.rs +++ b/src/types/entities/emoji.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::types::entities::User; use crate::types::{Guild, Snowflake}; -#[derive(Debug, Deserialize, Serialize, Default, Clone)] +#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, Default)] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Emoji { pub id: Option, From 185480b0be75a4a692e133c292b7c7bf7aebf5cb Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 22:38:16 -0400 Subject: [PATCH 16/23] Add forgotten feature lock to UserTheme --- src/types/entities/user_settings.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/entities/user_settings.rs b/src/types/entities/user_settings.rs index 1445c31..f34a159 100644 --- a/src/types/entities/user_settings.rs +++ b/src/types/entities/user_settings.rs @@ -16,6 +16,7 @@ pub enum UserStatus { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] +#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[serde(rename_all = "lowercase")] pub enum UserTheme { #[default] From 342354a06b33d5313c75936e8cd4659a57a9ebb4 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 22:38:39 -0400 Subject: [PATCH 17/23] Add forgotten derives to UnvailableGuild/GuildCreateResponse --- src/types/entities/guild.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/entities/guild.rs b/src/types/entities/guild.rs index 1e73cc4..f3f03f7 100644 --- a/src/types/entities/guild.rs +++ b/src/types/entities/guild.rs @@ -110,13 +110,13 @@ pub struct GuildInvite { pub vanity_url: Option, } -#[derive(Serialize, Deserialize, Debug, Default)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] pub struct UnavailableGuild { id: String, unavailable: bool, } -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] pub struct GuildCreateResponse { pub id: String, } From b8e5b627de77fc73cb4199e22343457bea3d0120 Mon Sep 17 00:00:00 2001 From: Zertex Date: Fri, 26 May 2023 22:44:43 -0400 Subject: [PATCH 18/23] Add PartialEq, Clone, Copy to Component --- src/types/entities/message.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/entities/message.rs b/src/types/entities/message.rs index 55cb92f..9efcad1 100644 --- a/src/types/entities/message.rs +++ b/src/types/entities/message.rs @@ -184,7 +184,7 @@ pub struct Reaction { pub emoji: Emoji, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)] pub enum Component { ActionRow = 1, Button = 2, From 3018c0ddd1cda423f62d84a9a5b29c6d90912cf8 Mon Sep 17 00:00:00 2001 From: Zertex Date: Sat, 27 May 2023 00:07:07 -0400 Subject: [PATCH 19/23] Add back settings and extended_settings fields to User --- src/types/entities/user.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/types/entities/user.rs b/src/types/entities/user.rs index ee3702d..bd1ffb2 100644 --- a/src/types/entities/user.rs +++ b/src/types/entities/user.rs @@ -49,6 +49,12 @@ pub struct User { pub purchased_flags: i32, pub premium_usage_flags: i32, pub disabled: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub settings: UserSettings, + #[cfg(feature = "sqlx")] + pub extended_settings: sqlx::types::Json, + #[cfg(not(feature = "sqlx"))] + pub extended_settings: Value, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] From 13c2e4aed9a91349abb6ec22446c2ab12b0b21f4 Mon Sep 17 00:00:00 2001 From: Zertex Date: Sat, 27 May 2023 00:12:05 -0400 Subject: [PATCH 20/23] fix imports --- src/types/entities/user.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/types/entities/user.rs b/src/types/entities/user.rs index bd1ffb2..be3e2b9 100644 --- a/src/types/entities/user.rs +++ b/src/types/entities/user.rs @@ -2,10 +2,7 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; -use crate::types::{ - errors::Error, - utils::Snowflake, //util::{email::adjust_email, entities::user_setting::UserSettings}, -}; +use crate::types::{errors::Error, utils::Snowflake, UserSettings}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))] From 9974d9041624d7e64f2a8f18c81a91581d1abd85 Mon Sep 17 00:00:00 2001 From: Zertex Date: Sat, 27 May 2023 00:24:32 -0400 Subject: [PATCH 21/23] Revert "fix imports" This reverts commit 13c2e4aed9a91349abb6ec22446c2ab12b0b21f4. --- src/types/entities/user.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/types/entities/user.rs b/src/types/entities/user.rs index be3e2b9..bd1ffb2 100644 --- a/src/types/entities/user.rs +++ b/src/types/entities/user.rs @@ -2,7 +2,10 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; -use crate::types::{errors::Error, utils::Snowflake, UserSettings}; +use crate::types::{ + errors::Error, + utils::Snowflake, //util::{email::adjust_email, entities::user_setting::UserSettings}, +}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))] From 5e000f3617a1e1428cdc5d1cae43b29242b6834b Mon Sep 17 00:00:00 2001 From: Zertex Date: Sat, 27 May 2023 00:24:37 -0400 Subject: [PATCH 22/23] Revert "Add back settings and extended_settings fields to User" This reverts commit 3018c0ddd1cda423f62d84a9a5b29c6d90912cf8. --- src/types/entities/user.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/types/entities/user.rs b/src/types/entities/user.rs index bd1ffb2..ee3702d 100644 --- a/src/types/entities/user.rs +++ b/src/types/entities/user.rs @@ -49,12 +49,6 @@ pub struct User { pub purchased_flags: i32, pub premium_usage_flags: i32, pub disabled: Option, - #[cfg_attr(feature = "sqlx", sqlx(skip))] - pub settings: UserSettings, - #[cfg(feature = "sqlx")] - pub extended_settings: sqlx::types::Json, - #[cfg(not(feature = "sqlx"))] - pub extended_settings: Value, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] From 7a487c657c6f2c6f421597470687f655d53c22f6 Mon Sep 17 00:00:00 2001 From: Zertex Date: Sat, 27 May 2023 11:40:20 -0400 Subject: [PATCH 23/23] remove message field --- src/types/entities/attachment.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/entities/attachment.rs b/src/types/entities/attachment.rs index 26b50a3..210f738 100644 --- a/src/types/entities/attachment.rs +++ b/src/types/entities/attachment.rs @@ -15,8 +15,6 @@ pub struct Attachment { pub proxy_url: String, pub height: Option, pub width: Option, - #[cfg_attr(feature = "sqlx", sqlx(skip))] - pub message: Option, pub ephemeral: Option, pub duration_secs: Option, pub waveform: Option,