Replace TypedBuilder with Default in update forms (#3814)

* 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
This commit is contained in:
dullbananas 2023-08-08 02:41:41 -07:00 committed by GitHub
parent a47b12bbde
commit 969f8b2ce9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 492 additions and 333 deletions

View file

@ -38,9 +38,10 @@ pub async fn distinguish_comment(
// Update the Comment // Update the Comment
let comment_id = data.comment_id; let comment_id = data.comment_id;
let form = CommentUpdateForm::builder() let form = CommentUpdateForm {
.distinguished(Some(data.distinguished)) distinguished: Some(data.distinguished),
.build(); ..Default::default()
};
Comment::update(&mut context.pool(), comment_id, &form) Comment::update(&mut context.pool(), comment_id, &form)
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View file

@ -25,9 +25,10 @@ pub async fn hide_community(
let local_user_view = local_user_view_from_jwt(&data.auth, &context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, &context).await?;
is_admin(&local_user_view)?; is_admin(&local_user_view)?;
let community_form = CommunityUpdateForm::builder() let community_form = CommunityUpdateForm {
.hidden(Some(data.hidden)) hidden: Some(data.hidden),
.build(); ..Default::default()
};
let mod_hide_community_form = ModHideCommunityForm { let mod_hide_community_form = ModHideCommunityForm {
community_id: data.community_id, community_id: data.community_id,

View file

@ -32,7 +32,10 @@ impl Perform for AddAdmin {
let added_admin = Person::update( let added_admin = Person::update(
&mut context.pool(), &mut context.pool(),
added_person_id, added_person_id,
&PersonUpdateForm::builder().admin(Some(added)).build(), &PersonUpdateForm {
admin: Some(added),
..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?;

View file

@ -35,10 +35,11 @@ pub async fn ban_from_site(
let person = Person::update( let person = Person::update(
&mut context.pool(), &mut context.pool(),
data.person_id, data.person_id,
&PersonUpdateForm::builder() &PersonUpdateForm {
.banned(Some(data.ban)) banned: Some(data.ban),
.ban_expires(Some(expires)) ban_expires: Some(expires),
.build(), ..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?;

View file

@ -90,14 +90,15 @@ impl Perform for SaveUserSettings {
let default_sort_type = data.default_sort_type; let default_sort_type = data.default_sort_type;
let theme = sanitize_html_opt(&data.theme); let theme = sanitize_html_opt(&data.theme);
let person_form = PersonUpdateForm::builder() let person_form = PersonUpdateForm {
.display_name(display_name) display_name,
.bio(bio) bio,
.matrix_user_id(matrix_user_id) matrix_user_id,
.bot_account(data.bot_account) bot_account: data.bot_account,
.avatar(avatar) avatar,
.banner(banner) banner,
.build(); ..Default::default()
};
Person::update(&mut context.pool(), person_id, &person_form) Person::update(&mut context.pool(), person_id, &person_form)
.await .await
@ -121,26 +122,27 @@ impl Perform for SaveUserSettings {
(None, None) (None, None)
}; };
let local_user_form = LocalUserUpdateForm::builder() let local_user_form = LocalUserUpdateForm {
.email(email) email,
.show_avatars(data.show_avatars) show_avatars: data.show_avatars,
.show_read_posts(data.show_read_posts) show_read_posts: data.show_read_posts,
.show_new_post_notifs(data.show_new_post_notifs) show_new_post_notifs: data.show_new_post_notifs,
.send_notifications_to_email(data.send_notifications_to_email) send_notifications_to_email: data.send_notifications_to_email,
.show_nsfw(data.show_nsfw) show_nsfw: data.show_nsfw,
.blur_nsfw(data.blur_nsfw) blur_nsfw: data.blur_nsfw,
.auto_expand(data.auto_expand) auto_expand: data.auto_expand,
.show_bot_accounts(data.show_bot_accounts) show_bot_accounts: data.show_bot_accounts,
.show_scores(data.show_scores) show_scores: data.show_scores,
.default_sort_type(default_sort_type) default_sort_type,
.default_listing_type(default_listing_type) default_listing_type,
.theme(theme) theme,
.interface_language(data.interface_language.clone()) interface_language: data.interface_language.clone(),
.totp_2fa_secret(totp_2fa_secret) totp_2fa_secret,
.totp_2fa_url(totp_2fa_url) totp_2fa_url,
.open_links_in_new_tab(data.open_links_in_new_tab) open_links_in_new_tab: data.open_links_in_new_tab,
.infinite_scroll_enabled(data.infinite_scroll_enabled) infinite_scroll_enabled: data.infinite_scroll_enabled,
.build(); ..Default::default()
};
let local_user_res = let local_user_res =
LocalUser::update(&mut context.pool(), local_user_id, &local_user_form).await; LocalUser::update(&mut context.pool(), local_user_id, &local_user_form).await;

View file

@ -23,12 +23,13 @@ impl Perform for VerifyEmail {
.await .await
.with_lemmy_type(LemmyErrorType::TokenNotFound)?; .with_lemmy_type(LemmyErrorType::TokenNotFound)?;
let form = LocalUserUpdateForm::builder() let form = LocalUserUpdateForm {
// necessary in case this is a new signup // 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 // necessary in case email of an existing user was changed
.email(Some(Some(verification.email))) email: Some(Some(verification.email)),
.build(); ..Default::default()
};
let local_user_id = verification.local_user_id; let local_user_id = verification.local_user_id;
LocalUser::update(&mut context.pool(), local_user_id, &form).await?; LocalUser::update(&mut context.pool(), local_user_id, &form).await?;

View file

@ -56,13 +56,15 @@ pub async fn feature_post(
// Update the post // Update the post
let post_id = data.post_id; let post_id = data.post_id;
let new_post: PostUpdateForm = if data.feature_type == PostFeatureType::Community { let new_post: PostUpdateForm = if data.feature_type == PostFeatureType::Community {
PostUpdateForm::builder() PostUpdateForm {
.featured_community(Some(data.featured)) featured_community: Some(data.featured),
.build() ..Default::default()
}
} else { } else {
PostUpdateForm::builder() PostUpdateForm {
.featured_local(Some(data.featured)) featured_local: Some(data.featured),
.build() ..Default::default()
}
}; };
let post = Post::update(&mut context.pool(), post_id, &new_post).await?; let post = Post::update(&mut context.pool(), post_id, &new_post).await?;

View file

@ -53,7 +53,10 @@ pub async fn lock_post(
let post = Post::update( let post = Post::update(
&mut context.pool(), &mut context.pool(),
post_id, post_id,
&PostUpdateForm::builder().locked(Some(locked)).build(), &PostUpdateForm {
locked: Some(locked),
..Default::default()
},
) )
.await?; .await?;

View file

@ -38,7 +38,10 @@ impl Perform for MarkPrivateMessageAsRead {
PrivateMessage::update( PrivateMessage::update(
&mut context.pool(), &mut context.pool(),
private_message_id, private_message_id,
&PrivateMessageUpdateForm::builder().read(Some(read)).build(), &PrivateMessageUpdateForm {
read: Some(read),
..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?; .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?;

View file

@ -43,7 +43,10 @@ impl Perform for LeaveAdmin {
Person::update( Person::update(
&mut context.pool(), &mut context.pool(),
person_id, person_id,
&PersonUpdateForm::builder().admin(Some(false)).build(), &PersonUpdateForm {
admin: Some(false),
..Default::default()
},
) )
.await?; .await?;

View file

@ -40,9 +40,10 @@ impl Perform for ApproveRegistrationApplication {
RegistrationApplication::update(&mut context.pool(), app_id, &app_form).await?; RegistrationApplication::update(&mut context.pool(), app_id, &app_form).await?;
// Update the local_user row // Update the local_user row
let local_user_form = LocalUserUpdateForm::builder() let local_user_form = LocalUserUpdateForm {
.accepted_application(Some(data.approve)) accepted_application: Some(data.approve),
.build(); ..Default::default()
};
let approved_user_id = registration_application.local_user_id; let approved_user_id = registration_application.local_user_id;
LocalUser::update(&mut context.pool(), approved_user_id, &local_user_form).await?; LocalUser::update(&mut context.pool(), approved_user_id, &local_user_form).await?;

View file

@ -596,10 +596,11 @@ pub async fn remove_user_data(
Person::update( Person::update(
pool, pool,
banned_person_id, banned_person_id,
&PersonUpdateForm::builder() &PersonUpdateForm {
.avatar(Some(None)) avatar: Some(None),
.banner(Some(None)) banner: Some(None),
.build(), ..Default::default()
},
) )
.await?; .await?;
@ -625,7 +626,10 @@ pub async fn remove_user_data(
Community::update( Community::update(
pool, pool,
community_id, community_id,
&CommunityUpdateForm::builder().removed(Some(true)).build(), &CommunityUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await?; .await?;
@ -642,10 +646,11 @@ pub async fn remove_user_data(
Community::update( Community::update(
pool, pool,
community_id, community_id,
&CommunityUpdateForm::builder() &CommunityUpdateForm {
.icon(Some(None)) icon: Some(None),
.banner(Some(None)) banner: Some(None),
.build(), ..Default::default()
},
) )
.await?; .await?;
} }
@ -679,7 +684,10 @@ pub async fn remove_user_data_in_community(
Comment::update( Comment::update(
pool, pool,
comment_id, comment_id,
&CommentUpdateForm::builder().removed(Some(true)).build(), &CommentUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await?; .await?;
} }

View file

@ -129,7 +129,10 @@ pub async fn create_comment(
let updated_comment = Comment::update( let updated_comment = Comment::update(
&mut context.pool(), &mut context.pool(),
inserted_comment_id, inserted_comment_id,
&CommentUpdateForm::builder().ap_id(Some(apub_id)).build(), &CommentUpdateForm {
ap_id: Some(apub_id),
..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntCreateComment)?; .with_lemmy_type(LemmyErrorType::CouldntCreateComment)?;

View file

@ -49,7 +49,10 @@ pub async fn delete_comment(
let updated_comment = Comment::update( let updated_comment = Comment::update(
&mut context.pool(), &mut context.pool(),
comment_id, comment_id,
&CommentUpdateForm::builder().deleted(Some(deleted)).build(), &CommentUpdateForm {
deleted: Some(deleted),
..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View file

@ -48,7 +48,10 @@ pub async fn remove_comment(
let updated_comment = Comment::update( let updated_comment = Comment::update(
&mut context.pool(), &mut context.pool(),
comment_id, comment_id,
&CommentUpdateForm::builder().removed(Some(removed)).build(), &CommentUpdateForm {
removed: Some(removed),
..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View file

@ -71,11 +71,12 @@ pub async fn update_comment(
let content = sanitize_html_opt(&content); let content = sanitize_html_opt(&content);
let comment_id = data.comment_id; let comment_id = data.comment_id;
let form = CommentUpdateForm::builder() let form = CommentUpdateForm {
.content(content) content,
.language_id(data.language_id) language_id: data.language_id,
.updated(Some(Some(naive_now()))) updated: Some(Some(naive_now())),
.build(); ..Default::default()
};
let updated_comment = Comment::update(&mut context.pool(), comment_id, &form) let updated_comment = Comment::update(&mut context.pool(), comment_id, &form)
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;

View file

@ -35,9 +35,10 @@ pub async fn delete_community(
let community = Community::update( let community = Community::update(
&mut context.pool(), &mut context.pool(),
community_id, community_id,
&CommunityUpdateForm::builder() &CommunityUpdateForm {
.deleted(Some(deleted)) deleted: Some(deleted),
.build(), ..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?;

View file

@ -35,9 +35,10 @@ pub async fn remove_community(
let community = Community::update( let community = Community::update(
&mut context.pool(), &mut context.pool(),
community_id, community_id,
&CommunityUpdateForm::builder() &CommunityUpdateForm {
.removed(Some(removed)) removed: Some(removed),
.build(), ..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?; .with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?;

View file

@ -65,15 +65,16 @@ pub async fn update_community(
CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; CommunityLanguage::update(&mut context.pool(), languages, community_id).await?;
} }
let community_form = CommunityUpdateForm::builder() let community_form = CommunityUpdateForm {
.title(title) title,
.description(description) description,
.icon(icon) icon,
.banner(banner) banner,
.nsfw(data.nsfw) nsfw: data.nsfw,
.posting_restricted_to_mods(data.posting_restricted_to_mods) posting_restricted_to_mods: data.posting_restricted_to_mods,
.updated(Some(Some(naive_now()))) updated: Some(Some(naive_now())),
.build(); ..Default::default()
};
let community_id = data.community_id; let community_id = data.community_id;
let community = Community::update(&mut context.pool(), community_id, &community_form) let community = Community::update(&mut context.pool(), community_id, &community_form)

View file

@ -148,7 +148,10 @@ pub async fn create_post(
let updated_post = Post::update( let updated_post = Post::update(
&mut context.pool(), &mut context.pool(),
inserted_post_id, inserted_post_id,
&PostUpdateForm::builder().ap_id(Some(apub_id)).build(), &PostUpdateForm {
ap_id: Some(apub_id),
..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntCreatePost)?; .with_lemmy_type(LemmyErrorType::CouldntCreatePost)?;

View file

@ -45,9 +45,10 @@ pub async fn delete_post(
let post = Post::update( let post = Post::update(
&mut context.pool(), &mut context.pool(),
data.post_id, data.post_id,
&PostUpdateForm::builder() &PostUpdateForm {
.deleted(Some(data.deleted)) deleted: Some(data.deleted),
.build(), ..Default::default()
},
) )
.await?; .await?;

View file

@ -47,7 +47,10 @@ pub async fn remove_post(
let post = Post::update( let post = Post::update(
&mut context.pool(), &mut context.pool(),
post_id, post_id,
&PostUpdateForm::builder().removed(Some(removed)).build(), &PostUpdateForm {
removed: Some(removed),
..Default::default()
},
) )
.await?; .await?;

View file

@ -93,18 +93,19 @@ pub async fn update_post(
) )
.await?; .await?;
let post_form = PostUpdateForm::builder() let post_form = PostUpdateForm {
.name(name) name,
.url(url) url,
.body(body) body,
.nsfw(data.nsfw) nsfw: data.nsfw,
.embed_title(embed_title) embed_title,
.embed_description(embed_description) embed_description,
.embed_video_url(embed_video_url) embed_video_url,
.language_id(data.language_id) language_id: data.language_id,
.thumbnail_url(Some(thumbnail_url)) thumbnail_url: Some(thumbnail_url),
.updated(Some(Some(naive_now()))) updated: Some(Some(naive_now())),
.build(); ..Default::default()
};
let post_id = data.post_id; let post_id = data.post_id;
let updated_post = Post::update(&mut context.pool(), post_id, &post_form) let updated_post = Post::update(&mut context.pool(), post_id, &post_form)

View file

@ -67,9 +67,10 @@ pub async fn create_private_message(
PrivateMessage::update( PrivateMessage::update(
&mut context.pool(), &mut context.pool(),
inserted_private_message.id, inserted_private_message.id,
&PrivateMessageUpdateForm::builder() &PrivateMessageUpdateForm {
.ap_id(Some(apub_id)) ap_id: Some(apub_id),
.build(), ..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntCreatePrivateMessage)?; .with_lemmy_type(LemmyErrorType::CouldntCreatePrivateMessage)?;

View file

@ -33,9 +33,10 @@ pub async fn delete_private_message(
let private_message = PrivateMessage::update( let private_message = PrivateMessage::update(
&mut context.pool(), &mut context.pool(),
private_message_id, private_message_id,
&PrivateMessageUpdateForm::builder() &PrivateMessageUpdateForm {
.deleted(Some(deleted)) deleted: Some(deleted),
.build(), ..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?; .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?;

View file

@ -44,10 +44,11 @@ pub async fn update_private_message(
PrivateMessage::update( PrivateMessage::update(
&mut context.pool(), &mut context.pool(),
private_message_id, private_message_id,
&PrivateMessageUpdateForm::builder() &PrivateMessageUpdateForm {
.content(Some(content)) content: Some(content),
.updated(Some(Some(naive_now()))) updated: Some(Some(naive_now())),
.build(), ..Default::default()
},
) )
.await .await
.with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?; .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?;

View file

@ -60,18 +60,19 @@ pub async fn create_site(
let sidebar = sanitize_html_opt(&data.sidebar); let sidebar = sanitize_html_opt(&data.sidebar);
let description = sanitize_html_opt(&data.description); let description = sanitize_html_opt(&data.description);
let site_form = SiteUpdateForm::builder() let site_form = SiteUpdateForm {
.name(Some(name)) name: Some(name),
.sidebar(diesel_option_overwrite(sidebar)) sidebar: diesel_option_overwrite(sidebar),
.description(diesel_option_overwrite(description)) description: diesel_option_overwrite(description),
.icon(diesel_option_overwrite_to_url(&data.icon)?) icon: diesel_option_overwrite_to_url(&data.icon)?,
.banner(diesel_option_overwrite_to_url(&data.banner)?) banner: diesel_option_overwrite_to_url(&data.banner)?,
.actor_id(Some(actor_id)) actor_id: Some(actor_id),
.last_refreshed_at(Some(naive_now())) last_refreshed_at: Some(naive_now()),
.inbox_url(inbox_url) inbox_url,
.private_key(Some(Some(keypair.private_key))) private_key: Some(Some(keypair.private_key)),
.public_key(Some(keypair.public_key)) public_key: Some(keypair.public_key),
.build(); ..Default::default()
};
let site_id = local_site.site_id; 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 default_theme = sanitize_html_opt(&data.default_theme);
let legal_information = sanitize_html_opt(&data.legal_information); 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 // Set the site setup to true
.site_setup(Some(true)) site_setup: Some(true),
.enable_downvotes(data.enable_downvotes) enable_downvotes: data.enable_downvotes,
.registration_mode(data.registration_mode) registration_mode: data.registration_mode,
.enable_nsfw(data.enable_nsfw) enable_nsfw: data.enable_nsfw,
.community_creation_admin_only(data.community_creation_admin_only) community_creation_admin_only: data.community_creation_admin_only,
.require_email_verification(data.require_email_verification) require_email_verification: data.require_email_verification,
.application_question(diesel_option_overwrite(application_question)) application_question: diesel_option_overwrite(application_question),
.private_instance(data.private_instance) private_instance: data.private_instance,
.default_theme(default_theme) default_theme,
.default_post_listing_type(data.default_post_listing_type) default_post_listing_type: data.default_post_listing_type,
.legal_information(diesel_option_overwrite(legal_information)) legal_information: diesel_option_overwrite(legal_information),
.application_email_admins(data.application_email_admins) application_email_admins: data.application_email_admins,
.hide_modlog_mod_names(data.hide_modlog_mod_names) hide_modlog_mod_names: data.hide_modlog_mod_names,
.updated(Some(Some(naive_now()))) updated: Some(Some(naive_now())),
.slur_filter_regex(diesel_option_overwrite(data.slur_filter_regex.clone())) slur_filter_regex: diesel_option_overwrite(data.slur_filter_regex.clone()),
.actor_name_max_length(data.actor_name_max_length) actor_name_max_length: data.actor_name_max_length,
.federation_enabled(data.federation_enabled) federation_enabled: data.federation_enabled,
.captcha_enabled(data.captcha_enabled) captcha_enabled: data.captcha_enabled,
.captcha_difficulty(data.captcha_difficulty.clone()) captcha_difficulty: data.captcha_difficulty.clone(),
.build(); ..Default::default()
};
LocalSite::update(&mut context.pool(), &local_site_form).await?; LocalSite::update(&mut context.pool(), &local_site_form).await?;
let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm::builder() let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
.message(data.rate_limit_message) message: data.rate_limit_message,
.message_per_second(data.rate_limit_message_per_second) message_per_second: data.rate_limit_message_per_second,
.post(data.rate_limit_post) post: data.rate_limit_post,
.post_per_second(data.rate_limit_post_per_second) post_per_second: data.rate_limit_post_per_second,
.register(data.rate_limit_register) register: data.rate_limit_register,
.register_per_second(data.rate_limit_register_per_second) register_per_second: data.rate_limit_register_per_second,
.image(data.rate_limit_image) image: data.rate_limit_image,
.image_per_second(data.rate_limit_image_per_second) image_per_second: data.rate_limit_image_per_second,
.comment(data.rate_limit_comment) comment: data.rate_limit_comment,
.comment_per_second(data.rate_limit_comment_per_second) comment_per_second: data.rate_limit_comment_per_second,
.search(data.rate_limit_search) search: data.rate_limit_search,
.search_per_second(data.rate_limit_search_per_second) search_per_second: data.rate_limit_search_per_second,
.build(); ..Default::default()
};
LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form).await?; LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form).await?;

View file

@ -63,14 +63,15 @@ pub async fn update_site(
let sidebar = sanitize_html_opt(&data.sidebar); let sidebar = sanitize_html_opt(&data.sidebar);
let description = sanitize_html_opt(&data.description); let description = sanitize_html_opt(&data.description);
let site_form = SiteUpdateForm::builder() let site_form = SiteUpdateForm {
.name(name) name,
.sidebar(diesel_option_overwrite(sidebar)) sidebar: diesel_option_overwrite(sidebar),
.description(diesel_option_overwrite(description)) description: diesel_option_overwrite(description),
.icon(diesel_option_overwrite_to_url(&data.icon)?) icon: diesel_option_overwrite_to_url(&data.icon)?,
.banner(diesel_option_overwrite_to_url(&data.banner)?) banner: diesel_option_overwrite_to_url(&data.banner)?,
.updated(Some(Some(naive_now()))) updated: Some(Some(naive_now())),
.build(); ..Default::default()
};
Site::update(&mut context.pool(), site.id, &site_form) Site::update(&mut context.pool(), site.id, &site_form)
.await .await
@ -82,46 +83,48 @@ pub async fn update_site(
let default_theme = sanitize_html_opt(&data.default_theme); let default_theme = sanitize_html_opt(&data.default_theme);
let legal_information = sanitize_html_opt(&data.legal_information); let legal_information = sanitize_html_opt(&data.legal_information);
let local_site_form = LocalSiteUpdateForm::builder() let local_site_form = LocalSiteUpdateForm {
.enable_downvotes(data.enable_downvotes) enable_downvotes: data.enable_downvotes,
.registration_mode(data.registration_mode) registration_mode: data.registration_mode,
.enable_nsfw(data.enable_nsfw) enable_nsfw: data.enable_nsfw,
.community_creation_admin_only(data.community_creation_admin_only) community_creation_admin_only: data.community_creation_admin_only,
.require_email_verification(data.require_email_verification) require_email_verification: data.require_email_verification,
.application_question(diesel_option_overwrite(application_question)) application_question: diesel_option_overwrite(application_question),
.private_instance(data.private_instance) private_instance: data.private_instance,
.default_theme(default_theme) default_theme,
.default_post_listing_type(data.default_post_listing_type) default_post_listing_type: data.default_post_listing_type,
.legal_information(diesel_option_overwrite(legal_information)) legal_information: diesel_option_overwrite(legal_information),
.application_email_admins(data.application_email_admins) application_email_admins: data.application_email_admins,
.hide_modlog_mod_names(data.hide_modlog_mod_names) hide_modlog_mod_names: data.hide_modlog_mod_names,
.updated(Some(Some(naive_now()))) updated: Some(Some(naive_now())),
.slur_filter_regex(diesel_option_overwrite(data.slur_filter_regex.clone())) slur_filter_regex: diesel_option_overwrite(data.slur_filter_regex.clone()),
.actor_name_max_length(data.actor_name_max_length) actor_name_max_length: data.actor_name_max_length,
.federation_enabled(data.federation_enabled) federation_enabled: data.federation_enabled,
.captcha_enabled(data.captcha_enabled) captcha_enabled: data.captcha_enabled,
.captcha_difficulty(data.captcha_difficulty.clone()) captcha_difficulty: data.captcha_difficulty.clone(),
.reports_email_admins(data.reports_email_admins) reports_email_admins: data.reports_email_admins,
.build(); ..Default::default()
};
let update_local_site = LocalSite::update(&mut context.pool(), &local_site_form) let update_local_site = LocalSite::update(&mut context.pool(), &local_site_form)
.await .await
.ok(); .ok();
let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm::builder() let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
.message(data.rate_limit_message) message: data.rate_limit_message,
.message_per_second(data.rate_limit_message_per_second) message_per_second: data.rate_limit_message_per_second,
.post(data.rate_limit_post) post: data.rate_limit_post,
.post_per_second(data.rate_limit_post_per_second) post_per_second: data.rate_limit_post_per_second,
.register(data.rate_limit_register) register: data.rate_limit_register,
.register_per_second(data.rate_limit_register_per_second) register_per_second: data.rate_limit_register_per_second,
.image(data.rate_limit_image) image: data.rate_limit_image,
.image_per_second(data.rate_limit_image_per_second) image_per_second: data.rate_limit_image_per_second,
.comment(data.rate_limit_comment) comment: data.rate_limit_comment,
.comment_per_second(data.rate_limit_comment_per_second) comment_per_second: data.rate_limit_comment_per_second,
.search(data.rate_limit_search) search: data.rate_limit_search,
.search_per_second(data.rate_limit_search_per_second) search_per_second: data.rate_limit_search_per_second,
.build(); ..Default::default()
};
LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form) LocalSiteRateLimit::update(&mut context.pool(), &local_site_rate_limit_form)
.await .await

View file

@ -157,10 +157,11 @@ impl ActivityHandler for BlockUser {
let blocked_person = Person::update( let blocked_person = Person::update(
&mut context.pool(), &mut context.pool(),
blocked_person.id, blocked_person.id,
&PersonUpdateForm::builder() &PersonUpdateForm {
.banned(Some(true)) banned: Some(true),
.ban_expires(Some(expires)) ban_expires: Some(expires),
.build(), ..Default::default()
},
) )
.await?; .await?;
if self.remove_data.unwrap_or(false) { if self.remove_data.unwrap_or(false) {

View file

@ -105,10 +105,11 @@ impl ActivityHandler for UndoBlockUser {
let blocked_person = Person::update( let blocked_person = Person::update(
&mut context.pool(), &mut context.pool(),
blocked_person.id, blocked_person.id,
&PersonUpdateForm::builder() &PersonUpdateForm {
.banned(Some(false)) banned: Some(false),
.ban_expires(Some(expires)) ban_expires: Some(expires),
.build(), ..Default::default()
},
) )
.await?; .await?;

View file

@ -153,9 +153,10 @@ impl ActivityHandler for CollectionAdd {
let post = ObjectId::<ApubPost>::from(self.object) let post = ObjectId::<ApubPost>::from(self.object)
.dereference(context) .dereference(context)
.await?; .await?;
let form = PostUpdateForm::builder() let form = PostUpdateForm {
.featured_community(Some(true)) featured_community: Some(true),
.build(); ..Default::default()
};
Post::update(&mut context.pool(), post.id, &form).await?; Post::update(&mut context.pool(), post.id, &form).await?;
} }
} }

View file

@ -141,9 +141,10 @@ impl ActivityHandler for CollectionRemove {
let post = ObjectId::<ApubPost>::from(self.object) let post = ObjectId::<ApubPost>::from(self.object)
.dereference(context) .dereference(context)
.await?; .await?;
let form = PostUpdateForm::builder() let form = PostUpdateForm {
.featured_community(Some(false)) featured_community: Some(false),
.build(); ..Default::default()
};
Post::update(&mut context.pool(), post.id, &form).await?; Post::update(&mut context.pool(), post.id, &form).await?;
} }
} }

View file

@ -56,7 +56,10 @@ impl ActivityHandler for LockPage {
} }
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> { 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?; let post = self.object.dereference(context).await?;
Post::update(&mut context.pool(), post.id, &form).await?; Post::update(&mut context.pool(), post.id, &form).await?;
Ok(()) Ok(())
@ -93,7 +96,10 @@ impl ActivityHandler for UndoLockPage {
} }
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> { 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?; let post = self.object.object.dereference(context).await?;
Post::update(&mut context.pool(), post.id, &form).await?; Post::update(&mut context.pool(), post.id, &form).await?;
Ok(()) Ok(())

View file

@ -123,7 +123,10 @@ pub(in crate::activities) async fn receive_remove_action(
Community::update( Community::update(
&mut context.pool(), &mut context.pool(),
community.id, community.id,
&CommunityUpdateForm::builder().removed(Some(true)).build(), &CommunityUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await?; .await?;
} }
@ -138,7 +141,10 @@ pub(in crate::activities) async fn receive_remove_action(
Post::update( Post::update(
&mut context.pool(), &mut context.pool(),
post.id, post.id,
&PostUpdateForm::builder().removed(Some(true)).build(), &PostUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await?; .await?;
} }
@ -153,7 +159,10 @@ pub(in crate::activities) async fn receive_remove_action(
Comment::update( Comment::update(
&mut context.pool(), &mut context.pool(),
comment.id, comment.id,
&CommentUpdateForm::builder().removed(Some(true)).build(), &CommentUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await?; .await?;
} }

View file

@ -258,9 +258,10 @@ async fn receive_delete_action(
Community::update( Community::update(
&mut context.pool(), &mut context.pool(),
community.id, community.id,
&CommunityUpdateForm::builder() &CommunityUpdateForm {
.deleted(Some(deleted)) deleted: Some(deleted),
.build(), ..Default::default()
},
) )
.await?; .await?;
} }
@ -269,7 +270,10 @@ async fn receive_delete_action(
Post::update( Post::update(
&mut context.pool(), &mut context.pool(),
post.id, post.id,
&PostUpdateForm::builder().deleted(Some(deleted)).build(), &PostUpdateForm {
deleted: Some(deleted),
..Default::default()
},
) )
.await?; .await?;
} }
@ -279,7 +283,10 @@ async fn receive_delete_action(
Comment::update( Comment::update(
&mut context.pool(), &mut context.pool(),
comment.id, comment.id,
&CommentUpdateForm::builder().deleted(Some(deleted)).build(), &CommentUpdateForm {
deleted: Some(deleted),
..Default::default()
},
) )
.await?; .await?;
} }
@ -288,9 +295,10 @@ async fn receive_delete_action(
PrivateMessage::update( PrivateMessage::update(
&mut context.pool(), &mut context.pool(),
pm.id, pm.id,
&PrivateMessageUpdateForm::builder() &PrivateMessageUpdateForm {
.deleted(Some(deleted)) deleted: Some(deleted),
.build(), ..Default::default()
},
) )
.await?; .await?;
} }

View file

@ -113,7 +113,10 @@ impl UndoDelete {
Community::update( Community::update(
&mut context.pool(), &mut context.pool(),
community.id, community.id,
&CommunityUpdateForm::builder().removed(Some(false)).build(), &CommunityUpdateForm {
removed: Some(false),
..Default::default()
},
) )
.await?; .await?;
} }
@ -128,7 +131,10 @@ impl UndoDelete {
Post::update( Post::update(
&mut context.pool(), &mut context.pool(),
post.id, post.id,
&PostUpdateForm::builder().removed(Some(false)).build(), &PostUpdateForm {
removed: Some(false),
..Default::default()
},
) )
.await?; .await?;
} }
@ -143,7 +149,10 @@ impl UndoDelete {
Comment::update( Comment::update(
&mut context.pool(), &mut context.pool(),
comment.id, comment.id,
&CommentUpdateForm::builder().removed(Some(false)).build(), &CommentUpdateForm {
removed: Some(false),
..Default::default()
},
) )
.await?; .await?;
} }

View file

@ -78,7 +78,10 @@ impl Object for ApubComment {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
if !self.deleted { 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?; Comment::update(&mut context.pool(), self.id, &form).await?;
} }
Ok(()) Ok(())

View file

@ -74,7 +74,10 @@ impl Object for ApubCommunity {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { 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?; Community::update(&mut context.pool(), self.id, &form).await?;
Ok(()) Ok(())
} }

View file

@ -77,7 +77,10 @@ impl Object for ApubPerson {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { 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?; DbPerson::update(&mut context.pool(), self.id, &form).await?;
Ok(()) Ok(())
} }

View file

@ -99,7 +99,10 @@ impl Object for ApubPost {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { async fn delete(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
if !self.deleted { 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?; Post::update(&mut context.pool(), self.id, &form).await?;
} }
Ok(()) Ok(())

View file

@ -145,14 +145,20 @@ mod tests {
Comment::update( Comment::update(
pool, pool,
inserted_comment.id, inserted_comment.id,
&CommentUpdateForm::builder().removed(Some(true)).build(), &CommentUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
Comment::update( Comment::update(
pool, pool,
inserted_child_comment.id, inserted_child_comment.id,
&CommentUpdateForm::builder().removed(Some(true)).build(), &CommentUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();

View file

@ -235,7 +235,10 @@ mod tests {
Comment::update( Comment::update(
pool, pool,
inserted_comment.id, inserted_comment.id,
&CommentUpdateForm::builder().removed(Some(true)).build(), &CommentUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
@ -246,7 +249,10 @@ mod tests {
Comment::update( Comment::update(
pool, pool,
inserted_comment.id, inserted_comment.id,
&CommentUpdateForm::builder().removed(Some(false)).build(), &CommentUpdateForm {
removed: Some(false),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
@ -254,7 +260,10 @@ mod tests {
Comment::update( Comment::update(
pool, pool,
inserted_comment.id, inserted_comment.id,
&CommentUpdateForm::builder().deleted(Some(true)).build(), &CommentUpdateForm {
deleted: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
@ -265,7 +274,10 @@ mod tests {
Comment::update( Comment::update(
pool, pool,
inserted_comment.id, inserted_comment.id,
&CommentUpdateForm::builder().removed(Some(true)).build(), &CommentUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();

View file

@ -160,7 +160,10 @@ mod tests {
Community::update( Community::update(
pool, pool,
inserted_community.id, inserted_community.id,
&CommunityUpdateForm::builder().deleted(Some(true)).build(), &CommunityUpdateForm {
deleted: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
@ -171,7 +174,10 @@ mod tests {
Community::update( Community::update(
pool, pool,
inserted_community.id, inserted_community.id,
&CommunityUpdateForm::builder().deleted(Some(false)).build(), &CommunityUpdateForm {
deleted: Some(false),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
@ -179,7 +185,10 @@ mod tests {
Community::update( Community::update(
pool, pool,
inserted_community.id, inserted_community.id,
&CommunityUpdateForm::builder().removed(Some(true)).build(), &CommunityUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
@ -190,7 +199,10 @@ mod tests {
Community::update( Community::update(
pool, pool,
inserted_community.id, inserted_community.id,
&CommunityUpdateForm::builder().deleted(Some(true)).build(), &CommunityUpdateForm {
deleted: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();

View file

@ -372,9 +372,10 @@ mod tests {
published: inserted_comment_saved.published, published: inserted_comment_saved.published,
}; };
let comment_update_form = CommentUpdateForm::builder() let comment_update_form = CommentUpdateForm {
.content(Some("A test comment".into())) content: Some("A test comment".into()),
.build(); ..Default::default()
};
let updated_comment = Comment::update(pool, inserted_comment.id, &comment_update_form) let updated_comment = Comment::update(pool, inserted_comment.id, &comment_update_form)
.await .await

View file

@ -475,9 +475,10 @@ mod tests {
let read_community = Community::read(pool, inserted_community.id).await.unwrap(); let read_community = Community::read(pool, inserted_community.id).await.unwrap();
let update_community_form = CommunityUpdateForm::builder() let update_community_form = CommunityUpdateForm {
.title(Some("nada".to_owned())) title: Some("nada".to_owned()),
.build(); ..Default::default()
};
let updated_community = Community::update(pool, inserted_community.id, &update_community_form) let updated_community = Community::update(pool, inserted_community.id, &update_community_form)
.await .await
.unwrap(); .unwrap();

View file

@ -253,9 +253,10 @@ mod tests {
let read_person = Person::read(pool, inserted_person.id).await.unwrap(); let read_person = Person::read(pool, inserted_person.id).await.unwrap();
let update_person_form = PersonUpdateForm::builder() let update_person_form = PersonUpdateForm {
.actor_id(Some(inserted_person.actor_id.clone())) actor_id: Some(inserted_person.actor_id.clone()),
.build(); ..Default::default()
};
let updated_person = Person::update(pool, inserted_person.id, &update_person_form) let updated_person = Person::update(pool, inserted_person.id, &update_person_form)
.await .await
.unwrap(); .unwrap();

View file

@ -453,9 +453,10 @@ mod tests {
let read_post = Post::read(pool, inserted_post.id).await.unwrap(); let read_post = Post::read(pool, inserted_post.id).await.unwrap();
let new_post_update = PostUpdateForm::builder() let new_post_update = PostUpdateForm {
.name(Some("A test post".into())) name: Some("A test post".into()),
.build(); ..Default::default()
};
let updated_post = Post::update(pool, inserted_post.id, &new_post_update) let updated_post = Post::update(pool, inserted_post.id, &new_post_update)
.await .await
.unwrap(); .unwrap();

View file

@ -142,9 +142,10 @@ mod tests {
.await .await
.unwrap(); .unwrap();
let private_message_update_form = PrivateMessageUpdateForm::builder() let private_message_update_form = PrivateMessageUpdateForm {
.content(Some("A test private message".into())) content: Some("A test private message".into()),
.build(); ..Default::default()
};
let updated_private_message = PrivateMessage::update( let updated_private_message = PrivateMessage::update(
pool, pool,
inserted_private_message.id, inserted_private_message.id,
@ -156,16 +157,20 @@ mod tests {
let deleted_private_message = PrivateMessage::update( let deleted_private_message = PrivateMessage::update(
pool, pool,
inserted_private_message.id, inserted_private_message.id,
&PrivateMessageUpdateForm::builder() &PrivateMessageUpdateForm {
.deleted(Some(true)) deleted: Some(true),
.build(), ..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
let marked_read_private_message = PrivateMessage::update( let marked_read_private_message = PrivateMessage::update(
pool, pool,
inserted_private_message.id, inserted_private_message.id,
&PrivateMessageUpdateForm::builder().read(Some(true)).build(), &PrivateMessageUpdateForm {
read: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();

View file

@ -66,8 +66,7 @@ pub struct CommentInsertForm {
pub language_id: Option<LanguageId>, pub language_id: Option<LanguageId>,
} }
#[derive(Debug, Clone, TypedBuilder)] #[derive(Debug, Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = comment))] #[cfg_attr(feature = "full", diesel(table_name = comment))]
pub struct CommentUpdateForm { pub struct CommentUpdateForm {

View file

@ -97,8 +97,7 @@ pub struct CommunityInsertForm {
pub instance_id: InstanceId, pub instance_id: InstanceId,
} }
#[derive(Debug, Clone, TypedBuilder)] #[derive(Debug, Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = community))] #[cfg_attr(feature = "full", diesel(table_name = community))]
pub struct CommunityUpdateForm { pub struct CommunityUpdateForm {

View file

@ -89,8 +89,7 @@ pub struct LocalSiteInsertForm {
pub reports_email_admins: Option<bool>, pub reports_email_admins: Option<bool>,
} }
#[derive(Clone, TypedBuilder)] #[derive(Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = local_site))] #[cfg_attr(feature = "full", diesel(table_name = local_site))]
pub struct LocalSiteUpdateForm { pub struct LocalSiteUpdateForm {

View file

@ -57,8 +57,7 @@ pub struct LocalSiteRateLimitInsertForm {
pub search_per_second: Option<i32>, pub search_per_second: Option<i32>,
} }
#[derive(Clone, TypedBuilder)] #[derive(Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))] #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
pub struct LocalSiteRateLimitUpdateForm { pub struct LocalSiteRateLimitUpdateForm {

View file

@ -90,8 +90,7 @@ pub struct LocalUserInsertForm {
pub infinite_scroll_enabled: Option<bool>, pub infinite_scroll_enabled: Option<bool>,
} }
#[derive(Clone, TypedBuilder)] #[derive(Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = local_user))] #[cfg_attr(feature = "full", diesel(table_name = local_user))]
pub struct LocalUserUpdateForm { pub struct LocalUserUpdateForm {

View file

@ -89,10 +89,9 @@ pub struct PersonInsertForm {
pub ban_expires: Option<chrono::NaiveDateTime>, pub ban_expires: Option<chrono::NaiveDateTime>,
} }
#[derive(Clone, TypedBuilder)] #[derive(Clone, Default)]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = person))] #[cfg_attr(feature = "full", diesel(table_name = person))]
#[builder(field_defaults(default))]
pub struct PersonUpdateForm { pub struct PersonUpdateForm {
pub display_name: Option<Option<String>>, pub display_name: Option<Option<String>>,
pub avatar: Option<Option<DbUrl>>, pub avatar: Option<Option<DbUrl>>,

View file

@ -85,8 +85,7 @@ pub struct PostInsertForm {
pub featured_local: Option<bool>, pub featured_local: Option<bool>,
} }
#[derive(Debug, Clone, TypedBuilder)] #[derive(Debug, Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = post))] #[cfg_attr(feature = "full", diesel(table_name = post))]
pub struct PostUpdateForm { pub struct PostUpdateForm {

View file

@ -49,8 +49,7 @@ pub struct PrivateMessageInsertForm {
pub local: Option<bool>, pub local: Option<bool>,
} }
#[derive(Clone, TypedBuilder)] #[derive(Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = private_message))] #[cfg_attr(feature = "full", diesel(table_name = private_message))]
pub struct PrivateMessageUpdateForm { pub struct PrivateMessageUpdateForm {

View file

@ -59,8 +59,7 @@ pub struct SiteInsertForm {
pub instance_id: InstanceId, pub instance_id: InstanceId,
} }
#[derive(Clone, TypedBuilder)] #[derive(Clone, Default)]
#[builder(field_defaults(default))]
#[cfg_attr(feature = "full", derive(AsChangeset))] #[cfg_attr(feature = "full", derive(AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = site))] #[cfg_attr(feature = "full", diesel(table_name = site))]
pub struct SiteUpdateForm { pub struct SiteUpdateForm {

View file

@ -608,9 +608,10 @@ mod tests {
let pool = &mut pool.into(); let pool = &mut pool.into();
let mut data = init_data(pool).await; let mut data = init_data(pool).await;
let local_user_form = LocalUserUpdateForm::builder() let local_user_form = LocalUserUpdateForm {
.show_bot_accounts(Some(false)) show_bot_accounts: Some(false),
.build(); ..Default::default()
};
let inserted_local_user = let inserted_local_user =
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form) LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form)
.await .await
@ -648,9 +649,10 @@ mod tests {
post_listing_single_with_person post_listing_single_with_person
); );
let local_user_form = LocalUserUpdateForm::builder() let local_user_form = LocalUserUpdateForm {
.show_bot_accounts(Some(true)) show_bot_accounts: Some(true),
.build(); ..Default::default()
};
let inserted_local_user = let inserted_local_user =
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form) LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form)
.await .await
@ -780,9 +782,10 @@ mod tests {
expected_post_with_upvote.counts.upvotes = 1; expected_post_with_upvote.counts.upvotes = 1;
assert_eq!(expected_post_with_upvote, post_listing_single_with_person); assert_eq!(expected_post_with_upvote, post_listing_single_with_person);
let local_user_form = LocalUserUpdateForm::builder() let local_user_form = LocalUserUpdateForm {
.show_bot_accounts(Some(false)) show_bot_accounts: Some(false),
.build(); ..Default::default()
};
let inserted_local_user = let inserted_local_user =
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form) LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form)
.await .await
@ -925,7 +928,10 @@ mod tests {
Post::update( Post::update(
pool, pool,
data.inserted_post.id, data.inserted_post.id,
&PostUpdateForm::builder().removed(Some(true)).build(), &PostUpdateForm {
removed: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();
@ -968,7 +974,10 @@ mod tests {
Post::update( Post::update(
pool, pool,
data.inserted_post.id, data.inserted_post.id,
&PostUpdateForm::builder().deleted(Some(true)).build(), &PostUpdateForm {
deleted: Some(true),
..Default::default()
},
) )
.await .await
.unwrap(); .unwrap();

View file

@ -350,9 +350,10 @@ mod tests {
.unwrap(); .unwrap();
// Update the local_user row // Update the local_user row
let approve_local_user_form = LocalUserUpdateForm::builder() let approve_local_user_form = LocalUserUpdateForm {
.accepted_application(Some(true)) accepted_application: Some(true),
.build(); ..Default::default()
};
LocalUser::update(pool, inserted_sara_local_user.id, &approve_local_user_form) LocalUser::update(pool, inserted_sara_local_user.id, &approve_local_user_form)
.await .await

View file

@ -77,16 +77,17 @@ async fn user_updates_2020_04_02(
for cperson in &incorrect_persons { for cperson in &incorrect_persons {
let keypair = generate_actor_keypair()?; let keypair = generate_actor_keypair()?;
let form = PersonUpdateForm::builder() let form = PersonUpdateForm {
.actor_id(Some(generate_local_apub_endpoint( actor_id: Some(generate_local_apub_endpoint(
EndpointType::Person, EndpointType::Person,
&cperson.name, &cperson.name,
protocol_and_hostname, protocol_and_hostname,
)?)) )?),
.private_key(Some(Some(keypair.private_key))) private_key: Some(Some(keypair.private_key)),
.public_key(Some(keypair.public_key)) public_key: Some(keypair.public_key),
.last_refreshed_at(Some(naive_now())) last_refreshed_at: Some(naive_now()),
.build(); ..Default::default()
};
Person::update(pool, cperson.id, &form).await?; Person::update(pool, cperson.id, &form).await?;
} }
@ -120,12 +121,13 @@ async fn community_updates_2020_04_02(
protocol_and_hostname, protocol_and_hostname,
)?; )?;
let form = CommunityUpdateForm::builder() let form = CommunityUpdateForm {
.actor_id(Some(community_actor_id.clone())) actor_id: Some(community_actor_id.clone()),
.private_key(Some(Some(keypair.private_key))) private_key: Some(Some(keypair.private_key)),
.public_key(Some(keypair.public_key)) public_key: Some(keypair.public_key),
.last_refreshed_at(Some(naive_now())) last_refreshed_at: Some(naive_now()),
.build(); ..Default::default()
};
Community::update(pool, ccommunity.id, &form).await?; Community::update(pool, ccommunity.id, &form).await?;
} }
@ -160,7 +162,10 @@ async fn post_updates_2020_04_03(
Post::update( Post::update(
pool, pool,
cpost.id, cpost.id,
&PostUpdateForm::builder().ap_id(Some(apub_id)).build(), &PostUpdateForm {
ap_id: Some(apub_id),
..Default::default()
},
) )
.await?; .await?;
} }
@ -195,7 +200,10 @@ async fn comment_updates_2020_04_03(
Comment::update( Comment::update(
pool, pool,
ccomment.id, ccomment.id,
&CommentUpdateForm::builder().ap_id(Some(apub_id)).build(), &CommentUpdateForm {
ap_id: Some(apub_id),
..Default::default()
},
) )
.await?; .await?;
} }
@ -230,9 +238,10 @@ async fn private_message_updates_2020_05_05(
PrivateMessage::update( PrivateMessage::update(
pool, pool,
cpm.id, cpm.id,
&PrivateMessageUpdateForm::builder() &PrivateMessageUpdateForm {
.ap_id(Some(apub_id)) ap_id: Some(apub_id),
.build(), ..Default::default()
},
) )
.await?; .await?;
} }
@ -344,13 +353,14 @@ async fn instance_actor_2022_01_28(
} }
let key_pair = generate_actor_keypair()?; let key_pair = generate_actor_keypair()?;
let actor_id = Url::parse(protocol_and_hostname)?; let actor_id = Url::parse(protocol_and_hostname)?;
let site_form = SiteUpdateForm::builder() let site_form = SiteUpdateForm {
.actor_id(Some(actor_id.clone().into())) actor_id: Some(actor_id.clone().into()),
.last_refreshed_at(Some(naive_now())) last_refreshed_at: Some(naive_now()),
.inbox_url(Some(generate_site_inbox_url(&actor_id.into())?)) inbox_url: Some(generate_site_inbox_url(&actor_id.into())?),
.private_key(Some(Some(key_pair.private_key))) private_key: Some(Some(key_pair.private_key)),
.public_key(Some(key_pair.public_key)) public_key: Some(key_pair.public_key),
.build(); ..Default::default()
};
Site::update(pool, site.id, &site_form).await?; Site::update(pool, site.id, &site_form).await?;
} }
Ok(()) Ok(())
@ -379,10 +389,11 @@ async fn regenerate_public_keys_2022_07_05(pool: &mut DbPool<'_>) -> Result<(),
community_.name community_.name
); );
let key_pair = generate_actor_keypair()?; let key_pair = generate_actor_keypair()?;
let form = CommunityUpdateForm::builder() let form = CommunityUpdateForm {
.public_key(Some(key_pair.public_key)) public_key: Some(key_pair.public_key),
.private_key(Some(Some(key_pair.private_key))) private_key: Some(Some(key_pair.private_key)),
.build(); ..Default::default()
};
Community::update(&mut conn.into(), community_.id, &form).await?; 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 person_.name
); );
let key_pair = generate_actor_keypair()?; let key_pair = generate_actor_keypair()?;
let form = PersonUpdateForm::builder() let form = PersonUpdateForm {
.public_key(Some(key_pair.public_key)) public_key: Some(key_pair.public_key),
.private_key(Some(Some(key_pair.private_key))) private_key: Some(Some(key_pair.private_key)),
.build(); ..Default::default()
};
Person::update(pool, person_.id, &form).await?; Person::update(pool, person_.id, &form).await?;
} }
} }