Replace TypedBuilder with Default in update forms (#3814)
authordullbananas <dull.bananas0@gmail.com>
Tue, 8 Aug 2023 09:41:41 +0000 (02:41 -0700)
committerGitHub <noreply@github.com>
Tue, 8 Aug 2023 09:41:41 +0000 (11:41 +0200)
* Update comment.rs

* Update community.rs

* Update local_site.rs

* Update local_site_rate_limit.rs

* Update local_user.rs

* Update person.rs

* Update comment.rs

* Update community.rs

* Update local_site.rs

* Update local_site_rate_limit.rs

* Update local_user.rs

* Update post.rs

* Update private_message.rs

* Update site.rs

* Update post.rs

* Update person.rs

* Update private_message.rs

* Update comment.rs

* Update create.rs

* Update leave_admin.rs

* Update update.rs

* Update remove.rs

* Update add_admin.rs

* Update verify_email.rs

* Update mod.rs

* Update mod.rs

* Update undo_delete.rs

* Update undo_delete.rs

* Update utils.rs

* Update feature.rs

* Update delete.rs

* Update lock.rs

* Update create.rs

* Update approve.rs

* Update update.rs

* Update lock_page.rs

* Update block_user.rs

* Update delete.rs

* Update undo_block_user.rs

* Update collection_remove.rs

* Update post.rs

* Update hide.rs

* Update person.rs

* Update remove.rs

* Update post_view.rs

* Update create.rs

* Update remove.rs

* Update collection_add.rs

* Update community.rs

* Update update.rs

* Update post_aggregates.rs

* Update update.rs

* Update comment.rs

* Update code_migrations.rs

* Update registration_application_view.rs

* Update update.rs

* Update ban_person.rs

* Update community.rs

* Update delete.rs

* Update delete.rs

* Update delete.rs

* Update person_aggregates.rs

* Update save_settings.rs

* Update distinguish.rs

* Update mark_read.rs

* Update site_aggregates.rs

* Update create.rs

* Fix

* rerun ci

* Update comment.rs

* rerun ci

* Update create.rs

* Update create.rs

* Update post_view.rs

* rerun ci

* Update undo_delete.rs

* rerun ci

60 files changed:
crates/api/src/comment/distinguish.rs
crates/api/src/community/hide.rs
crates/api/src/local_user/add_admin.rs
crates/api/src/local_user/ban_person.rs
crates/api/src/local_user/save_settings.rs
crates/api/src/local_user/verify_email.rs
crates/api/src/post/feature.rs
crates/api/src/post/lock.rs
crates/api/src/private_message/mark_read.rs
crates/api/src/site/leave_admin.rs
crates/api/src/site/registration_applications/approve.rs
crates/api_common/src/utils.rs
crates/api_crud/src/comment/create.rs
crates/api_crud/src/comment/delete.rs
crates/api_crud/src/comment/remove.rs
crates/api_crud/src/comment/update.rs
crates/api_crud/src/community/delete.rs
crates/api_crud/src/community/remove.rs
crates/api_crud/src/community/update.rs
crates/api_crud/src/post/create.rs
crates/api_crud/src/post/delete.rs
crates/api_crud/src/post/remove.rs
crates/api_crud/src/post/update.rs
crates/api_crud/src/private_message/create.rs
crates/api_crud/src/private_message/delete.rs
crates/api_crud/src/private_message/update.rs
crates/api_crud/src/site/create.rs
crates/api_crud/src/site/update.rs
crates/apub/src/activities/block/block_user.rs
crates/apub/src/activities/block/undo_block_user.rs
crates/apub/src/activities/community/collection_add.rs
crates/apub/src/activities/community/collection_remove.rs
crates/apub/src/activities/community/lock_page.rs
crates/apub/src/activities/deletion/delete.rs
crates/apub/src/activities/deletion/mod.rs
crates/apub/src/activities/deletion/undo_delete.rs
crates/apub/src/objects/comment.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/person.rs
crates/apub/src/objects/post.rs
crates/db_schema/src/aggregates/person_aggregates.rs
crates/db_schema/src/aggregates/post_aggregates.rs
crates/db_schema/src/aggregates/site_aggregates.rs
crates/db_schema/src/impls/comment.rs
crates/db_schema/src/impls/community.rs
crates/db_schema/src/impls/person.rs
crates/db_schema/src/impls/post.rs
crates/db_schema/src/impls/private_message.rs
crates/db_schema/src/source/comment.rs
crates/db_schema/src/source/community.rs
crates/db_schema/src/source/local_site.rs
crates/db_schema/src/source/local_site_rate_limit.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_schema/src/source/site.rs
crates/db_views/src/post_view.rs
crates/db_views/src/registration_application_view.rs
src/code_migrations.rs

index 367ffcbf7c5af69bcb91794e320c715f95ede71c..7db9a58f8df260ee76f0180f30a2dd5715c735aa 100644 (file)
@@ -38,9 +38,10 @@ pub async fn distinguish_comment(
 
   // Update the Comment
   let comment_id = data.comment_id;
-  let form = CommentUpdateForm::builder()
-    .distinguished(Some(data.distinguished))
-    .build();
+  let form = CommentUpdateForm {
+    distinguished: Some(data.distinguished),
+    ..Default::default()
+  };
   Comment::update(&mut context.pool(), comment_id, &form)
     .await
     .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
index ce437ad99d55de6405d530520fa1db30d896401d..10ca6372a06261c4d1526e7a83e60ae7b70d8f53 100644 (file)
@@ -25,9 +25,10 @@ pub async fn hide_community(
   let local_user_view = local_user_view_from_jwt(&data.auth, &context).await?;
   is_admin(&local_user_view)?;
 
-  let community_form = CommunityUpdateForm::builder()
-    .hidden(Some(data.hidden))
-    .build();
+  let community_form = CommunityUpdateForm {
+    hidden: Some(data.hidden),
+    ..Default::default()
+  };
 
   let mod_hide_community_form = ModHideCommunityForm {
     community_id: data.community_id,
index 0b478ea92c4880110f54465952ce381c4d9f7939..81ec588f0e54053f2fe457a987944fce585b6b84 100644 (file)
@@ -32,7 +32,10 @@ impl Perform for AddAdmin {
     let added_admin = Person::update(
       &mut context.pool(),
       added_person_id,
-      &PersonUpdateForm::builder().admin(Some(added)).build(),
+      &PersonUpdateForm {
+        admin: Some(added),
+        ..Default::default()
+      },
     )
     .await
     .with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?;
index 6e99ef25082646efc67b567a3ef65e49f596abb2..490a514488403e3f3320e856e1c31ea671c6d64d 100644 (file)
@@ -35,10 +35,11 @@ pub async fn ban_from_site(
   let person = Person::update(
     &mut context.pool(),
     data.person_id,
-    &PersonUpdateForm::builder()
-      .banned(Some(data.ban))
-      .ban_expires(Some(expires))
-      .build(),
+    &PersonUpdateForm {
+      banned: Some(data.ban),
+      ban_expires: Some(expires),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?;
index 152c11ad12e1e9c6c0840bb82603ad905d1a1369..946b5e8b64b5e3917f6d30a500c829ebcac26e39 100644 (file)
@@ -90,14 +90,15 @@ impl Perform for SaveUserSettings {
     let default_sort_type = data.default_sort_type;
     let theme = sanitize_html_opt(&data.theme);
 
-    let person_form = PersonUpdateForm::builder()
-      .display_name(display_name)
-      .bio(bio)
-      .matrix_user_id(matrix_user_id)
-      .bot_account(data.bot_account)
-      .avatar(avatar)
-      .banner(banner)
-      .build();
+    let person_form = PersonUpdateForm {
+      display_name,
+      bio,
+      matrix_user_id,
+      bot_account: data.bot_account,
+      avatar,
+      banner,
+      ..Default::default()
+    };
 
     Person::update(&mut context.pool(), person_id, &person_form)
       .await
@@ -121,26 +122,27 @@ impl Perform for SaveUserSettings {
       (None, None)
     };
 
-    let local_user_form = LocalUserUpdateForm::builder()
-      .email(email)
-      .show_avatars(data.show_avatars)
-      .show_read_posts(data.show_read_posts)
-      .show_new_post_notifs(data.show_new_post_notifs)
-      .send_notifications_to_email(data.send_notifications_to_email)
-      .show_nsfw(data.show_nsfw)
-      .blur_nsfw(data.blur_nsfw)
-      .auto_expand(data.auto_expand)
-      .show_bot_accounts(data.show_bot_accounts)
-      .show_scores(data.show_scores)
-      .default_sort_type(default_sort_type)
-      .default_listing_type(default_listing_type)
-      .theme(theme)
-      .interface_language(data.interface_language.clone())
-      .totp_2fa_secret(totp_2fa_secret)
-      .totp_2fa_url(totp_2fa_url)
-      .open_links_in_new_tab(data.open_links_in_new_tab)
-      .infinite_scroll_enabled(data.infinite_scroll_enabled)
-      .build();
+    let local_user_form = LocalUserUpdateForm {
+      email,
+      show_avatars: data.show_avatars,
+      show_read_posts: data.show_read_posts,
+      show_new_post_notifs: data.show_new_post_notifs,
+      send_notifications_to_email: data.send_notifications_to_email,
+      show_nsfw: data.show_nsfw,
+      blur_nsfw: data.blur_nsfw,
+      auto_expand: data.auto_expand,
+      show_bot_accounts: data.show_bot_accounts,
+      show_scores: data.show_scores,
+      default_sort_type,
+      default_listing_type,
+      theme,
+      interface_language: data.interface_language.clone(),
+      totp_2fa_secret,
+      totp_2fa_url,
+      open_links_in_new_tab: data.open_links_in_new_tab,
+      infinite_scroll_enabled: data.infinite_scroll_enabled,
+      ..Default::default()
+    };
 
     let local_user_res =
       LocalUser::update(&mut context.pool(), local_user_id, &local_user_form).await;
index a0c4763a6e03ff503c34ef28808994856f1e4796..a15743ea4738d548db39a07d1323394d4a35a67f 100644 (file)
@@ -23,12 +23,13 @@ impl Perform for VerifyEmail {
       .await
       .with_lemmy_type(LemmyErrorType::TokenNotFound)?;
 
-    let form = LocalUserUpdateForm::builder()
+    let form = LocalUserUpdateForm {
       // necessary in case this is a new signup
-      .email_verified(Some(true))
+      email_verified: Some(true),
       // necessary in case email of an existing user was changed
-      .email(Some(Some(verification.email)))
-      .build();
+      email: Some(Some(verification.email)),
+      ..Default::default()
+    };
     let local_user_id = verification.local_user_id;
 
     LocalUser::update(&mut context.pool(), local_user_id, &form).await?;
index 5e18c2b64ce910cf6cb3217270451872f03937ee..02b9551a9493a25bcc9c0ffb23fa07eb8a040be5 100644 (file)
@@ -56,13 +56,15 @@ pub async fn feature_post(
   // Update the post
   let post_id = data.post_id;
   let new_post: PostUpdateForm = if data.feature_type == PostFeatureType::Community {
-    PostUpdateForm::builder()
-      .featured_community(Some(data.featured))
-      .build()
+    PostUpdateForm {
+      featured_community: Some(data.featured),
+      ..Default::default()
+    }
   } else {
-    PostUpdateForm::builder()
-      .featured_local(Some(data.featured))
-      .build()
+    PostUpdateForm {
+      featured_local: Some(data.featured),
+      ..Default::default()
+    }
   };
   let post = Post::update(&mut context.pool(), post_id, &new_post).await?;
 
index 45ec3317f4a53adf9912fcc100bcc10621a53800..b2ba9b3d12b2be5ba7ebc8b1876bb772676440a3 100644 (file)
@@ -53,7 +53,10 @@ pub async fn lock_post(
   let post = Post::update(
     &mut context.pool(),
     post_id,
-    &PostUpdateForm::builder().locked(Some(locked)).build(),
+    &PostUpdateForm {
+      locked: Some(locked),
+      ..Default::default()
+    },
   )
   .await?;
 
index cca37fde4f2ae1486b44104e82d8f01a60210f86..54fb4790c91589ee08a7aa885ed9105a77c33409 100644 (file)
@@ -38,7 +38,10 @@ impl Perform for MarkPrivateMessageAsRead {
     PrivateMessage::update(
       &mut context.pool(),
       private_message_id,
-      &PrivateMessageUpdateForm::builder().read(Some(read)).build(),
+      &PrivateMessageUpdateForm {
+        read: Some(read),
+        ..Default::default()
+      },
     )
     .await
     .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?;
index 3781c73f2f30fd35179c519a38e3d62a6aa53cb3..570f9d52c3f21c67d6320a0686d39a3f8effc53f 100644 (file)
@@ -43,7 +43,10 @@ impl Perform for LeaveAdmin {
     Person::update(
       &mut context.pool(),
       person_id,
-      &PersonUpdateForm::builder().admin(Some(false)).build(),
+      &PersonUpdateForm {
+        admin: Some(false),
+        ..Default::default()
+      },
     )
     .await?;
 
index 227f93243dacec0f6ff86fbaad5f240c3a20f02e..eb0fb0323fd8de1c4a80cc3c1c6f764f0aae0ed5 100644 (file)
@@ -40,9 +40,10 @@ impl Perform for ApproveRegistrationApplication {
       RegistrationApplication::update(&mut context.pool(), app_id, &app_form).await?;
 
     // Update the local_user row
-    let local_user_form = LocalUserUpdateForm::builder()
-      .accepted_application(Some(data.approve))
-      .build();
+    let local_user_form = LocalUserUpdateForm {
+      accepted_application: Some(data.approve),
+      ..Default::default()
+    };
 
     let approved_user_id = registration_application.local_user_id;
     LocalUser::update(&mut context.pool(), approved_user_id, &local_user_form).await?;
index 78d7b4caec4e58b62804063ec5400b5f35a2b704..4d434afcdfc2d279a5f77f628f44d3929a38a5f0 100644 (file)
@@ -596,10 +596,11 @@ pub async fn remove_user_data(
   Person::update(
     pool,
     banned_person_id,
-    &PersonUpdateForm::builder()
-      .avatar(Some(None))
-      .banner(Some(None))
-      .build(),
+    &PersonUpdateForm {
+      avatar: Some(None),
+      banner: Some(None),
+      ..Default::default()
+    },
   )
   .await?;
 
@@ -625,7 +626,10 @@ pub async fn remove_user_data(
     Community::update(
       pool,
       community_id,
-      &CommunityUpdateForm::builder().removed(Some(true)).build(),
+      &CommunityUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await?;
 
@@ -642,10 +646,11 @@ pub async fn remove_user_data(
     Community::update(
       pool,
       community_id,
-      &CommunityUpdateForm::builder()
-        .icon(Some(None))
-        .banner(Some(None))
-        .build(),
+      &CommunityUpdateForm {
+        icon: Some(None),
+        banner: Some(None),
+        ..Default::default()
+      },
     )
     .await?;
   }
@@ -679,7 +684,10 @@ pub async fn remove_user_data_in_community(
     Comment::update(
       pool,
       comment_id,
-      &CommentUpdateForm::builder().removed(Some(true)).build(),
+      &CommentUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await?;
   }
index 678bcfb08ab8f22c0fed39fe55517e8760224f0c..33e480a9b5cfd3310e42cd805c8809c6e9536b8a 100644 (file)
@@ -129,7 +129,10 @@ pub async fn create_comment(
   let updated_comment = Comment::update(
     &mut context.pool(),
     inserted_comment_id,
-    &CommentUpdateForm::builder().ap_id(Some(apub_id)).build(),
+    &CommentUpdateForm {
+      ap_id: Some(apub_id),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntCreateComment)?;
index 81a0116a67368fc2c758f093bdc0018453caf699..96c22b604a5e952a344982926d9d1d4a75310202 100644 (file)
@@ -49,7 +49,10 @@ pub async fn delete_comment(
   let updated_comment = Comment::update(
     &mut context.pool(),
     comment_id,
-    &CommentUpdateForm::builder().deleted(Some(deleted)).build(),
+    &CommentUpdateForm {
+      deleted: Some(deleted),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
index b3afcc7553907fd22d8604162ecd9ad488d9b419..2bb5c75f2f9b9fdf12de3b6ee9f105254eb0eb2a 100644 (file)
@@ -48,7 +48,10 @@ pub async fn remove_comment(
   let updated_comment = Comment::update(
     &mut context.pool(),
     comment_id,
-    &CommentUpdateForm::builder().removed(Some(removed)).build(),
+    &CommentUpdateForm {
+      removed: Some(removed),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
index e170f2e0559efbe8a63cfc01094d859d545b6f06..a07ee4548e1b75886c9527b36d8af5d74cf51a10 100644 (file)
@@ -71,11 +71,12 @@ pub async fn update_comment(
   let content = sanitize_html_opt(&content);
 
   let comment_id = data.comment_id;
-  let form = CommentUpdateForm::builder()
-    .content(content)
-    .language_id(data.language_id)
-    .updated(Some(Some(naive_now())))
-    .build();
+  let form = CommentUpdateForm {
+    content,
+    language_id: data.language_id,
+    updated: Some(Some(naive_now())),
+    ..Default::default()
+  };
   let updated_comment = Comment::update(&mut context.pool(), comment_id, &form)
     .await
     .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
index e23b1f40453d481472bd72fbe8f0e4db402d8bcc..9c8db512df1636bb330fee9998aad88474081f05 100644 (file)
@@ -35,9 +35,10 @@ pub async fn delete_community(
   let community = Community::update(
     &mut context.pool(),
     community_id,
-    &CommunityUpdateForm::builder()
-      .deleted(Some(deleted))
-      .build(),
+    &CommunityUpdateForm {
+      deleted: Some(deleted),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?;
index b79b2a66658cbb3345922b61d0d4976e9609616d..f0bee639de6abbcb75541249ba34f05f43fcad22 100644 (file)
@@ -35,9 +35,10 @@ pub async fn remove_community(
   let community = Community::update(
     &mut context.pool(),
     community_id,
-    &CommunityUpdateForm::builder()
-      .removed(Some(removed))
-      .build(),
+    &CommunityUpdateForm {
+      removed: Some(removed),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?;
index baa4e1bdbe795f9552ba4c3551606537d8c657b0..cf53ff89151e37b34b7fdf15fc15fe9187b82d22 100644 (file)
@@ -65,15 +65,16 @@ pub async fn update_community(
     CommunityLanguage::update(&mut context.pool(), languages, community_id).await?;
   }
 
-  let community_form = CommunityUpdateForm::builder()
-    .title(title)
-    .description(description)
-    .icon(icon)
-    .banner(banner)
-    .nsfw(data.nsfw)
-    .posting_restricted_to_mods(data.posting_restricted_to_mods)
-    .updated(Some(Some(naive_now())))
-    .build();
+  let community_form = CommunityUpdateForm {
+    title,
+    description,
+    icon,
+    banner,
+    nsfw: data.nsfw,
+    posting_restricted_to_mods: data.posting_restricted_to_mods,
+    updated: Some(Some(naive_now())),
+    ..Default::default()
+  };
 
   let community_id = data.community_id;
   let community = Community::update(&mut context.pool(), community_id, &community_form)
index dd88204a9a75dd449cbe4b190c24c998999a3045..07e2cc27b6143f8a0f5b13da4aad9307c546393a 100644 (file)
@@ -148,7 +148,10 @@ pub async fn create_post(
   let updated_post = Post::update(
     &mut context.pool(),
     inserted_post_id,
-    &PostUpdateForm::builder().ap_id(Some(apub_id)).build(),
+    &PostUpdateForm {
+      ap_id: Some(apub_id),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntCreatePost)?;
index 0d5eea886d54c18cc0bea3e08616a9c7f0642428..79c8af0f011969816b21bd0a77d121513aabdedb 100644 (file)
@@ -45,9 +45,10 @@ pub async fn delete_post(
   let post = Post::update(
     &mut context.pool(),
     data.post_id,
-    &PostUpdateForm::builder()
-      .deleted(Some(data.deleted))
-      .build(),
+    &PostUpdateForm {
+      deleted: Some(data.deleted),
+      ..Default::default()
+    },
   )
   .await?;
 
index 4a87eb7848acec8fc6dd642c707aa75b4a982185..ee100cfdc2288518f1cdce84c2621c1819646ca8 100644 (file)
@@ -47,7 +47,10 @@ pub async fn remove_post(
   let post = Post::update(
     &mut context.pool(),
     post_id,
-    &PostUpdateForm::builder().removed(Some(removed)).build(),
+    &PostUpdateForm {
+      removed: Some(removed),
+      ..Default::default()
+    },
   )
   .await?;
 
index c831c88f15dd5f7558d0f17f35e322d7999ba4e9..a0f56aeb97eee4a076324eedf5971cc5b7bf42fb 100644 (file)
@@ -93,18 +93,19 @@ pub async fn update_post(
   )
   .await?;
 
-  let post_form = PostUpdateForm::builder()
-    .name(name)
-    .url(url)
-    .body(body)
-    .nsfw(data.nsfw)
-    .embed_title(embed_title)
-    .embed_description(embed_description)
-    .embed_video_url(embed_video_url)
-    .language_id(data.language_id)
-    .thumbnail_url(Some(thumbnail_url))
-    .updated(Some(Some(naive_now())))
-    .build();
+  let post_form = PostUpdateForm {
+    name,
+    url,
+    body,
+    nsfw: data.nsfw,
+    embed_title,
+    embed_description,
+    embed_video_url,
+    language_id: data.language_id,
+    thumbnail_url: Some(thumbnail_url),
+    updated: Some(Some(naive_now())),
+    ..Default::default()
+  };
 
   let post_id = data.post_id;
   let updated_post = Post::update(&mut context.pool(), post_id, &post_form)
index b9ac916f342948feca4d9bd691d6529c54d6a08c..f5e4b15abfc575261ba4619dcc027e1c1aa56c8e 100644 (file)
@@ -67,9 +67,10 @@ pub async fn create_private_message(
   PrivateMessage::update(
     &mut context.pool(),
     inserted_private_message.id,
-    &PrivateMessageUpdateForm::builder()
-      .ap_id(Some(apub_id))
-      .build(),
+    &PrivateMessageUpdateForm {
+      ap_id: Some(apub_id),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntCreatePrivateMessage)?;
index 7657a7ff7e49eff314cef8225b9ab3074787e846..2a50dc0a29d201bc13bc4748d400bfc880dac7e3 100644 (file)
@@ -33,9 +33,10 @@ pub async fn delete_private_message(
   let private_message = PrivateMessage::update(
     &mut context.pool(),
     private_message_id,
-    &PrivateMessageUpdateForm::builder()
-      .deleted(Some(deleted))
-      .build(),
+    &PrivateMessageUpdateForm {
+      deleted: Some(deleted),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?;
index eb24d7c126a489a6ee2e8366100e44a458f8072d..d9e53776dd2aac1dfa291b11a88a40f7ab6869f9 100644 (file)
@@ -44,10 +44,11 @@ pub async fn update_private_message(
   PrivateMessage::update(
     &mut context.pool(),
     private_message_id,
-    &PrivateMessageUpdateForm::builder()
-      .content(Some(content))
-      .updated(Some(Some(naive_now())))
-      .build(),
+    &PrivateMessageUpdateForm {
+      content: Some(content),
+      updated: Some(Some(naive_now())),
+      ..Default::default()
+    },
   )
   .await
   .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?;
index f7beb254bf23e393c7f2673cc87915bd3ea480ab..38d6111ce6f630d284484362ceca3dfeef95ca3f 100644 (file)
@@ -60,18 +60,19 @@ pub async fn create_site(
   let sidebar = sanitize_html_opt(&data.sidebar);
   let description = sanitize_html_opt(&data.description);
 
-  let site_form = SiteUpdateForm::builder()
-    .name(Some(name))
-    .sidebar(diesel_option_overwrite(sidebar))
-    .description(diesel_option_overwrite(description))
-    .icon(diesel_option_overwrite_to_url(&data.icon)?)
-    .banner(diesel_option_overwrite_to_url(&data.banner)?)
-    .actor_id(Some(actor_id))
-    .last_refreshed_at(Some(naive_now()))
-    .inbox_url(inbox_url)
-    .private_key(Some(Some(keypair.private_key)))
-    .public_key(Some(keypair.public_key))
-    .build();
+  let site_form = SiteUpdateForm {
+    name: Some(name),
+    sidebar: diesel_option_overwrite(sidebar),
+    description: diesel_option_overwrite(description),
+    icon: diesel_option_overwrite_to_url(&data.icon)?,
+    banner: diesel_option_overwrite_to_url(&data.banner)?,
+    actor_id: Some(actor_id),
+    last_refreshed_at: Some(naive_now()),
+    inbox_url,
+    private_key: Some(Some(keypair.private_key)),
+    public_key: Some(keypair.public_key),
+    ..Default::default()
+  };
 
   let site_id = local_site.site_id;
 
@@ -81,45 +82,47 @@ pub async fn create_site(
   let default_theme = sanitize_html_opt(&data.default_theme);
   let legal_information = sanitize_html_opt(&data.legal_information);
 
-  let local_site_form = LocalSiteUpdateForm::builder()
+  let local_site_form = LocalSiteUpdateForm {
     // Set the site setup to true
-    .site_setup(Some(true))
-    .enable_downvotes(data.enable_downvotes)
-    .registration_mode(data.registration_mode)
-    .enable_nsfw(data.enable_nsfw)
-    .community_creation_admin_only(data.community_creation_admin_only)
-    .require_email_verification(data.require_email_verification)
-    .application_question(diesel_option_overwrite(application_question))
-    .private_instance(data.private_instance)
-    .default_theme(default_theme)
-    .default_post_listing_type(data.default_post_listing_type)
-    .legal_information(diesel_option_overwrite(legal_information))
-    .application_email_admins(data.application_email_admins)
-    .hide_modlog_mod_names(data.hide_modlog_mod_names)
-    .updated(Some(Some(naive_now())))
-    .slur_filter_regex(diesel_option_overwrite(data.slur_filter_regex.clone()))
-    .actor_name_max_length(data.actor_name_max_length)
-    .federation_enabled(data.federation_enabled)
-    .captcha_enabled(data.captcha_enabled)
-    .captcha_difficulty(data.captcha_difficulty.clone())
-    .build();
+    site_setup: Some(true),
+    enable_downvotes: data.enable_downvotes,
+    registration_mode: data.registration_mode,
+    enable_nsfw: data.enable_nsfw,
+    community_creation_admin_only: data.community_creation_admin_only,
+    require_email_verification: data.require_email_verification,
+    application_question: diesel_option_overwrite(application_question),
+    private_instance: data.private_instance,
+    default_theme,
+    default_post_listing_type: data.default_post_listing_type,
+    legal_information: diesel_option_overwrite(legal_information),
+    application_email_admins: data.application_email_admins,
+    hide_modlog_mod_names: data.hide_modlog_mod_names,
+    updated: Some(Some(naive_now())),
+    slur_filter_regex: diesel_option_overwrite(data.slur_filter_regex.clone()),
+    actor_name_max_length: data.actor_name_max_length,
+    federation_enabled: data.federation_enabled,
+    captcha_enabled: data.captcha_enabled,
+    captcha_difficulty: data.captcha_difficulty.clone(),
+    ..Default::default()
+  };
 
   LocalSite::update(&mut context.pool(), &local_site_form).await?;
 
-  let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm::builder()
-    .message(data.rate_limit_message)
-    .message_per_second(data.rate_limit_message_per_second)
-    .post(data.rate_limit_post)
-    .post_per_second(data.rate_limit_post_per_second)
-    .register(data.rate_limit_register)
-    .register_per_second(data.rate_limit_register_per_second)
-    .image(data.rate_limit_image)
-    .image_per_second(data.rate_limit_image_per_second)
-    .comment(data.rate_limit_comment)
-    .comment_per_second(data.rate_limit_comment_per_second)
-    .search(data.rate_limit_search)
-    .search_per_second(data.rate_limit_search_per_second)
-    .build();
+  let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
+    message: data.rate_limit_message,
+    message_per_second: data.rate_limit_message_per_second,
+    post: data.rate_limit_post,
+    post_per_second: data.rate_limit_post_per_second,
+    register: data.rate_limit_register,
+    register_per_second: data.rate_limit_register_per_second,
+    image: data.rate_limit_image,
+    image_per_second: data.rate_limit_image_per_second,
+    comment: data.rate_limit_comment,
+    comment_per_second: data.rate_limit_comment_per_second,
+    search: data.rate_limit_search,
+    search_per_second: data.rate_limit_search_per_second,
+    ..Default::default()
+  };
 
   LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form).await?;
 
index f560c7295ca468a1dd6dfcc4f884c9cd4c384ad4..6148d546eb22c6d15563197f81c44430aa5b14ef 100644 (file)
@@ -63,14 +63,15 @@ pub async fn update_site(
   let sidebar = sanitize_html_opt(&data.sidebar);
   let description = sanitize_html_opt(&data.description);
 
-  let site_form = SiteUpdateForm::builder()
-    .name(name)
-    .sidebar(diesel_option_overwrite(sidebar))
-    .description(diesel_option_overwrite(description))
-    .icon(diesel_option_overwrite_to_url(&data.icon)?)
-    .banner(diesel_option_overwrite_to_url(&data.banner)?)
-    .updated(Some(Some(naive_now())))
-    .build();
+  let site_form = SiteUpdateForm {
+    name,
+    sidebar: diesel_option_overwrite(sidebar),
+    description: diesel_option_overwrite(description),
+    icon: diesel_option_overwrite_to_url(&data.icon)?,
+    banner: diesel_option_overwrite_to_url(&data.banner)?,
+    updated: Some(Some(naive_now())),
+    ..Default::default()
+  };
 
   Site::update(&mut context.pool(), site.id, &site_form)
     .await
@@ -82,46 +83,48 @@ pub async fn update_site(
   let default_theme = sanitize_html_opt(&data.default_theme);
   let legal_information = sanitize_html_opt(&data.legal_information);
 
-  let local_site_form = LocalSiteUpdateForm::builder()
-    .enable_downvotes(data.enable_downvotes)
-    .registration_mode(data.registration_mode)
-    .enable_nsfw(data.enable_nsfw)
-    .community_creation_admin_only(data.community_creation_admin_only)
-    .require_email_verification(data.require_email_verification)
-    .application_question(diesel_option_overwrite(application_question))
-    .private_instance(data.private_instance)
-    .default_theme(default_theme)
-    .default_post_listing_type(data.default_post_listing_type)
-    .legal_information(diesel_option_overwrite(legal_information))
-    .application_email_admins(data.application_email_admins)
-    .hide_modlog_mod_names(data.hide_modlog_mod_names)
-    .updated(Some(Some(naive_now())))
-    .slur_filter_regex(diesel_option_overwrite(data.slur_filter_regex.clone()))
-    .actor_name_max_length(data.actor_name_max_length)
-    .federation_enabled(data.federation_enabled)
-    .captcha_enabled(data.captcha_enabled)
-    .captcha_difficulty(data.captcha_difficulty.clone())
-    .reports_email_admins(data.reports_email_admins)
-    .build();
+  let local_site_form = LocalSiteUpdateForm {
+    enable_downvotes: data.enable_downvotes,
+    registration_mode: data.registration_mode,
+    enable_nsfw: data.enable_nsfw,
+    community_creation_admin_only: data.community_creation_admin_only,
+    require_email_verification: data.require_email_verification,
+    application_question: diesel_option_overwrite(application_question),
+    private_instance: data.private_instance,
+    default_theme,
+    default_post_listing_type: data.default_post_listing_type,
+    legal_information: diesel_option_overwrite(legal_information),
+    application_email_admins: data.application_email_admins,
+    hide_modlog_mod_names: data.hide_modlog_mod_names,
+    updated: Some(Some(naive_now())),
+    slur_filter_regex: diesel_option_overwrite(data.slur_filter_regex.clone()),
+    actor_name_max_length: data.actor_name_max_length,
+    federation_enabled: data.federation_enabled,
+    captcha_enabled: data.captcha_enabled,
+    captcha_difficulty: data.captcha_difficulty.clone(),
+    reports_email_admins: data.reports_email_admins,
+    ..Default::default()
+  };
 
   let update_local_site = LocalSite::update(&mut context.pool(), &local_site_form)
     .await
     .ok();
 
-  let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm::builder()
-    .message(data.rate_limit_message)
-    .message_per_second(data.rate_limit_message_per_second)
-    .post(data.rate_limit_post)
-    .post_per_second(data.rate_limit_post_per_second)
-    .register(data.rate_limit_register)
-    .register_per_second(data.rate_limit_register_per_second)
-    .image(data.rate_limit_image)
-    .image_per_second(data.rate_limit_image_per_second)
-    .comment(data.rate_limit_comment)
-    .comment_per_second(data.rate_limit_comment_per_second)
-    .search(data.rate_limit_search)
-    .search_per_second(data.rate_limit_search_per_second)
-    .build();
+  let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
+    message: data.rate_limit_message,
+    message_per_second: data.rate_limit_message_per_second,
+    post: data.rate_limit_post,
+    post_per_second: data.rate_limit_post_per_second,
+    register: data.rate_limit_register,
+    register_per_second: data.rate_limit_register_per_second,
+    image: data.rate_limit_image,
+    image_per_second: data.rate_limit_image_per_second,
+    comment: data.rate_limit_comment,
+    comment_per_second: data.rate_limit_comment_per_second,
+    search: data.rate_limit_search,
+    search_per_second: data.rate_limit_search_per_second,
+    ..Default::default()
+  };
 
   LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form)
     .await
index abfab84565fd1f09d1ca895f84ae61f61e3d7ff9..b4fb53c7d5fa5ee3f349976671d73be8e1725a1e 100644 (file)
@@ -157,10 +157,11 @@ impl ActivityHandler for BlockUser {
         let blocked_person = Person::update(
           &mut context.pool(),
           blocked_person.id,
-          &PersonUpdateForm::builder()
-            .banned(Some(true))
-            .ban_expires(Some(expires))
-            .build(),
+          &PersonUpdateForm {
+            banned: Some(true),
+            ban_expires: Some(expires),
+            ..Default::default()
+          },
         )
         .await?;
         if self.remove_data.unwrap_or(false) {
index 2ebd053baae945fec0c47b60395fb6a2c930ca74..91cafa0a555cf42a43064b0c2941b20e39911053 100644 (file)
@@ -105,10 +105,11 @@ impl ActivityHandler for UndoBlockUser {
         let blocked_person = Person::update(
           &mut context.pool(),
           blocked_person.id,
-          &PersonUpdateForm::builder()
-            .banned(Some(false))
-            .ban_expires(Some(expires))
-            .build(),
+          &PersonUpdateForm {
+            banned: Some(false),
+            ban_expires: Some(expires),
+            ..Default::default()
+          },
         )
         .await?;
 
index e03ded2b398ee79dab2fdba4e7339eb2f6ac4f17..3d2daf4c72d3665e217efc4488131a48a8722a42 100644 (file)
@@ -153,9 +153,10 @@ impl ActivityHandler for CollectionAdd {
         let post = ObjectId::<ApubPost>::from(self.object)
           .dereference(context)
           .await?;
-        let form = PostUpdateForm::builder()
-          .featured_community(Some(true))
-          .build();
+        let form = PostUpdateForm {
+          featured_community: Some(true),
+          ..Default::default()
+        };
         Post::update(&mut context.pool(), post.id, &form).await?;
       }
     }
index 28214284b1b93d27a6f8539a0dd4d8a429b3e927..38ed95683e2ada5f8750e9acb706a8307e84c981 100644 (file)
@@ -141,9 +141,10 @@ impl ActivityHandler for CollectionRemove {
         let post = ObjectId::<ApubPost>::from(self.object)
           .dereference(context)
           .await?;
-        let form = PostUpdateForm::builder()
-          .featured_community(Some(false))
-          .build();
+        let form = PostUpdateForm {
+          featured_community: Some(false),
+          ..Default::default()
+        };
         Post::update(&mut context.pool(), post.id, &form).await?;
       }
     }
index 2ceb183843c39806a876e3e3fa3e2b86e00b3963..446b7824f3519517e0e79e971fdf7c6d4aa1ba83 100644 (file)
@@ -56,7 +56,10 @@ impl ActivityHandler for LockPage {
   }
 
   async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
-    let form = PostUpdateForm::builder().locked(Some(true)).build();
+    let form = PostUpdateForm {
+      locked: Some(true),
+      ..Default::default()
+    };
     let post = self.object.dereference(context).await?;
     Post::update(&mut context.pool(), post.id, &form).await?;
     Ok(())
@@ -93,7 +96,10 @@ impl ActivityHandler for UndoLockPage {
   }
 
   async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
-    let form = PostUpdateForm::builder().locked(Some(false)).build();
+    let form = PostUpdateForm {
+      locked: Some(false),
+      ..Default::default()
+    };
     let post = self.object.object.dereference(context).await?;
     Post::update(&mut context.pool(), post.id, &form).await?;
     Ok(())
index 06f7463ae0f12dfe163677153e726aaf846da746..7a35ec5021cd054688acaf6514c91718224687ef 100644 (file)
@@ -123,7 +123,10 @@ pub(in crate::activities) async fn receive_remove_action(
       Community::update(
         &mut context.pool(),
         community.id,
-        &CommunityUpdateForm::builder().removed(Some(true)).build(),
+        &CommunityUpdateForm {
+          removed: Some(true),
+          ..Default::default()
+        },
       )
       .await?;
     }
@@ -138,7 +141,10 @@ pub(in crate::activities) async fn receive_remove_action(
       Post::update(
         &mut context.pool(),
         post.id,
-        &PostUpdateForm::builder().removed(Some(true)).build(),
+        &PostUpdateForm {
+          removed: Some(true),
+          ..Default::default()
+        },
       )
       .await?;
     }
@@ -153,7 +159,10 @@ pub(in crate::activities) async fn receive_remove_action(
       Comment::update(
         &mut context.pool(),
         comment.id,
-        &CommentUpdateForm::builder().removed(Some(true)).build(),
+        &CommentUpdateForm {
+          removed: Some(true),
+          ..Default::default()
+        },
       )
       .await?;
     }
index e03074f19d96531c32065b76dc8a641796eea375..23ecd3bd1098be71f8c55a83b397491c5a2afde0 100644 (file)
@@ -258,9 +258,10 @@ async fn receive_delete_action(
       Community::update(
         &mut context.pool(),
         community.id,
-        &CommunityUpdateForm::builder()
-          .deleted(Some(deleted))
-          .build(),
+        &CommunityUpdateForm {
+          deleted: Some(deleted),
+          ..Default::default()
+        },
       )
       .await?;
     }
@@ -269,7 +270,10 @@ async fn receive_delete_action(
         Post::update(
           &mut context.pool(),
           post.id,
-          &PostUpdateForm::builder().deleted(Some(deleted)).build(),
+          &PostUpdateForm {
+            deleted: Some(deleted),
+            ..Default::default()
+          },
         )
         .await?;
       }
@@ -279,7 +283,10 @@ async fn receive_delete_action(
         Comment::update(
           &mut context.pool(),
           comment.id,
-          &CommentUpdateForm::builder().deleted(Some(deleted)).build(),
+          &CommentUpdateForm {
+            deleted: Some(deleted),
+            ..Default::default()
+          },
         )
         .await?;
       }
@@ -288,9 +295,10 @@ async fn receive_delete_action(
       PrivateMessage::update(
         &mut context.pool(),
         pm.id,
-        &PrivateMessageUpdateForm::builder()
-          .deleted(Some(deleted))
-          .build(),
+        &PrivateMessageUpdateForm {
+          deleted: Some(deleted),
+          ..Default::default()
+        },
       )
       .await?;
     }
index 541a7455fe376082931f957524c859bcdd357236..4d7822042ae780f65832b01b0970bf6ab889fdcb 100644 (file)
@@ -113,7 +113,10 @@ impl UndoDelete {
         Community::update(
           &mut context.pool(),
           community.id,
-          &CommunityUpdateForm::builder().removed(Some(false)).build(),
+          &CommunityUpdateForm {
+            removed: Some(false),
+            ..Default::default()
+          },
         )
         .await?;
       }
@@ -128,7 +131,10 @@ impl UndoDelete {
         Post::update(
           &mut context.pool(),
           post.id,
-          &PostUpdateForm::builder().removed(Some(false)).build(),
+          &PostUpdateForm {
+            removed: Some(false),
+            ..Default::default()
+          },
         )
         .await?;
       }
@@ -143,7 +149,10 @@ impl UndoDelete {
         Comment::update(
           &mut context.pool(),
           comment.id,
-          &CommentUpdateForm::builder().removed(Some(false)).build(),
+          &CommentUpdateForm {
+            removed: Some(false),
+            ..Default::default()
+          },
         )
         .await?;
       }
index 3b05ed3946e0bb6bc00f4959d70905e6155bcbf8..1b7724431200302ee0c153988a21649f366be1fc 100644 (file)
@@ -78,7 +78,10 @@ impl Object for ApubComment {
   #[tracing::instrument(skip_all)]
   async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
     if !self.deleted {
-      let form = CommentUpdateForm::builder().deleted(Some(true)).build();
+      let form = CommentUpdateForm {
+        deleted: Some(true),
+        ..Default::default()
+      };
       Comment::update(&mut context.pool(), self.id, &form).await?;
     }
     Ok(())
index 75eb941b1b3af0589cf29782277e4ef6e388c4c9..10d5ddd4fadd8b3475016f54ba0597aa649da23e 100644 (file)
@@ -74,7 +74,10 @@ impl Object for ApubCommunity {
 
   #[tracing::instrument(skip_all)]
   async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
-    let form = CommunityUpdateForm::builder().deleted(Some(true)).build();
+    let form = CommunityUpdateForm {
+      deleted: Some(true),
+      ..Default::default()
+    };
     Community::update(&mut context.pool(), self.id, &form).await?;
     Ok(())
   }
index 2c238fb56c309d4c23accaa81633e06f4190fae6..907fd5f8fb7a25c9956307e5104ab7e6b305786c 100644 (file)
@@ -77,7 +77,10 @@ impl Object for ApubPerson {
 
   #[tracing::instrument(skip_all)]
   async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
-    let form = PersonUpdateForm::builder().deleted(Some(true)).build();
+    let form = PersonUpdateForm {
+      deleted: Some(true),
+      ..Default::default()
+    };
     DbPerson::update(&mut context.pool(), self.id, &form).await?;
     Ok(())
   }
index f04e07ded3b9961ad39e36720133946dc3d89e9d..df3aefed2782882f517b55ac3102c389b5190595 100644 (file)
@@ -99,7 +99,10 @@ impl Object for ApubPost {
   #[tracing::instrument(skip_all)]
   async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
     if !self.deleted {
-      let form = PostUpdateForm::builder().deleted(Some(true)).build();
+      let form = PostUpdateForm {
+        deleted: Some(true),
+        ..Default::default()
+      };
       Post::update(&mut context.pool(), self.id, &form).await?;
     }
     Ok(())
index 2e71844fa8443d8b5d21f36e94a46b58bcc8ddf8..e6195de28560def1921f7514688da76dd1b502c1 100644 (file)
@@ -145,14 +145,20 @@ mod tests {
     Comment::update(
       pool,
       inserted_comment.id,
-      &CommentUpdateForm::builder().removed(Some(true)).build(),
+      &CommentUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
     Comment::update(
       pool,
       inserted_child_comment.id,
-      &CommentUpdateForm::builder().removed(Some(true)).build(),
+      &CommentUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
index 0203708255b0c0c8f561ecdce79dd9697f601512..7847f3946a3d593974b0367dcc487d315d56015e 100644 (file)
@@ -235,7 +235,10 @@ mod tests {
     Comment::update(
       pool,
       inserted_comment.id,
-      &CommentUpdateForm::builder().removed(Some(true)).build(),
+      &CommentUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
@@ -246,7 +249,10 @@ mod tests {
     Comment::update(
       pool,
       inserted_comment.id,
-      &CommentUpdateForm::builder().removed(Some(false)).build(),
+      &CommentUpdateForm {
+        removed: Some(false),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
@@ -254,7 +260,10 @@ mod tests {
     Comment::update(
       pool,
       inserted_comment.id,
-      &CommentUpdateForm::builder().deleted(Some(true)).build(),
+      &CommentUpdateForm {
+        deleted: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
@@ -265,7 +274,10 @@ mod tests {
     Comment::update(
       pool,
       inserted_comment.id,
-      &CommentUpdateForm::builder().removed(Some(true)).build(),
+      &CommentUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
index ea3da85aeaf9e12c2601a834d79d0edc5a388634..4fe57720a62380dc2420a0f35d7d2a9b125b1823 100644 (file)
@@ -160,7 +160,10 @@ mod tests {
     Community::update(
       pool,
       inserted_community.id,
-      &CommunityUpdateForm::builder().deleted(Some(true)).build(),
+      &CommunityUpdateForm {
+        deleted: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
@@ -171,7 +174,10 @@ mod tests {
     Community::update(
       pool,
       inserted_community.id,
-      &CommunityUpdateForm::builder().deleted(Some(false)).build(),
+      &CommunityUpdateForm {
+        deleted: Some(false),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
@@ -179,7 +185,10 @@ mod tests {
     Community::update(
       pool,
       inserted_community.id,
-      &CommunityUpdateForm::builder().removed(Some(true)).build(),
+      &CommunityUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
@@ -190,7 +199,10 @@ mod tests {
     Community::update(
       pool,
       inserted_community.id,
-      &CommunityUpdateForm::builder().deleted(Some(true)).build(),
+      &CommunityUpdateForm {
+        deleted: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
index 88757cd023f5a4b15ee01a925d6afc4395733948..cab033df30e3ea58e85eb8d83d36d36b532daab0 100644 (file)
@@ -372,9 +372,10 @@ mod tests {
       published: inserted_comment_saved.published,
     };
 
-    let comment_update_form = CommentUpdateForm::builder()
-      .content(Some("A test comment".into()))
-      .build();
+    let comment_update_form = CommentUpdateForm {
+      content: Some("A test comment".into()),
+      ..Default::default()
+    };
 
     let updated_comment = Comment::update(pool, inserted_comment.id, &comment_update_form)
       .await
index d5d558fa27adaf5e1015f7af37495ae743b0a273..bedb9820ece01c8ac3ee0b925a9832afd29d7e11 100644 (file)
@@ -475,9 +475,10 @@ mod tests {
 
     let read_community = Community::read(pool, inserted_community.id).await.unwrap();
 
-    let update_community_form = CommunityUpdateForm::builder()
-      .title(Some("nada".to_owned()))
-      .build();
+    let update_community_form = CommunityUpdateForm {
+      title: Some("nada".to_owned()),
+      ..Default::default()
+    };
     let updated_community = Community::update(pool, inserted_community.id, &update_community_form)
       .await
       .unwrap();
index 53f4a4df01118e2aa2b857397fee0b2ffa87a9d2..43bdf5c3be23e63f9d4068bbe8fcfc78b78f16cc 100644 (file)
@@ -253,9 +253,10 @@ mod tests {
 
     let read_person = Person::read(pool, inserted_person.id).await.unwrap();
 
-    let update_person_form = PersonUpdateForm::builder()
-      .actor_id(Some(inserted_person.actor_id.clone()))
-      .build();
+    let update_person_form = PersonUpdateForm {
+      actor_id: Some(inserted_person.actor_id.clone()),
+      ..Default::default()
+    };
     let updated_person = Person::update(pool, inserted_person.id, &update_person_form)
       .await
       .unwrap();
index 60b8af2cea075547baefa60f2a8114166fa02530..a798ddcb0aad0fe8efefd1571ad7c6b30ff4c0f9 100644 (file)
@@ -453,9 +453,10 @@ mod tests {
 
     let read_post = Post::read(pool, inserted_post.id).await.unwrap();
 
-    let new_post_update = PostUpdateForm::builder()
-      .name(Some("A test post".into()))
-      .build();
+    let new_post_update = PostUpdateForm {
+      name: Some("A test post".into()),
+      ..Default::default()
+    };
     let updated_post = Post::update(pool, inserted_post.id, &new_post_update)
       .await
       .unwrap();
index d422f0d2370fc1a2eb39366558cb460c42d6f7c8..81a4b185080e8428f061d5353e367f18ed6df649 100644 (file)
@@ -142,9 +142,10 @@ mod tests {
       .await
       .unwrap();
 
-    let private_message_update_form = PrivateMessageUpdateForm::builder()
-      .content(Some("A test private message".into()))
-      .build();
+    let private_message_update_form = PrivateMessageUpdateForm {
+      content: Some("A test private message".into()),
+      ..Default::default()
+    };
     let updated_private_message = PrivateMessage::update(
       pool,
       inserted_private_message.id,
@@ -156,16 +157,20 @@ mod tests {
     let deleted_private_message = PrivateMessage::update(
       pool,
       inserted_private_message.id,
-      &PrivateMessageUpdateForm::builder()
-        .deleted(Some(true))
-        .build(),
+      &PrivateMessageUpdateForm {
+        deleted: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
     let marked_read_private_message = PrivateMessage::update(
       pool,
       inserted_private_message.id,
-      &PrivateMessageUpdateForm::builder().read(Some(true)).build(),
+      &PrivateMessageUpdateForm {
+        read: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
index ecf745ee99e4b07149b5f0695c494fd4f0897129..f76e2fba77ddb97b1ca2d66f2f7dd4a0aecba764 100644 (file)
@@ -66,8 +66,7 @@ pub struct CommentInsertForm {
   pub language_id: Option<LanguageId>,
 }
 
-#[derive(Debug, Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Debug, Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = comment))]
 pub struct CommentUpdateForm {
index 64b30b2a8a3430a5347ecba2e544c719bcd7b09a..5d56c36a52b341a09362faa90ddaf21278ed2f84 100644 (file)
@@ -97,8 +97,7 @@ pub struct CommunityInsertForm {
   pub instance_id: InstanceId,
 }
 
-#[derive(Debug, Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Debug, Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = community))]
 pub struct CommunityUpdateForm {
index be93717a9840bb9bcb5901ee5ddb047052481188..a57bf503c350dd88db6cdccc3b755c595acbd2a2 100644 (file)
@@ -89,8 +89,7 @@ pub struct LocalSiteInsertForm {
   pub reports_email_admins: Option<bool>,
 }
 
-#[derive(Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
 pub struct LocalSiteUpdateForm {
index 9d3e3a2507957e45eecc95fd8f4df54bab043d0c..ab14bfd8323fb3c250679293e2ff9acc33e15d9d 100644 (file)
@@ -57,8 +57,7 @@ pub struct LocalSiteRateLimitInsertForm {
   pub search_per_second: Option<i32>,
 }
 
-#[derive(Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
 pub struct LocalSiteRateLimitUpdateForm {
index 0d8db6693f0b90f3914e44f3370d87e5f87030c6..4e668bddf6a97d511ecb978056e204fb9c9f26b3 100644 (file)
@@ -90,8 +90,7 @@ pub struct LocalUserInsertForm {
   pub infinite_scroll_enabled: Option<bool>,
 }
 
-#[derive(Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
 pub struct LocalUserUpdateForm {
index 82d6f61a2648e51d65fc79bcf13db705aa9c3f37..7772bb11819a969aa50a439c871ac743b6399008 100644 (file)
@@ -89,10 +89,9 @@ pub struct PersonInsertForm {
   pub ban_expires: Option<chrono::NaiveDateTime>,
 }
 
-#[derive(Clone, TypedBuilder)]
+#[derive(Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = person))]
-#[builder(field_defaults(default))]
 pub struct PersonUpdateForm {
   pub display_name: Option<Option<String>>,
   pub avatar: Option<Option<DbUrl>>,
index 27eac6d986dd73572a58273d7511974e096d57d4..de56f118753107734d3e15904d046353c00c1a34 100644 (file)
@@ -85,8 +85,7 @@ pub struct PostInsertForm {
   pub featured_local: Option<bool>,
 }
 
-#[derive(Debug, Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Debug, Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = post))]
 pub struct PostUpdateForm {
index 0ceaf762f95c87a4bf37b37f5f9588c94a01495e..bd8c73e300a7873cd4ccc19fa7f574b0461cce0c 100644 (file)
@@ -49,8 +49,7 @@ pub struct PrivateMessageInsertForm {
   pub local: Option<bool>,
 }
 
-#[derive(Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = private_message))]
 pub struct PrivateMessageUpdateForm {
index 12b30c584c3ccd7479eaa023c3fa1d7e3eaa0156..e45ece70632707ffcae680e737924ac69d807650 100644 (file)
@@ -59,8 +59,7 @@ pub struct SiteInsertForm {
   pub instance_id: InstanceId,
 }
 
-#[derive(Clone, TypedBuilder)]
-#[builder(field_defaults(default))]
+#[derive(Clone, Default)]
 #[cfg_attr(feature = "full", derive(AsChangeset))]
 #[cfg_attr(feature = "full", diesel(table_name = site))]
 pub struct SiteUpdateForm {
index 5fcb73f69da09a24fdb2c14554037ecfd4730ad1..7d461d14d99bb6e2db73e3f6e68e7ea82699f9d6 100644 (file)
@@ -608,9 +608,10 @@ mod tests {
     let pool = &mut pool.into();
     let mut data = init_data(pool).await;
 
-    let local_user_form = LocalUserUpdateForm::builder()
-      .show_bot_accounts(Some(false))
-      .build();
+    let local_user_form = LocalUserUpdateForm {
+      show_bot_accounts: Some(false),
+      ..Default::default()
+    };
     let inserted_local_user =
       LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form)
         .await
@@ -648,9 +649,10 @@ mod tests {
       post_listing_single_with_person
     );
 
-    let local_user_form = LocalUserUpdateForm::builder()
-      .show_bot_accounts(Some(true))
-      .build();
+    let local_user_form = LocalUserUpdateForm {
+      show_bot_accounts: Some(true),
+      ..Default::default()
+    };
     let inserted_local_user =
       LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form)
         .await
@@ -780,9 +782,10 @@ mod tests {
     expected_post_with_upvote.counts.upvotes = 1;
     assert_eq!(expected_post_with_upvote, post_listing_single_with_person);
 
-    let local_user_form = LocalUserUpdateForm::builder()
-      .show_bot_accounts(Some(false))
-      .build();
+    let local_user_form = LocalUserUpdateForm {
+      show_bot_accounts: Some(false),
+      ..Default::default()
+    };
     let inserted_local_user =
       LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form)
         .await
@@ -925,7 +928,10 @@ mod tests {
     Post::update(
       pool,
       data.inserted_post.id,
-      &PostUpdateForm::builder().removed(Some(true)).build(),
+      &PostUpdateForm {
+        removed: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
@@ -968,7 +974,10 @@ mod tests {
     Post::update(
       pool,
       data.inserted_post.id,
-      &PostUpdateForm::builder().deleted(Some(true)).build(),
+      &PostUpdateForm {
+        deleted: Some(true),
+        ..Default::default()
+      },
     )
     .await
     .unwrap();
index 6064bf055a2b12d2dbb578b2a81b5428525b51cf..bdea385cff54fa20fab24754709d9e0cde182463 100644 (file)
@@ -350,9 +350,10 @@ mod tests {
       .unwrap();
 
     // Update the local_user row
-    let approve_local_user_form = LocalUserUpdateForm::builder()
-      .accepted_application(Some(true))
-      .build();
+    let approve_local_user_form = LocalUserUpdateForm {
+      accepted_application: Some(true),
+      ..Default::default()
+    };
 
     LocalUser::update(pool, inserted_sara_local_user.id, &approve_local_user_form)
       .await
index ae7df39799ab1f04d4a6e6c806161d49c20436fd..51302524f409f1e7157cb120773c49e5492fe70b 100644 (file)
@@ -77,16 +77,17 @@ async fn user_updates_2020_04_02(
   for cperson in &incorrect_persons {
     let keypair = generate_actor_keypair()?;
 
-    let form = PersonUpdateForm::builder()
-      .actor_id(Some(generate_local_apub_endpoint(
+    let form = PersonUpdateForm {
+      actor_id: Some(generate_local_apub_endpoint(
         EndpointType::Person,
         &cperson.name,
         protocol_and_hostname,
-      )?))
-      .private_key(Some(Some(keypair.private_key)))
-      .public_key(Some(keypair.public_key))
-      .last_refreshed_at(Some(naive_now()))
-      .build();
+      )?),
+      private_key: Some(Some(keypair.private_key)),
+      public_key: Some(keypair.public_key),
+      last_refreshed_at: Some(naive_now()),
+      ..Default::default()
+    };
 
     Person::update(pool, cperson.id, &form).await?;
   }
@@ -120,12 +121,13 @@ async fn community_updates_2020_04_02(
       protocol_and_hostname,
     )?;
 
-    let form = CommunityUpdateForm::builder()
-      .actor_id(Some(community_actor_id.clone()))
-      .private_key(Some(Some(keypair.private_key)))
-      .public_key(Some(keypair.public_key))
-      .last_refreshed_at(Some(naive_now()))
-      .build();
+    let form = CommunityUpdateForm {
+      actor_id: Some(community_actor_id.clone()),
+      private_key: Some(Some(keypair.private_key)),
+      public_key: Some(keypair.public_key),
+      last_refreshed_at: Some(naive_now()),
+      ..Default::default()
+    };
 
     Community::update(pool, ccommunity.id, &form).await?;
   }
@@ -160,7 +162,10 @@ async fn post_updates_2020_04_03(
     Post::update(
       pool,
       cpost.id,
-      &PostUpdateForm::builder().ap_id(Some(apub_id)).build(),
+      &PostUpdateForm {
+        ap_id: Some(apub_id),
+        ..Default::default()
+      },
     )
     .await?;
   }
@@ -195,7 +200,10 @@ async fn comment_updates_2020_04_03(
     Comment::update(
       pool,
       ccomment.id,
-      &CommentUpdateForm::builder().ap_id(Some(apub_id)).build(),
+      &CommentUpdateForm {
+        ap_id: Some(apub_id),
+        ..Default::default()
+      },
     )
     .await?;
   }
@@ -230,9 +238,10 @@ async fn private_message_updates_2020_05_05(
     PrivateMessage::update(
       pool,
       cpm.id,
-      &PrivateMessageUpdateForm::builder()
-        .ap_id(Some(apub_id))
-        .build(),
+      &PrivateMessageUpdateForm {
+        ap_id: Some(apub_id),
+        ..Default::default()
+      },
     )
     .await?;
   }
@@ -344,13 +353,14 @@ async fn instance_actor_2022_01_28(
     }
     let key_pair = generate_actor_keypair()?;
     let actor_id = Url::parse(protocol_and_hostname)?;
-    let site_form = SiteUpdateForm::builder()
-      .actor_id(Some(actor_id.clone().into()))
-      .last_refreshed_at(Some(naive_now()))
-      .inbox_url(Some(generate_site_inbox_url(&actor_id.into())?))
-      .private_key(Some(Some(key_pair.private_key)))
-      .public_key(Some(key_pair.public_key))
-      .build();
+    let site_form = SiteUpdateForm {
+      actor_id: Some(actor_id.clone().into()),
+      last_refreshed_at: Some(naive_now()),
+      inbox_url: Some(generate_site_inbox_url(&actor_id.into())?),
+      private_key: Some(Some(key_pair.private_key)),
+      public_key: Some(key_pair.public_key),
+      ..Default::default()
+    };
     Site::update(pool, site.id, &site_form).await?;
   }
   Ok(())
@@ -379,10 +389,11 @@ async fn regenerate_public_keys_2022_07_05(pool: &mut DbPool<'_>) -> Result<(),
         community_.name
       );
       let key_pair = generate_actor_keypair()?;
-      let form = CommunityUpdateForm::builder()
-        .public_key(Some(key_pair.public_key))
-        .private_key(Some(Some(key_pair.private_key)))
-        .build();
+      let form = CommunityUpdateForm {
+        public_key: Some(key_pair.public_key),
+        private_key: Some(Some(key_pair.private_key)),
+        ..Default::default()
+      };
       Community::update(&mut conn.into(), community_.id, &form).await?;
     }
   }
@@ -401,10 +412,11 @@ async fn regenerate_public_keys_2022_07_05(pool: &mut DbPool<'_>) -> Result<(),
         person_.name
       );
       let key_pair = generate_actor_keypair()?;
-      let form = PersonUpdateForm::builder()
-        .public_key(Some(key_pair.public_key))
-        .private_key(Some(Some(key_pair.private_key)))
-        .build();
+      let form = PersonUpdateForm {
+        public_key: Some(key_pair.public_key),
+        private_key: Some(Some(key_pair.private_key)),
+        ..Default::default()
+      };
       Person::update(pool, person_.id, &form).await?;
     }
   }