]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/source/person.rs
Making public key required. Fixes #1934
[lemmy.git] / crates / db_schema / src / source / person.rs
index be1ce268f7d5bc4f4bc525ca4851cb2c1850b480..8ff56eba445f578ba77213c9e1f6633ed3cec2c2 100644 (file)
@@ -1,11 +1,10 @@
 use crate::{
+  newtypes::{DbUrl, PersonId},
   schema::{person, person_alias_1, person_alias_2},
-  DbUrl,
-  PersonId,
 };
-use serde::Serialize;
+use serde::{Deserialize, Serialize};
 
-#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
+#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "person"]
 pub struct Person {
   pub id: PersonId,
@@ -19,7 +18,7 @@ pub struct Person {
   pub bio: Option<String>,
   pub local: bool,
   pub private_key: Option<String>,
-  pub public_key: Option<String>,
+  pub public_key: String,
   pub last_refreshed_at: chrono::NaiveDateTime,
   pub banner: Option<DbUrl>,
   pub deleted: bool,
@@ -27,10 +26,11 @@ pub struct Person {
   pub shared_inbox_url: Option<DbUrl>,
   pub matrix_user_id: Option<String>,
   pub admin: bool,
+  pub bot_account: bool,
 }
 
 /// A safe representation of person, without the sensitive info
-#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
+#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "person"]
 pub struct PersonSafe {
   pub id: PersonId,
@@ -49,9 +49,10 @@ pub struct PersonSafe {
   pub shared_inbox_url: Option<DbUrl>,
   pub matrix_user_id: Option<String>,
   pub admin: bool,
+  pub bot_account: bool,
 }
 
-#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
+#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "person_alias_1"]
 pub struct PersonAlias1 {
   pub id: PersonId,
@@ -65,7 +66,7 @@ pub struct PersonAlias1 {
   pub bio: Option<String>,
   pub local: bool,
   pub private_key: Option<String>,
-  pub public_key: Option<String>,
+  pub public_key: String,
   pub last_refreshed_at: chrono::NaiveDateTime,
   pub banner: Option<DbUrl>,
   pub deleted: bool,
@@ -73,9 +74,10 @@ pub struct PersonAlias1 {
   pub shared_inbox_url: Option<DbUrl>,
   pub matrix_user_id: Option<String>,
   pub admin: bool,
+  pub bot_account: bool,
 }
 
-#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
+#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "person_alias_1"]
 pub struct PersonSafeAlias1 {
   pub id: PersonId,
@@ -94,9 +96,10 @@ pub struct PersonSafeAlias1 {
   pub shared_inbox_url: Option<DbUrl>,
   pub matrix_user_id: Option<String>,
   pub admin: bool,
+  pub bot_account: bool,
 }
 
-#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
+#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "person_alias_2"]
 pub struct PersonAlias2 {
   pub id: PersonId,
@@ -110,7 +113,7 @@ pub struct PersonAlias2 {
   pub bio: Option<String>,
   pub local: bool,
   pub private_key: Option<String>,
-  pub public_key: Option<String>,
+  pub public_key: String,
   pub last_refreshed_at: chrono::NaiveDateTime,
   pub banner: Option<DbUrl>,
   pub deleted: bool,
@@ -118,9 +121,10 @@ pub struct PersonAlias2 {
   pub shared_inbox_url: Option<DbUrl>,
   pub matrix_user_id: Option<String>,
   pub admin: bool,
+  pub bot_account: bool,
 }
 
-#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
+#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "person_alias_1"]
 pub struct PersonSafeAlias2 {
   pub id: PersonId,
@@ -139,6 +143,7 @@ pub struct PersonSafeAlias2 {
   pub shared_inbox_url: Option<DbUrl>,
   pub matrix_user_id: Option<String>,
   pub admin: bool,
+  pub bot_account: bool,
 }
 
 #[derive(Insertable, AsChangeset, Clone, Default)]
@@ -154,7 +159,7 @@ pub struct PersonForm {
   pub bio: Option<Option<String>>,
   pub local: Option<bool>,
   pub private_key: Option<Option<String>>,
-  pub public_key: Option<Option<String>>,
+  pub public_key: String,
   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
   pub banner: Option<Option<DbUrl>>,
   pub deleted: Option<bool>,
@@ -162,4 +167,5 @@ pub struct PersonForm {
   pub shared_inbox_url: Option<Option<DbUrl>>,
   pub matrix_user_id: Option<Option<String>>,
   pub admin: Option<bool>,
+  pub bot_account: Option<bool>,
 }