]> git.puffer.fish Git - matthieu/nova.git/commitdiff
Add Application-related structures
authorn1c00o <git.n1c00o@gmail.com>
Sat, 2 Oct 2021 21:00:08 +0000 (23:00 +0200)
committern1c00o <git.n1c00o@gmail.com>
Sat, 2 Oct 2021 21:00:08 +0000 (23:00 +0200)
common/rust/src/discord_models/application.rs [new file with mode: 0644]
common/rust/src/discord_models/mod.rs
common/rust/src/discord_models/teams.rs [new file with mode: 0644]

diff --git a/common/rust/src/discord_models/application.rs b/common/rust/src/discord_models/application.rs
new file mode 100644 (file)
index 0000000..65707d2
--- /dev/null
@@ -0,0 +1,38 @@
+use enumflags2::{bitflags, BitFlags};
+use serde::{Deserialize, Serialize};
+
+use super::{teams::Team, user::User};
+
+#[bitflags]
+#[repr(u64)]
+#[derive(Debug, Clone, Copy)]
+pub enum ApplicationFlags {
+    GatewayPresence = 1 << 12,
+    GatewayPresenceLimit = 1 << 13,
+    GatewayGuildMembers = 1 << 14,
+    GatewayGuildMembersLimited = 1 << 15,
+    VerificationPendingGuildLimit = 1 << 16,
+    Embedded = 1 << 17,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct Application {
+    pub id: String,
+    pub name: String,
+    pub icon: Option<String>,
+    pub description: String,
+    pub rpc_origins: Option<Vec<String>>,
+    pub bot_public: bool,
+    pub bot_require_code_grant: bool,
+    pub terms_of_service_url: Option<String>,
+    pub privacy_policy_url: Option<String>,
+    pub owner: Option<User>,
+    pub summary: String,
+    pub verify_key: String,
+    pub team: Option<Team>,
+    pub guild_id: Option<String>,
+    pub primary_sku_id: Option<String>,
+    pub slug: Option<String>,
+    pub cover_image: Option<String>,
+    pub flags: Option<BitFlags<ApplicationFlags>>,
+}
index 56d877fa1614909440b9c9a8316396526ab78266..2bcde7c1c109df53a4c69785c85210677d074814 100644 (file)
@@ -1,2 +1,5 @@
+pub mod application;
 pub mod guild;
+pub mod stage_instance;
+pub mod teams;
 pub mod user;
diff --git a/common/rust/src/discord_models/teams.rs b/common/rust/src/discord_models/teams.rs
new file mode 100644 (file)
index 0000000..369b3cd
--- /dev/null
@@ -0,0 +1,28 @@
+use serde::{Deserialize, Serialize};
+use serde_repr::{Deserialize_repr, Serialize_repr};
+
+use super::user::User;
+
+#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)]
+#[repr(u8)]
+pub enum MembershipState {
+    Invited = 0,
+    Accepted = 1,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TeamMembers {
+    pub membership_state: MembershipState,
+    pub permissions: Vec<String>,
+    pub team_id: String,
+    pub user: User,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct Team {
+    pub icon: Option<String>,
+    pub id: String,
+    pub members: Vec<TeamMembers>,
+    pub name: String,
+    pub owner_user_id: String,
+}