From fc24ad34305f8d83d9ea9504f51c11d6157976be Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 17 May 2021 16:04:26 -0700 Subject: [PATCH] * Badges now have an optional permissions field * New struct changes integrating badge system --- json-api/db/src/lib.rs | 13 ++++++++++++- json-api/migrations/2021-05-17-221928_badges/up.sql | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/json-api/db/src/lib.rs b/json-api/db/src/lib.rs index 0de94d3..35f3222 100644 --- a/json-api/db/src/lib.rs +++ b/json-api/db/src/lib.rs @@ -65,7 +65,8 @@ pub struct Channel { pub id: UBigInt, pub name: VarChar, pub description: Option, - pub kind: Integer + pub kind: Integer, + pub badges: Vec } #[derive(Serialize, Debug)] @@ -82,6 +83,7 @@ pub struct Member { pub name: VarChar, pub status: Integer, pub permissions: UBigInt, + pub badges: Vec } #[derive(Serialize)] @@ -90,6 +92,7 @@ pub struct PublicMember { pub name: VarChar, pub status: Integer, pub permissions: UBigInt, + pub badges: Vec } #[derive(Debug, Deserialize, Serialize)] @@ -100,3 +103,11 @@ pub struct Neighbor { pub url: String, pub wsurl: Option, } + +#[derive(Debug, Serialize, Deserialize)] +pub struct Badge { + pub name: String, + pub id: u32, + pub color: u32, + pub perms: Option, // abridged version of permissiosn +} \ No newline at end of file diff --git a/json-api/migrations/2021-05-17-221928_badges/up.sql b/json-api/migrations/2021-05-17-221928_badges/up.sql index 73d044b..571151b 100644 --- a/json-api/migrations/2021-05-17-221928_badges/up.sql +++ b/json-api/migrations/2021-05-17-221928_badges/up.sql @@ -2,5 +2,6 @@ CREATE TABLE IF NOT EXISTS `badges`( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(256) NOT NULL, `color` INTEGER UNSIGNED NOT NULL DEFAULT 0xFFFFFFFF, + `permissions` INTEGER UNSIGNED, -- nullable because this isn't logically applicable to every badge PRIMARY KEY(`id`) ); \ No newline at end of file