// 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)?;
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,
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)?;
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)?;
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
(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;
.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?;
// 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?;
let post = Post::update(
&mut context.pool(),
post_id,
- &PostUpdateForm::builder().locked(Some(locked)).build(),
+ &PostUpdateForm {
+ locked: Some(locked),
+ ..Default::default()
+ },
)
.await?;
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)?;
Person::update(
&mut context.pool(),
person_id,
- &PersonUpdateForm::builder().admin(Some(false)).build(),
+ &PersonUpdateForm {
+ admin: Some(false),
+ ..Default::default()
+ },
)
.await?;
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?;
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?;
Community::update(
pool,
community_id,
- &CommunityUpdateForm::builder().removed(Some(true)).build(),
+ &CommunityUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await?;
Community::update(
pool,
community_id,
- &CommunityUpdateForm::builder()
- .icon(Some(None))
- .banner(Some(None))
- .build(),
+ &CommunityUpdateForm {
+ icon: Some(None),
+ banner: Some(None),
+ ..Default::default()
+ },
)
.await?;
}
Comment::update(
pool,
comment_id,
- &CommentUpdateForm::builder().removed(Some(true)).build(),
+ &CommentUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await?;
}
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)?;
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)?;
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)?;
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)?;
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)?;
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)?;
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)
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)?;
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?;
let post = Post::update(
&mut context.pool(),
post_id,
- &PostUpdateForm::builder().removed(Some(removed)).build(),
+ &PostUpdateForm {
+ removed: Some(removed),
+ ..Default::default()
+ },
)
.await?;
)
.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)
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)?;
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)?;
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)?;
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;
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?;
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
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
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) {
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?;
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?;
}
}
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?;
}
}
}
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(())
}
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(())
Community::update(
&mut context.pool(),
community.id,
- &CommunityUpdateForm::builder().removed(Some(true)).build(),
+ &CommunityUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await?;
}
Post::update(
&mut context.pool(),
post.id,
- &PostUpdateForm::builder().removed(Some(true)).build(),
+ &PostUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await?;
}
Comment::update(
&mut context.pool(),
comment.id,
- &CommentUpdateForm::builder().removed(Some(true)).build(),
+ &CommentUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await?;
}
Community::update(
&mut context.pool(),
community.id,
- &CommunityUpdateForm::builder()
- .deleted(Some(deleted))
- .build(),
+ &CommunityUpdateForm {
+ deleted: Some(deleted),
+ ..Default::default()
+ },
)
.await?;
}
Post::update(
&mut context.pool(),
post.id,
- &PostUpdateForm::builder().deleted(Some(deleted)).build(),
+ &PostUpdateForm {
+ deleted: Some(deleted),
+ ..Default::default()
+ },
)
.await?;
}
Comment::update(
&mut context.pool(),
comment.id,
- &CommentUpdateForm::builder().deleted(Some(deleted)).build(),
+ &CommentUpdateForm {
+ deleted: Some(deleted),
+ ..Default::default()
+ },
)
.await?;
}
PrivateMessage::update(
&mut context.pool(),
pm.id,
- &PrivateMessageUpdateForm::builder()
- .deleted(Some(deleted))
- .build(),
+ &PrivateMessageUpdateForm {
+ deleted: Some(deleted),
+ ..Default::default()
+ },
)
.await?;
}
Community::update(
&mut context.pool(),
community.id,
- &CommunityUpdateForm::builder().removed(Some(false)).build(),
+ &CommunityUpdateForm {
+ removed: Some(false),
+ ..Default::default()
+ },
)
.await?;
}
Post::update(
&mut context.pool(),
post.id,
- &PostUpdateForm::builder().removed(Some(false)).build(),
+ &PostUpdateForm {
+ removed: Some(false),
+ ..Default::default()
+ },
)
.await?;
}
Comment::update(
&mut context.pool(),
comment.id,
- &CommentUpdateForm::builder().removed(Some(false)).build(),
+ &CommentUpdateForm {
+ removed: Some(false),
+ ..Default::default()
+ },
)
.await?;
}
#[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(())
#[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(())
}
#[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(())
}
#[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(())
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();
Comment::update(
pool,
inserted_comment.id,
- &CommentUpdateForm::builder().removed(Some(true)).build(),
+ &CommentUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
Comment::update(
pool,
inserted_comment.id,
- &CommentUpdateForm::builder().removed(Some(false)).build(),
+ &CommentUpdateForm {
+ removed: Some(false),
+ ..Default::default()
+ },
)
.await
.unwrap();
Comment::update(
pool,
inserted_comment.id,
- &CommentUpdateForm::builder().deleted(Some(true)).build(),
+ &CommentUpdateForm {
+ deleted: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
Comment::update(
pool,
inserted_comment.id,
- &CommentUpdateForm::builder().removed(Some(true)).build(),
+ &CommentUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
Community::update(
pool,
inserted_community.id,
- &CommunityUpdateForm::builder().deleted(Some(true)).build(),
+ &CommunityUpdateForm {
+ deleted: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
Community::update(
pool,
inserted_community.id,
- &CommunityUpdateForm::builder().deleted(Some(false)).build(),
+ &CommunityUpdateForm {
+ deleted: Some(false),
+ ..Default::default()
+ },
)
.await
.unwrap();
Community::update(
pool,
inserted_community.id,
- &CommunityUpdateForm::builder().removed(Some(true)).build(),
+ &CommunityUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
Community::update(
pool,
inserted_community.id,
- &CommunityUpdateForm::builder().deleted(Some(true)).build(),
+ &CommunityUpdateForm {
+ deleted: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
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
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();
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();
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();
.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,
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();
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 {
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 {
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 {
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 {
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 {
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>>,
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 {
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 {
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 {
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
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
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
Post::update(
pool,
data.inserted_post.id,
- &PostUpdateForm::builder().removed(Some(true)).build(),
+ &PostUpdateForm {
+ removed: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
Post::update(
pool,
data.inserted_post.id,
- &PostUpdateForm::builder().deleted(Some(true)).build(),
+ &PostUpdateForm {
+ deleted: Some(true),
+ ..Default::default()
+ },
)
.await
.unwrap();
.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
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?;
}
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?;
}
Post::update(
pool,
cpost.id,
- &PostUpdateForm::builder().ap_id(Some(apub_id)).build(),
+ &PostUpdateForm {
+ ap_id: Some(apub_id),
+ ..Default::default()
+ },
)
.await?;
}
Comment::update(
pool,
ccomment.id,
- &CommentUpdateForm::builder().ap_id(Some(apub_id)).build(),
+ &CommentUpdateForm {
+ ap_id: Some(apub_id),
+ ..Default::default()
+ },
)
.await?;
}
PrivateMessage::update(
pool,
cpm.id,
- &PrivateMessageUpdateForm::builder()
- .ap_id(Some(apub_id))
- .build(),
+ &PrivateMessageUpdateForm {
+ ap_id: Some(apub_id),
+ ..Default::default()
+ },
)
.await?;
}
}
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(())
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?;
}
}
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?;
}
}