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:
parent
a47b12bbde
commit
969f8b2ce9
60 changed files with 492 additions and 333 deletions
|
@ -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)?;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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?;
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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?;
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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>>,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue