]> Untitled Git - lemmy.git/commitdiff
Creating default DB forms. Fixes #1511
authorDessalines <tyhou13@gmx.com>
Sat, 20 Mar 2021 20:59:07 +0000 (16:59 -0400)
committerDessalines <tyhou13@gmx.com>
Sat, 20 Mar 2021 20:59:07 +0000 (16:59 -0400)
35 files changed:
crates/api/src/comment.rs
crates/api/src/community.rs
crates/api/src/lib.rs
crates/api/src/local_user.rs
crates/api/src/post.rs
crates/api_structs/src/community.rs
crates/apub/src/objects/comment.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/post.rs
crates/apub/src/objects/private_message.rs
crates/db_queries/src/aggregates/comment_aggregates.rs
crates/db_queries/src/aggregates/community_aggregates.rs
crates/db_queries/src/aggregates/person_aggregates.rs
crates/db_queries/src/aggregates/post_aggregates.rs
crates/db_queries/src/aggregates/site_aggregates.rs
crates/db_queries/src/source/activity.rs
crates/db_queries/src/source/comment.rs
crates/db_queries/src/source/community.rs
crates/db_queries/src/source/moderator.rs
crates/db_queries/src/source/password_reset_request.rs
crates/db_queries/src/source/person.rs
crates/db_queries/src/source/person_mention.rs
crates/db_queries/src/source/post.rs
crates/db_queries/src/source/private_message.rs
crates/db_schema/src/lib.rs
crates/db_schema/src/source/activity.rs
crates/db_schema/src/source/comment.rs
crates/db_schema/src/source/community.rs
crates/db_schema/src/source/local_user.rs
crates/db_schema/src/source/person.rs
crates/db_schema/src/source/post.rs
crates/db_schema/src/source/private_message.rs
crates/db_views/src/comment_view.rs
crates/db_views/src/post_view.rs
src/code_migrations.rs

index 4fd3f7b2c2ddbba4dd1fca52d3f3f1d45c9a89d7..61f9a7040e44744bbbb51ac004e89305c68304c1 100644 (file)
@@ -85,13 +85,7 @@ impl Perform for CreateComment {
       parent_id: data.parent_id.to_owned(),
       post_id: data.post_id,
       creator_id: local_user_view.person.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     // Create the comment
index f6ecbf1255df3678fb63477eb9d93d348d431ae6..cce4dfbcc43d3e82931e163b69e49922b1a5b312 100644 (file)
@@ -168,19 +168,14 @@ impl Perform for CreateCommunity {
       icon,
       banner,
       creator_id: local_user_view.person.id,
-      removed: None,
-      deleted: None,
       nsfw: data.nsfw,
-      updated: None,
       actor_id: Some(community_actor_id.to_owned()),
-      local: true,
       private_key: Some(keypair.private_key),
       public_key: Some(keypair.public_key),
-      last_refreshed_at: None,
-      published: None,
       followers_url: Some(generate_followers_url(&community_actor_id)?),
       inbox_url: Some(generate_inbox_url(&community_actor_id)?),
       shared_inbox_url: Some(Some(generate_shared_inbox_url(&community_actor_id)?)),
+      ..CommunityForm::default()
     };
 
     let inserted_community = match blocking(context.pool(), move |conn| {
@@ -263,23 +258,13 @@ impl Perform for EditCommunity {
     let community_form = CommunityForm {
       name: read_community.name,
       title: data.title.to_owned(),
+      creator_id: read_community.creator_id,
       description: data.description.to_owned(),
       icon,
       banner,
-      creator_id: read_community.creator_id,
-      removed: Some(read_community.removed),
-      deleted: Some(read_community.deleted),
       nsfw: data.nsfw,
       updated: Some(naive_now()),
-      actor_id: Some(read_community.actor_id),
-      local: read_community.local,
-      private_key: read_community.private_key,
-      public_key: read_community.public_key,
-      last_refreshed_at: None,
-      published: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let community_id = data.community_id;
index 8c6fe8a5208609a8ed560d8a837049b455758d61..fc258d6a19c8b367fda557911ebbc5d6bf45e618 100644 (file)
@@ -528,38 +528,15 @@ mod tests {
 
     let new_person = PersonForm {
       name: "Gerry9812".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
 
     let local_user_form = LocalUserForm {
       person_id: inserted_person.id,
-      email: None,
       password_encrypted: "123456".to_string(),
-      admin: None,
-      show_nsfw: None,
-      theme: None,
-      default_sort_type: None,
-      default_listing_type: None,
-      lang: None,
-      show_avatars: None,
-      send_notifications_to_email: None,
+      ..LocalUserForm::default()
     };
 
     let inserted_local_user = LocalUser::create(&conn, &local_user_form).unwrap();
index c43db39cf0f63e2bd6564468151663aea02187dc..f7072b6e6498d78069879ac0585df20bb4925dc1 100644 (file)
@@ -199,22 +199,12 @@ impl Perform for Register {
     // Register the new person
     let person_form = PersonForm {
       name: data.username.to_owned(),
-      avatar: None,
-      banner: None,
-      preferred_username: None,
-      published: None,
-      updated: None,
-      banned: None,
-      deleted: None,
       actor_id: Some(actor_id.clone()),
-      bio: None,
-      local: Some(true),
       private_key: Some(Some(actor_keypair.private_key)),
       public_key: Some(Some(actor_keypair.public_key)),
-      last_refreshed_at: None,
       inbox_url: Some(generate_inbox_url(&actor_id)?),
       shared_inbox_url: Some(Some(generate_shared_inbox_url(&actor_id)?)),
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     // insert the person
@@ -285,22 +275,14 @@ impl Perform for Register {
           name: default_community_name.to_string(),
           title: "The Default Community".to_string(),
           description: Some("The Default Community".to_string()),
-          nsfw: false,
           creator_id: inserted_person.id,
-          removed: None,
-          deleted: None,
-          updated: None,
           actor_id: Some(actor_id.to_owned()),
-          local: true,
           private_key: Some(main_community_keypair.private_key),
           public_key: Some(main_community_keypair.public_key),
-          last_refreshed_at: None,
-          published: None,
-          icon: None,
-          banner: None,
           followers_url: Some(generate_followers_url(&actor_id)?),
           inbox_url: Some(generate_inbox_url(&actor_id)?),
           shared_inbox_url: Some(Some(generate_shared_inbox_url(&actor_id)?)),
+          ..CommunityForm::default()
         };
         blocking(context.pool(), move |conn| {
           Community::create(conn, &community_form)
@@ -1101,12 +1083,7 @@ impl Perform for CreatePrivateMessage {
       content: content_slurs_removed.to_owned(),
       creator_id: local_user_view.person.id,
       recipient_id: data.recipient_id,
-      deleted: None,
-      read: None,
-      updated: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PrivateMessageForm::default()
     };
 
     let inserted_private_message = match blocking(context.pool(), move |conn| {
index 9911f6722c551c701a1e487156eaccf00ed55b68..48153a86b9d8a5455d2be9c95abd2911c9d38613 100644 (file)
@@ -82,19 +82,12 @@ impl Perform for CreatePost {
       body: data.body.to_owned(),
       community_id: data.community_id,
       creator_id: local_user_view.person.id,
-      removed: None,
-      deleted: None,
       nsfw: data.nsfw,
-      locked: None,
-      stickied: None,
-      updated: None,
       embed_title: iframely_title,
       embed_description: iframely_description,
       embed_html: iframely_html,
       thumbnail_url: pictrs_thumbnail.map(|u| u.into()),
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post =
@@ -399,24 +392,18 @@ impl Perform for EditPost {
       fetch_iframely_and_pictrs_data(context.client(), data_url).await;
 
     let post_form = PostForm {
+      creator_id: orig_post.creator_id.to_owned(),
+      community_id: orig_post.community_id,
       name: data.name.trim().to_owned(),
       url: data_url.map(|u| u.to_owned().into()),
       body: data.body.to_owned(),
       nsfw: data.nsfw,
-      creator_id: orig_post.creator_id.to_owned(),
-      community_id: orig_post.community_id,
-      removed: Some(orig_post.removed),
-      deleted: Some(orig_post.deleted),
-      locked: Some(orig_post.locked),
-      stickied: Some(orig_post.stickied),
       updated: Some(naive_now()),
       embed_title: iframely_title,
       embed_description: iframely_description,
       embed_html: iframely_html,
       thumbnail_url: pictrs_thumbnail.map(|u| u.into()),
-      ap_id: Some(orig_post.ap_id),
-      local: orig_post.local,
-      published: None,
+      ..PostForm::default()
     };
 
     let post_id = data.post_id;
index bd0e129dc7f9b8374166b6fe6857a0d4521ba990..a034404471f0556cf3d4e838051cd2efe8daeec9 100644 (file)
@@ -28,7 +28,7 @@ pub struct CreateCommunity {
   pub description: Option<String>,
   pub icon: Option<String>,
   pub banner: Option<String>,
-  pub nsfw: bool,
+  pub nsfw: Option<bool>,
   pub auth: String,
 }
 
@@ -88,7 +88,7 @@ pub struct EditCommunity {
   pub description: Option<String>,
   pub icon: Option<String>,
   pub banner: Option<String>,
-  pub nsfw: bool,
+  pub nsfw: Option<bool>,
   pub auth: String,
 }
 
index cc1d9f0364b7a50c850e9c01f7d5e11aef94f7bb..b09d4f42d07872399f6ec92d165dfc63c7332383 100644 (file)
@@ -181,7 +181,7 @@ impl FromApubToForm<NoteExt> for CommentForm {
       updated: note.updated().map(|u| u.to_owned().naive_local()),
       deleted: None,
       ap_id: Some(check_object_domain(note, expected_domain)?),
-      local: false,
+      local: Some(false),
     })
   }
 }
index 936938130fc3ad5341a8db3f26a417ce720d038d..a4c0d6c34d81f7e2e46eeea2f70822a48f53872d 100644 (file)
@@ -205,9 +205,9 @@ impl FromApubToForm<GroupExt> for CommunityForm {
       published: group.inner.published().map(|u| u.to_owned().naive_local()),
       updated: group.inner.updated().map(|u| u.to_owned().naive_local()),
       deleted: None,
-      nsfw: group.ext_one.sensitive.unwrap_or(false),
+      nsfw: Some(group.ext_one.sensitive.unwrap_or(false)),
       actor_id: Some(check_object_domain(group, expected_domain)?),
-      local: false,
+      local: Some(false),
       private_key: None,
       public_key: Some(group.ext_two.to_owned().public_key.public_key_pem),
       last_refreshed_at: Some(naive_now()),
index 776946cbdceec6afae927ad85c8a6990f17cd037..8f01218a90e945ff2899a5c533aa290816c19dcd 100644 (file)
@@ -217,7 +217,7 @@ impl FromApubToForm<PageExt> for PostForm {
       embed_html: iframely_html,
       thumbnail_url: pictrs_thumbnail.map(|u| u.into()),
       ap_id: Some(check_object_domain(page, expected_domain)?),
-      local: false,
+      local: Some(false),
     })
   }
 }
index d8c0077cf50ce48c8dafa8f83fdf4d18810f3339..b332446f577cd379faf768be9ecd476fcc213c96 100644 (file)
@@ -121,7 +121,7 @@ impl FromApubToForm<NoteExt> for PrivateMessageForm {
       deleted: None,
       read: None,
       ap_id: Some(check_object_domain(note, expected_domain)?),
-      local: false,
+      local: Some(false),
     })
   }
 }
index d3e925244413d337cc90888094e7518c7e5ce3e5..a2bea11efaf325f1e66430e93c2dbe608ccef242 100644 (file)
@@ -44,44 +44,14 @@ mod tests {
 
     let new_person = PersonForm {
       name: "thommy_comment_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
 
     let another_person = PersonForm {
       name: "jerry_comment_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let another_inserted_person = Person::create(&conn, &another_person).unwrap();
@@ -90,45 +60,16 @@ mod tests {
       name: "TIL_comment_agg".into(),
       creator_id: inserted_person.id,
       title: "nada".to_owned(),
-      description: None,
-      nsfw: false,
-      removed: None,
-      deleted: None,
-      updated: None,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
 
     let new_post = PostForm {
       name: "A test post".into(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      nsfw: false,
-      updated: None,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -137,14 +78,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
@@ -153,14 +87,8 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
       parent_id: Some(inserted_comment.id),
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
index ad90f20f62f2c12b83e7c1484aeed7da4a6074d0..25c0b394e22024b81c49d736bfdd494bde9728bc 100644 (file)
@@ -48,44 +48,14 @@ mod tests {
 
     let new_person = PersonForm {
       name: "thommy_community_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
 
     let another_person = PersonForm {
       name: "jerry_community_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let another_inserted_person = Person::create(&conn, &another_person).unwrap();
@@ -94,22 +64,7 @@ mod tests {
       name: "TIL_community_agg".into(),
       creator_id: inserted_person.id,
       title: "nada".to_owned(),
-      description: None,
-      nsfw: false,
-      removed: None,
-      deleted: None,
-      updated: None,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
@@ -118,22 +73,7 @@ mod tests {
       name: "TIL_community_agg_2".into(),
       creator_id: inserted_person.id,
       title: "nada".to_owned(),
-      description: None,
-      nsfw: false,
-      removed: None,
-      deleted: None,
-      updated: None,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let another_inserted_community = Community::create(&conn, &another_community).unwrap();
@@ -164,23 +104,9 @@ mod tests {
 
     let new_post = PostForm {
       name: "A test post".into(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      nsfw: false,
-      updated: None,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -189,14 +115,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
@@ -205,14 +124,8 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
       parent_id: Some(inserted_comment.id),
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
index f6a6cd1ba46aad11f85ec8fd768bf3258b0e1180..953f74ee7f3f7f3158e4e7a3fb530c13af4c4608 100644 (file)
@@ -44,44 +44,14 @@ mod tests {
 
     let new_person = PersonForm {
       name: "thommy_user_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
 
     let another_person = PersonForm {
       name: "jerry_user_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let another_inserted_person = Person::create(&conn, &another_person).unwrap();
@@ -90,45 +60,16 @@ mod tests {
       name: "TIL_site_agg".into(),
       creator_id: inserted_person.id,
       title: "nada".to_owned(),
-      description: None,
-      nsfw: false,
-      removed: None,
-      deleted: None,
-      updated: None,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
 
     let new_post = PostForm {
       name: "A test post".into(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      nsfw: false,
-      updated: None,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -145,14 +86,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
@@ -170,14 +104,8 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
       parent_id: Some(inserted_comment.id),
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
index a32b9da66e19ad95c23acbf58d69b368c1fe2e79..fe73813167f1adc4d950d89a4e5a7bdbe30e59ef 100644 (file)
@@ -48,44 +48,14 @@ mod tests {
 
     let new_person = PersonForm {
       name: "thommy_community_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
 
     let another_person = PersonForm {
       name: "jerry_community_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let another_inserted_person = Person::create(&conn, &another_person).unwrap();
@@ -94,45 +64,16 @@ mod tests {
       name: "TIL_community_agg".into(),
       creator_id: inserted_person.id,
       title: "nada".to_owned(),
-      description: None,
-      nsfw: false,
-      removed: None,
-      deleted: None,
-      updated: None,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
 
     let new_post = PostForm {
       name: "A test post".into(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      nsfw: false,
-      updated: None,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -141,14 +82,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
@@ -157,14 +91,8 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
       parent_id: Some(inserted_comment.id),
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
index 67cb04a7e709cb2501b18c30e913b4e155f889db..64fbdf7df404e5d850958cbd59053f1013abef3a 100644 (file)
@@ -42,22 +42,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: "thommy_site_agg".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -80,45 +65,16 @@ mod tests {
       name: "TIL_site_agg".into(),
       creator_id: inserted_person.id,
       title: "nada".to_owned(),
-      description: None,
-      nsfw: false,
-      removed: None,
-      deleted: None,
-      updated: None,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
 
     let new_post = PostForm {
       name: "A test post".into(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      nsfw: false,
-      updated: None,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     // Insert two of those posts
@@ -129,14 +85,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     // Insert two of those comments
@@ -146,14 +95,8 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
       parent_id: Some(inserted_comment.id),
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
index 5d345db691c10bb667d37b93feff8980d8db3d0b..d1fc0622f90a1f389f047571d8d87a7cc930ce1d 100644 (file)
@@ -74,7 +74,7 @@ impl Activity_ for Activity {
     let activity_form = ActivityForm {
       ap_id,
       data: serde_json::to_value(&data)?,
-      local,
+      local: Some(local),
       sensitive,
       updated: None,
     };
@@ -138,22 +138,7 @@ mod tests {
 
     let creator_form = PersonForm {
       name: "activity_creator_pm".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_creator = Person::create(&conn, &creator_form).unwrap();
@@ -180,7 +165,7 @@ mod tests {
     let activity_form = ActivityForm {
       ap_id: ap_id.clone(),
       data: test_json.to_owned(),
-      local: true,
+      local: Some(true),
       sensitive: false,
       updated: None,
     };
index 47965d3b449f842f315f4bd3b2912b7a010fa43e..8d77626aa70c6a5d4703f235698451d814ea4465 100644 (file)
@@ -246,22 +246,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: "terry".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -269,23 +254,8 @@ mod tests {
     let new_community = CommunityForm {
       name: "test community".to_string(),
       title: "nada".to_owned(),
-      description: None,
       creator_id: inserted_person.id,
-      removed: None,
-      deleted: None,
-      updated: None,
-      nsfw: false,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      banner: None,
-      icon: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      followers_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
@@ -293,22 +263,8 @@ mod tests {
     let new_post = PostForm {
       name: "A test post".into(),
       creator_id: inserted_person.id,
-      url: None,
-      body: None,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      updated: None,
-      nsfw: false,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -317,14 +273,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
@@ -349,13 +298,7 @@ mod tests {
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
       parent_id: Some(inserted_comment.id),
-      removed: None,
-      deleted: None,
-      read: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
index a0038c9d35648cbc7861b7b09b1b4edb4c3d024c..1970eef88babe398b77458f9d50fb99baf9ae286 100644 (file)
@@ -356,22 +356,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: "bobbee".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -380,22 +365,7 @@ mod tests {
       name: "TIL".into(),
       creator_id: inserted_person.id,
       title: "nada".to_owned(),
-      description: None,
-      nsfw: false,
-      removed: None,
-      deleted: None,
-      updated: None,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
index 3b6d25445f1a1aa41dd7e56b50981681fadd5f45..c641fffc74fd9b0880ac8d6394eec95e467b2915 100644 (file)
@@ -209,44 +209,14 @@ mod tests {
 
     let new_mod = PersonForm {
       name: "the mod".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_mod = Person::create(&conn, &new_mod).unwrap();
 
     let new_person = PersonForm {
       name: "jim2".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -254,46 +224,17 @@ mod tests {
     let new_community = CommunityForm {
       name: "mod_community".to_string(),
       title: "nada".to_owned(),
-      description: None,
       creator_id: inserted_person.id,
-      removed: None,
-      deleted: None,
-      updated: None,
-      nsfw: false,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
 
     let new_post = PostForm {
       name: "A test post thweep".into(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      updated: None,
-      nsfw: false,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -302,14 +243,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
index 654dabf6504a1c4d5aa83220a0e97b616c342ebf..6fe4ee3a5b645e29a8c46879d4367457d19ebd40 100644 (file)
@@ -95,22 +95,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: "thommy prw".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -118,15 +103,7 @@ mod tests {
     let new_local_user = LocalUserForm {
       person_id: inserted_person.id,
       password_encrypted: "pass".to_string(),
-      email: None,
-      admin: None,
-      show_nsfw: None,
-      theme: None,
-      default_sort_type: None,
-      default_listing_type: None,
-      lang: None,
-      show_avatars: None,
-      send_notifications_to_email: None,
+      ..LocalUserForm::default()
     };
 
     let inserted_local_user = LocalUser::create(&conn, &new_local_user).unwrap();
index 40adab3dfcb939392c1e36861d7a90ed85d5fd66..6d5ad9b4d34581a46e29ee589b373504cfcc1ebe 100644 (file)
@@ -243,22 +243,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: "holly".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
index a6a86e78857e98bdc6355bec3c72e1c1355db1fa..5a3a7ea61dcca9d418a317a360203130180feb7a 100644 (file)
@@ -90,44 +90,14 @@ mod tests {
 
     let new_person = PersonForm {
       name: "terrylake".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
 
     let recipient_form = PersonForm {
       name: "terrylakes recipient".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_recipient = Person::create(&conn, &recipient_form).unwrap();
@@ -135,23 +105,8 @@ mod tests {
     let new_community = CommunityForm {
       name: "test community lake".to_string(),
       title: "nada".to_owned(),
-      description: None,
       creator_id: inserted_person.id,
-      removed: None,
-      deleted: None,
-      updated: None,
-      nsfw: false,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
@@ -159,22 +114,8 @@ mod tests {
     let new_post = PostForm {
       name: "A test post".into(),
       creator_id: inserted_person.id,
-      url: None,
-      body: None,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      updated: None,
-      nsfw: false,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -183,14 +124,7 @@ mod tests {
       content: "A test comment".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      removed: None,
-      deleted: None,
-      read: None,
-      parent_id: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
index b1f6b7c2b024e67c876fafbb2b5ec836b4716c55..169ca18ef51c8ab062ee735bdafdfd0c11f7873d 100644 (file)
@@ -273,22 +273,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: "jim".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -296,46 +281,17 @@ mod tests {
     let new_community = CommunityForm {
       name: "test community_3".to_string(),
       title: "nada".to_owned(),
-      description: None,
       creator_id: inserted_person.id,
-      removed: None,
-      deleted: None,
-      updated: None,
-      nsfw: false,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
 
     let new_post = PostForm {
       name: "A test post".into(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      nsfw: false,
-      updated: None,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
index cd663093c7c560b95f4c08c170caf75eb590cffc..98c8e08ce4c644a13232b9889d3160f9afbd2b8b 100644 (file)
@@ -150,44 +150,14 @@ mod tests {
 
     let creator_form = PersonForm {
       name: "creator_pm".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_creator = Person::create(&conn, &creator_form).unwrap();
 
     let recipient_form = PersonForm {
       name: "recipient_pm".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_recipient = Person::create(&conn, &recipient_form).unwrap();
@@ -196,12 +166,7 @@ mod tests {
       content: "A test private message".into(),
       creator_id: inserted_creator.id,
       recipient_id: inserted_recipient.id,
-      deleted: None,
-      read: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..PrivateMessageForm::default()
     };
 
     let inserted_private_message = PrivateMessage::create(&conn, &private_message_form).unwrap();
index 6b07e5cee5b66dec139aca1c2a4d87b9efc7db58..4efa983fe4365696662ed23ea07fbbd8ed2f70af 100644 (file)
@@ -22,7 +22,9 @@ use url::Url;
 pub mod schema;
 pub mod source;
 
-#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
+#[derive(
+  Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize, DieselNewType,
+)]
 pub struct PostId(pub i32);
 
 impl fmt::Display for PostId {
@@ -31,7 +33,9 @@ impl fmt::Display for PostId {
   }
 }
 
-#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
+#[derive(
+  Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize, DieselNewType,
+)]
 pub struct PersonId(pub i32);
 
 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
@@ -43,7 +47,9 @@ impl fmt::Display for CommentId {
   }
 }
 
-#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
+#[derive(
+  Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize, DieselNewType,
+)]
 pub struct CommunityId(pub i32);
 
 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
index 7b7f4aba391ef44fe39fa24b9855475e3236a077..ced8f3be49c95a87e7119515db4cece71b5fbe64 100644 (file)
@@ -18,7 +18,7 @@ pub struct Activity {
 #[table_name = "activity"]
 pub struct ActivityForm {
   pub data: Value,
-  pub local: bool,
+  pub local: Option<bool>,
   pub updated: Option<chrono::NaiveDateTime>,
   pub ap_id: DbUrl,
   pub sensitive: bool,
index 8a91f601ec7c4340acf4e64f41f2339305c50cbe..fba61f4632de84b46043c4369fe0576d3dc02348 100644 (file)
@@ -51,7 +51,7 @@ pub struct CommentAlias1 {
   pub local: bool,
 }
 
-#[derive(Insertable, AsChangeset, Clone)]
+#[derive(Insertable, AsChangeset, Clone, Default)]
 #[table_name = "comment"]
 pub struct CommentForm {
   pub creator_id: PersonId,
@@ -64,7 +64,7 @@ pub struct CommentForm {
   pub updated: Option<chrono::NaiveDateTime>,
   pub deleted: Option<bool>,
   pub ap_id: Option<DbUrl>,
-  pub local: bool,
+  pub local: Option<bool>,
 }
 
 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug, Clone)]
index 81789ecdfd38598de4f9de291b975849da7111d8..4275102709c19e098314794c71c98c144fe8baa9 100644 (file)
@@ -51,7 +51,7 @@ pub struct CommunitySafe {
   pub banner: Option<DbUrl>,
 }
 
-#[derive(Insertable, AsChangeset, Debug)]
+#[derive(Insertable, AsChangeset, Debug, Default)]
 #[table_name = "community"]
 pub struct CommunityForm {
   pub name: String,
@@ -62,9 +62,9 @@ pub struct CommunityForm {
   pub published: Option<chrono::NaiveDateTime>,
   pub updated: Option<chrono::NaiveDateTime>,
   pub deleted: Option<bool>,
-  pub nsfw: bool,
+  pub nsfw: Option<bool>,
   pub actor_id: Option<DbUrl>,
-  pub local: bool,
+  pub local: Option<bool>,
   pub private_key: Option<String>,
   pub public_key: Option<String>,
   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
index d902e6b4d107c460e2162c8c0a9786579259b145..2f4a9fc2b40f24f538ed59af2262aac9d6935616 100644 (file)
@@ -20,7 +20,7 @@ pub struct LocalUser {
 }
 
 // TODO redo these, check table defaults
-#[derive(Insertable, AsChangeset, Clone)]
+#[derive(Insertable, AsChangeset, Clone, Default)]
 #[table_name = "local_user"]
 pub struct LocalUserForm {
   pub person_id: PersonId,
index 8c66b1a8e54252b53361d8c2765f636f3d026ff9..f5f10ac46284be4b50ce94dc85fd31b4da1b715f 100644 (file)
@@ -135,7 +135,7 @@ pub struct PersonSafeAlias2 {
   pub matrix_user_id: Option<String>,
 }
 
-#[derive(Insertable, AsChangeset, Clone)]
+#[derive(Insertable, AsChangeset, Clone, Default)]
 #[table_name = "person"]
 pub struct PersonForm {
   pub name: String,
index 34b889d4629987da0a2484085c4b22621e3db36e..87681e010eaf5eb7fd5ebda7e6a200552f38f081 100644 (file)
@@ -31,7 +31,7 @@ pub struct Post {
   pub local: bool,
 }
 
-#[derive(Insertable, AsChangeset)]
+#[derive(Insertable, AsChangeset, Default)]
 #[table_name = "post"]
 pub struct PostForm {
   pub name: String,
@@ -51,7 +51,7 @@ pub struct PostForm {
   pub embed_html: Option<String>,
   pub thumbnail_url: Option<DbUrl>,
   pub ap_id: Option<DbUrl>,
-  pub local: bool,
+  pub local: Option<bool>,
 }
 
 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
index 6d46c012994c03b1ee5b3819c336153dde596de4..6710c2dcfde75ec7d50d9ededbbce73371eeef7e 100644 (file)
@@ -16,7 +16,7 @@ pub struct PrivateMessage {
   pub local: bool,
 }
 
-#[derive(Insertable, AsChangeset)]
+#[derive(Insertable, AsChangeset, Default)]
 #[table_name = "private_message"]
 pub struct PrivateMessageForm {
   pub creator_id: PersonId,
@@ -27,5 +27,5 @@ pub struct PrivateMessageForm {
   pub published: Option<chrono::NaiveDateTime>,
   pub updated: Option<chrono::NaiveDateTime>,
   pub ap_id: Option<DbUrl>,
-  pub local: bool,
+  pub local: Option<bool>,
 }
index 478a906f25bf5c8b6a50e268997a3edc7d2d8a17..e44ddfef3043789a18299c788918a5db30fe97e5 100644 (file)
@@ -454,22 +454,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: "timmy".into(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -477,23 +462,8 @@ mod tests {
     let new_community = CommunityForm {
       name: "test community 5".to_string(),
       title: "nada".to_owned(),
-      description: None,
       creator_id: inserted_person.id,
-      removed: None,
-      deleted: None,
-      updated: None,
-      nsfw: false,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
@@ -501,22 +471,8 @@ mod tests {
     let new_post = PostForm {
       name: "A test post 2".into(),
       creator_id: inserted_person.id,
-      url: None,
-      body: None,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      updated: None,
-      nsfw: false,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
@@ -525,14 +481,7 @@ mod tests {
       content: "A test comment 32".into(),
       creator_id: inserted_person.id,
       post_id: inserted_post.id,
-      parent_id: None,
-      removed: None,
-      deleted: None,
-      read: None,
-      published: None,
-      updated: None,
-      ap_id: None,
-      local: true,
+      ..CommentForm::default()
     };
 
     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
index 08d889d18f5e18c896f4dfc5826ff57b18f25088..8e305b486a671a1cd9f37aaf9fe7dd9a05dfde62 100644 (file)
@@ -454,22 +454,7 @@ mod tests {
 
     let new_person = PersonForm {
       name: person_name.to_owned(),
-      preferred_username: None,
-      avatar: None,
-      banner: None,
-      banned: None,
-      deleted: None,
-      published: None,
-      updated: None,
-      actor_id: None,
-      bio: None,
-      local: None,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
@@ -477,46 +462,17 @@ mod tests {
     let new_community = CommunityForm {
       name: community_name.to_owned(),
       title: "nada".to_owned(),
-      description: None,
       creator_id: inserted_person.id,
-      removed: None,
-      deleted: None,
-      updated: None,
-      nsfw: false,
-      actor_id: None,
-      local: true,
-      private_key: None,
-      public_key: None,
-      last_refreshed_at: None,
-      published: None,
-      icon: None,
-      banner: None,
-      followers_url: None,
-      inbox_url: None,
-      shared_inbox_url: None,
+      ..CommunityForm::default()
     };
 
     let inserted_community = Community::create(&conn, &new_community).unwrap();
 
     let new_post = PostForm {
       name: post_name.to_owned(),
-      url: None,
-      body: None,
       creator_id: inserted_person.id,
       community_id: inserted_community.id,
-      removed: None,
-      deleted: None,
-      locked: None,
-      stickied: None,
-      updated: None,
-      nsfw: false,
-      embed_title: None,
-      embed_description: None,
-      embed_html: None,
-      thumbnail_url: None,
-      ap_id: None,
-      local: true,
-      published: None,
+      ..PostForm::default()
     };
 
     let inserted_post = Post::create(&conn, &new_post).unwrap();
index e9b43356a769eae4359aa752db2e2d8166b13ae2..144c39f872563f69e3731a920c65b45f6ecc535e 100644 (file)
@@ -55,22 +55,11 @@ fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
 
     let form = PersonForm {
       name: cperson.name.to_owned(),
-      avatar: None,
-      banner: None,
-      preferred_username: None,
-      published: None,
-      updated: None,
-      banned: None,
-      deleted: None,
       actor_id: Some(generate_apub_endpoint(EndpointType::Person, &cperson.name)?),
-      bio: None,
-      local: None,
       private_key: Some(Some(keypair.private_key)),
       public_key: Some(Some(keypair.public_key)),
       last_refreshed_at: Some(naive_now()),
-      inbox_url: None,
-      shared_inbox_url: None,
-      matrix_user_id: None,
+      ..PersonForm::default()
     };
 
     Person::update(&conn, cperson.id, &form)?;
@@ -103,10 +92,10 @@ fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
       creator_id: ccommunity.creator_id,
       removed: None,
       deleted: None,
-      nsfw: ccommunity.nsfw,
+      nsfw: None,
       updated: None,
       actor_id: Some(community_actor_id.to_owned()),
-      local: ccommunity.local,
+      local: Some(ccommunity.local),
       private_key: Some(keypair.private_key),
       public_key: Some(keypair.public_key),
       last_refreshed_at: Some(naive_now()),