mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
* Remove TypedBuilder in favor of derive_new (fixes #4863) * fix * fix
This commit is contained in:
parent
5a722146b5
commit
ad75192bae
21
Cargo.lock
generated
21
Cargo.lock
generated
@ -2640,7 +2640,6 @@ dependencies = [
|
||||
"tokio-postgres-rustls",
|
||||
"tracing",
|
||||
"ts-rs",
|
||||
"typed-builder",
|
||||
"url",
|
||||
"uuid",
|
||||
]
|
||||
@ -5237,26 +5236,6 @@ dependencies = [
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typed-builder"
|
||||
version = "0.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a06fbd5b8de54c5f7c91f6fe4cebb949be2125d7758e630bb58b1d831dbce600"
|
||||
dependencies = [
|
||||
"typed-builder-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typed-builder-macro"
|
||||
version = "0.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9534daa9fd3ed0bd911d462a37f172228077e7abf18c18a5f67199d959205f8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
|
@ -131,7 +131,6 @@ anyhow = { version = "1.0.86", features = [
|
||||
"backtrace",
|
||||
] } # backtrace is on by default on nightly, but not stable rust
|
||||
diesel_ltree = "0.3.1"
|
||||
typed-builder = "0.19.1"
|
||||
serial_test = "3.1.1"
|
||||
tokio = { version = "1.39.2", features = ["full"] }
|
||||
regex = "1.10.5"
|
||||
|
@ -58,28 +58,21 @@ async fn create_test_site(context: &Data<LemmyContext>) -> LemmyResult<(Instance
|
||||
.await?
|
||||
.unwrap();
|
||||
|
||||
let site_form = SiteInsertForm::builder()
|
||||
.name("test site".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
let site_form = SiteInsertForm::new("test site".to_string(), inserted_instance.id);
|
||||
let site = Site::create(pool, &site_form).await.unwrap();
|
||||
|
||||
// Create a local site, since this is necessary for determining if email verification is
|
||||
// required
|
||||
let local_site_form = LocalSiteInsertForm::builder()
|
||||
.site_id(site.id)
|
||||
.require_email_verification(Some(true))
|
||||
.application_question(Some(".".to_string()))
|
||||
.registration_mode(Some(RegistrationMode::RequireApplication))
|
||||
.site_setup(Some(true))
|
||||
.build();
|
||||
let mut local_site_form = LocalSiteInsertForm::new(site.id);
|
||||
local_site_form.require_email_verification = Some(true);
|
||||
local_site_form.application_question = Some(".".to_string());
|
||||
local_site_form.registration_mode = Some(RegistrationMode::RequireApplication);
|
||||
local_site_form.site_setup = Some(true);
|
||||
let local_site = LocalSite::create(pool, &local_site_form).await.unwrap();
|
||||
|
||||
// Required to have a working local SiteView when updating the site to change email verification
|
||||
// requirement or registration mode
|
||||
let rate_limit_form = LocalSiteRateLimitInsertForm::builder()
|
||||
.local_site_id(local_site.id)
|
||||
.build();
|
||||
let rate_limit_form = LocalSiteRateLimitInsertForm::new(local_site.id);
|
||||
LocalSiteRateLimit::create(pool, &rate_limit_form)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -111,12 +111,9 @@ pub async fn create_comment(
|
||||
}
|
||||
};
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content(content.clone())
|
||||
.post_id(data.post_id)
|
||||
.creator_id(local_user_view.person.id)
|
||||
.language_id(language_id)
|
||||
.build();
|
||||
let mut comment_form =
|
||||
CommentInsertForm::new(local_user_view.person.id, data.post_id, content.clone());
|
||||
comment_form.language_id = language_id;
|
||||
|
||||
// Create the comment
|
||||
let parent_path = parent_opt.clone().map(|t| t.path);
|
||||
|
@ -88,23 +88,23 @@ pub async fn create_community(
|
||||
// When you create a community, make sure the user becomes a moderator and a follower
|
||||
let keypair = generate_actor_keypair()?;
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name(data.name.clone())
|
||||
.title(data.title.clone())
|
||||
.description(description)
|
||||
.icon(icon)
|
||||
.banner(banner)
|
||||
.nsfw(data.nsfw)
|
||||
.actor_id(Some(community_actor_id.clone()))
|
||||
.private_key(Some(keypair.private_key))
|
||||
.public_key(keypair.public_key)
|
||||
.followers_url(Some(generate_followers_url(&community_actor_id)?))
|
||||
.inbox_url(Some(generate_inbox_url(&community_actor_id)?))
|
||||
.shared_inbox_url(Some(generate_shared_inbox_url(context.settings())?))
|
||||
.posting_restricted_to_mods(data.posting_restricted_to_mods)
|
||||
.instance_id(site_view.site.instance_id)
|
||||
.visibility(data.visibility)
|
||||
.build();
|
||||
let mut community_form = CommunityInsertForm::new(
|
||||
site_view.site.instance_id,
|
||||
data.name.clone(),
|
||||
data.title.clone(),
|
||||
keypair.public_key,
|
||||
);
|
||||
community_form.description = description;
|
||||
community_form.icon = icon;
|
||||
community_form.banner = banner;
|
||||
community_form.nsfw = data.nsfw;
|
||||
community_form.actor_id = Some(community_actor_id.clone());
|
||||
community_form.private_key = Some(keypair.private_key);
|
||||
community_form.followers_url = Some(generate_followers_url(&community_actor_id)?);
|
||||
community_form.inbox_url = Some(generate_inbox_url(&community_actor_id)?);
|
||||
community_form.shared_inbox_url = Some(generate_shared_inbox_url(context.settings())?);
|
||||
community_form.posting_restricted_to_mods = data.posting_restricted_to_mods;
|
||||
community_form.visibility = data.visibility;
|
||||
|
||||
let inserted_community = Community::create(&mut context.pool(), &community_form)
|
||||
.await
|
||||
|
@ -24,19 +24,17 @@ pub async fn create_custom_emoji(
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
let emoji_form = CustomEmojiInsertForm::builder()
|
||||
.shortcode(data.shortcode.to_lowercase().trim().to_string())
|
||||
.alt_text(data.alt_text.to_string())
|
||||
.category(data.category.to_string())
|
||||
.image_url(data.clone().image_url.into())
|
||||
.build();
|
||||
let emoji_form = CustomEmojiInsertForm::new(
|
||||
data.shortcode.to_lowercase().trim().to_string(),
|
||||
data.clone().image_url.into(),
|
||||
data.alt_text.to_string(),
|
||||
data.category.to_string(),
|
||||
);
|
||||
let emoji = CustomEmoji::create(&mut context.pool(), &emoji_form).await?;
|
||||
let mut keywords = vec![];
|
||||
for keyword in &data.keywords {
|
||||
let keyword_form = CustomEmojiKeywordInsertForm::builder()
|
||||
.custom_emoji_id(emoji.id)
|
||||
.keyword(keyword.to_lowercase().trim().to_string())
|
||||
.build();
|
||||
let keyword_form =
|
||||
CustomEmojiKeywordInsertForm::new(emoji.id, keyword.to_lowercase().trim().to_string());
|
||||
keywords.push(keyword_form);
|
||||
}
|
||||
CustomEmojiKeyword::create(&mut context.pool(), keywords).await?;
|
||||
|
@ -24,19 +24,17 @@ pub async fn update_custom_emoji(
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
let emoji_form = CustomEmojiUpdateForm::builder()
|
||||
.alt_text(data.alt_text.to_string())
|
||||
.category(data.category.to_string())
|
||||
.image_url(data.clone().image_url.into())
|
||||
.build();
|
||||
let emoji_form = CustomEmojiUpdateForm::new(
|
||||
data.clone().image_url.into(),
|
||||
data.alt_text.to_string(),
|
||||
data.category.to_string(),
|
||||
);
|
||||
let emoji = CustomEmoji::update(&mut context.pool(), data.id, &emoji_form).await?;
|
||||
CustomEmojiKeyword::delete(&mut context.pool(), data.id).await?;
|
||||
let mut keywords = vec![];
|
||||
for keyword in &data.keywords {
|
||||
let keyword_form = CustomEmojiKeywordInsertForm::builder()
|
||||
.custom_emoji_id(emoji.id)
|
||||
.keyword(keyword.to_lowercase().trim().to_string())
|
||||
.build();
|
||||
let keyword_form =
|
||||
CustomEmojiKeywordInsertForm::new(emoji.id, keyword.to_lowercase().trim().to_string());
|
||||
keywords.push(keyword_form);
|
||||
}
|
||||
CustomEmojiKeyword::create(&mut context.pool(), keywords).await?;
|
||||
|
@ -130,16 +130,16 @@ pub async fn create_post(
|
||||
}
|
||||
};
|
||||
|
||||
let post_form = PostInsertForm::builder()
|
||||
.name(data.name.trim().to_string())
|
||||
.url(url.map(Into::into))
|
||||
.body(body)
|
||||
.alt_text(data.alt_text.clone())
|
||||
.community_id(data.community_id)
|
||||
.creator_id(local_user_view.person.id)
|
||||
.nsfw(data.nsfw)
|
||||
.language_id(language_id)
|
||||
.build();
|
||||
let mut post_form = PostInsertForm::new(
|
||||
data.name.trim().to_string(),
|
||||
local_user_view.person.id,
|
||||
data.community_id,
|
||||
);
|
||||
post_form.url = url.map(Into::into);
|
||||
post_form.body = body;
|
||||
post_form.alt_text = data.alt_text.clone();
|
||||
post_form.nsfw = data.nsfw;
|
||||
post_form.language_id = language_id;
|
||||
|
||||
let inserted_post = Post::create(&mut context.pool(), &post_form)
|
||||
.await
|
||||
|
@ -46,11 +46,11 @@ pub async fn create_private_message(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let private_message_form = PrivateMessageInsertForm::builder()
|
||||
.content(content.clone())
|
||||
.creator_id(local_user_view.person.id)
|
||||
.recipient_id(data.recipient_id)
|
||||
.build();
|
||||
let private_message_form = PrivateMessageInsertForm::new(
|
||||
local_user_view.person.id,
|
||||
data.recipient_id,
|
||||
content.clone(),
|
||||
);
|
||||
|
||||
let inserted_private_message = PrivateMessage::create(&mut context.pool(), &private_message_form)
|
||||
.await
|
||||
|
@ -363,11 +363,12 @@ mod tests {
|
||||
let export_user =
|
||||
create_user("hanna".to_string(), Some("my bio".to_string()), &context).await?;
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("testcom".to_string())
|
||||
.title("testcom".to_string())
|
||||
.instance_id(export_user.person.instance_id)
|
||||
.build();
|
||||
let community_form = CommunityInsertForm::new(
|
||||
export_user.person.instance_id,
|
||||
"testcom".to_string(),
|
||||
"testcom".to_string(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let community = Community::create(&mut context.pool(), &community_form).await?;
|
||||
let follower_form = CommunityFollowerForm {
|
||||
community_id: community.id,
|
||||
@ -413,11 +414,12 @@ mod tests {
|
||||
let export_user =
|
||||
create_user("hanna".to_string(), Some("my bio".to_string()), &context).await?;
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("testcom".to_string())
|
||||
.title("testcom".to_string())
|
||||
.instance_id(export_user.person.instance_id)
|
||||
.build();
|
||||
let community_form = CommunityInsertForm::new(
|
||||
export_user.person.instance_id,
|
||||
"testcom".to_string(),
|
||||
"testcom".to_string(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let community = Community::create(&mut context.pool(), &community_form).await?;
|
||||
let follower_form = CommunityFollowerForm {
|
||||
community_id: community.id,
|
||||
|
@ -151,14 +151,14 @@ pub(crate) mod tests {
|
||||
Instance::read_or_create(&mut context.pool(), "my_domain.tld".to_string()).await?;
|
||||
create_local_site(context, instance.id).await?;
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("testcom6".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(instance.id)
|
||||
.deleted(Some(deleted))
|
||||
.visibility(Some(visibility))
|
||||
.build();
|
||||
let mut community_form = CommunityInsertForm::new(
|
||||
instance.id,
|
||||
"testcom6".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
community_form.deleted = Some(deleted);
|
||||
community_form.visibility = Some(visibility);
|
||||
let community = Community::create(&mut context.pool(), &community_form).await?;
|
||||
Ok((instance, community))
|
||||
}
|
||||
@ -169,18 +169,13 @@ pub(crate) mod tests {
|
||||
instance_id: InstanceId,
|
||||
) -> LemmyResult<()> {
|
||||
// Create a local site, since this is necessary for community fetching.
|
||||
let site_form = SiteInsertForm::builder()
|
||||
.name("test site".to_string())
|
||||
.instance_id(instance_id)
|
||||
.build();
|
||||
let site_form = SiteInsertForm::new("test site".to_string(), instance_id);
|
||||
let site = Site::create(&mut context.pool(), &site_form).await?;
|
||||
|
||||
let local_site_form = LocalSiteInsertForm::builder().site_id(site.id).build();
|
||||
let local_site_form = LocalSiteInsertForm::new(site.id);
|
||||
let local_site = LocalSite::create(&mut context.pool(), &local_site_form).await?;
|
||||
let local_site_rate_limit_form = LocalSiteRateLimitInsertForm::builder()
|
||||
.local_site_id(local_site.id)
|
||||
.build();
|
||||
|
||||
let local_site_rate_limit_form = LocalSiteRateLimitInsertForm::new(local_site.id);
|
||||
LocalSiteRateLimit::create(&mut context.pool(), &local_site_rate_limit_form).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -151,29 +151,28 @@ impl Object for ApubCommunity {
|
||||
let icon = proxy_image_link_opt_apub(group.icon.map(|i| i.url), context).await?;
|
||||
let banner = proxy_image_link_opt_apub(group.image.map(|i| i.url), context).await?;
|
||||
|
||||
let form = CommunityInsertForm {
|
||||
name: group.preferred_username.clone(),
|
||||
title: group.name.unwrap_or(group.preferred_username.clone()),
|
||||
description,
|
||||
published: group.published,
|
||||
updated: group.updated,
|
||||
deleted: Some(false),
|
||||
nsfw: Some(group.sensitive.unwrap_or(false)),
|
||||
actor_id: Some(group.id.into()),
|
||||
local: Some(false),
|
||||
public_key: group.public_key.public_key_pem,
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
icon,
|
||||
banner,
|
||||
followers_url: group.followers.clone().map(Into::into),
|
||||
inbox_url: Some(group.inbox.into()),
|
||||
shared_inbox_url: group.endpoints.map(|e| e.shared_inbox.into()),
|
||||
moderators_url: group.attributed_to.clone().map(Into::into),
|
||||
posting_restricted_to_mods: group.posting_restricted_to_mods,
|
||||
let mut form = CommunityInsertForm::new(
|
||||
instance_id,
|
||||
featured_url: group.featured.clone().map(Into::into),
|
||||
..Default::default()
|
||||
};
|
||||
group.preferred_username.clone(),
|
||||
group.name.unwrap_or(group.preferred_username.clone()),
|
||||
group.public_key.public_key_pem,
|
||||
);
|
||||
form.published = group.published;
|
||||
form.updated = group.updated;
|
||||
form.deleted = Some(false);
|
||||
form.nsfw = Some(group.sensitive.unwrap_or(false));
|
||||
form.actor_id = Some(group.id.into());
|
||||
form.local = Some(false);
|
||||
form.last_refreshed_at = Some(naive_now());
|
||||
form.icon = icon;
|
||||
form.banner = banner;
|
||||
form.description = description;
|
||||
form.followers_url = group.followers.clone().map(Into::into);
|
||||
form.inbox_url = Some(group.inbox.into());
|
||||
form.shared_inbox_url = group.endpoints.map(|e| e.shared_inbox.into());
|
||||
form.moderators_url = group.attributed_to.clone().map(Into::into);
|
||||
form.posting_restricted_to_mods = group.posting_restricted_to_mods;
|
||||
form.featured_url = group.featured.clone().map(Into::into);
|
||||
let languages =
|
||||
LanguageTag::to_language_id_multiple(group.language, &mut context.pool()).await?;
|
||||
|
||||
|
@ -247,21 +247,17 @@ impl Object for ApubPost {
|
||||
let language_id =
|
||||
LanguageTag::to_language_id_single(page.language, &mut context.pool()).await?;
|
||||
|
||||
let form = PostInsertForm::builder()
|
||||
.name(name)
|
||||
.url(url.map(Into::into))
|
||||
.body(body)
|
||||
.alt_text(alt_text)
|
||||
.creator_id(creator.id)
|
||||
.community_id(community.id)
|
||||
.published(page.published.map(Into::into))
|
||||
.updated(page.updated.map(Into::into))
|
||||
.deleted(Some(false))
|
||||
.nsfw(page.sensitive)
|
||||
.ap_id(Some(page.id.clone().into()))
|
||||
.local(Some(false))
|
||||
.language_id(language_id)
|
||||
.build();
|
||||
let mut form = PostInsertForm::new(name, creator.id, community.id);
|
||||
form.url = url.map(Into::into);
|
||||
form.body = body;
|
||||
form.alt_text = alt_text;
|
||||
form.published = page.published.map(Into::into);
|
||||
form.updated = page.updated.map(Into::into);
|
||||
form.deleted = Some(false);
|
||||
form.nsfw = page.sensitive;
|
||||
form.ap_id = Some(page.id.clone().into());
|
||||
form.local = Some(false);
|
||||
form.language_id = language_id;
|
||||
|
||||
let timestamp = page.updated.or(page.published).unwrap_or_else(naive_now);
|
||||
let post = Post::insert_apub(&mut context.pool(), timestamp, &form).await?;
|
||||
|
@ -79,11 +79,12 @@ async fn try_main() -> LemmyResult<()> {
|
||||
println!("🌍 creating {} communities", args.communities);
|
||||
let mut community_ids = vec![];
|
||||
for i in 0..args.communities.get() {
|
||||
let form = CommunityInsertForm::builder()
|
||||
.name(format!("c{i}"))
|
||||
.title(i.to_string())
|
||||
.instance_id(instance.id)
|
||||
.build();
|
||||
let form = CommunityInsertForm::new(
|
||||
instance.id,
|
||||
format!("c{i}"),
|
||||
i.to_string(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
community_ids.push(Community::create(&mut conn.into(), &form).await?.id);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,6 @@ diesel-async = { workspace = true, features = [
|
||||
], optional = true }
|
||||
regex = { workspace = true, optional = true }
|
||||
diesel_ltree = { workspace = true, optional = true }
|
||||
typed-builder = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
deadpool = { version = "0.12.1", features = ["rt_tokio_1"], optional = true }
|
||||
|
@ -72,37 +72,33 @@ mod tests {
|
||||
|
||||
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("TIL_comment_agg".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL_comment_agg".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
let child_comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let child_comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let _inserted_child_comment =
|
||||
Comment::create(pool, &child_comment_form, Some(&inserted_comment.path))
|
||||
.await
|
||||
|
@ -73,22 +73,20 @@ mod tests {
|
||||
|
||||
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("TIL_community_agg".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL_community_agg".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let another_community = CommunityInsertForm::builder()
|
||||
.name("TIL_community_agg_2".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let another_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL_community_agg_2".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let another_inserted_community = Community::create(pool, &another_community).await.unwrap();
|
||||
|
||||
let first_person_follow = CommunityFollowerForm {
|
||||
@ -121,28 +119,25 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
let child_comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let child_comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let _inserted_child_comment =
|
||||
Comment::create(pool, &child_comment_form, Some(&inserted_comment.path))
|
||||
.await
|
||||
|
@ -57,21 +57,20 @@ mod tests {
|
||||
|
||||
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("TIL_site_agg".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL_site_agg".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let post_like = PostLikeForm {
|
||||
@ -79,15 +78,13 @@ mod tests {
|
||||
person_id: inserted_person.id,
|
||||
score: 1,
|
||||
};
|
||||
|
||||
let _inserted_post_like = PostLike::like(pool, &post_like).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
let mut comment_like = CommentLikeForm {
|
||||
@ -99,12 +96,11 @@ mod tests {
|
||||
|
||||
let _inserted_comment_like = CommentLike::like(pool, &comment_like).await.unwrap();
|
||||
|
||||
let child_comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let child_comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_child_comment =
|
||||
Comment::create(pool, &child_comment_form, Some(&inserted_comment.path))
|
||||
.await
|
||||
|
@ -91,37 +91,33 @@ mod tests {
|
||||
|
||||
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("TIL_community_agg".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL_community_agg".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
let child_comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let child_comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_child_comment =
|
||||
Comment::create(pool, &child_comment_form, Some(&inserted_comment.path))
|
||||
.await
|
||||
@ -225,28 +221,26 @@ mod tests {
|
||||
|
||||
let inserted_person = Person::create(pool, &new_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("TIL_community_agg".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL_community_agg".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
|
@ -46,19 +46,15 @@ mod tests {
|
||||
|
||||
let inserted_person = Person::create(pool, &new_person).await.unwrap();
|
||||
|
||||
let site_form = SiteInsertForm::builder()
|
||||
.name("test_site".into())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let site_form = SiteInsertForm::new("test_site".into(), inserted_instance.id);
|
||||
let inserted_site = Site::create(pool, &site_form).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("TIL_site_agg".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL_site_agg".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
(
|
||||
@ -78,31 +74,30 @@ mod tests {
|
||||
let (inserted_instance, inserted_person, inserted_site, inserted_community) =
|
||||
prepare_site_with_community(pool).await;
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
|
||||
// Insert two of those posts
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
let _inserted_post_again = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
|
||||
// Insert two of those comments
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
let child_comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let child_comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let _inserted_child_comment =
|
||||
Comment::create(pool, &child_comment_form, Some(&inserted_comment.path))
|
||||
.await
|
||||
|
@ -446,14 +446,11 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let site_form = SiteInsertForm::builder()
|
||||
.name("test site".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
let site_form = SiteInsertForm::new("test site".to_string(), inserted_instance.id);
|
||||
let site = Site::create(pool, &site_form).await.unwrap();
|
||||
|
||||
// Create a local site, since this is necessary for local languages
|
||||
let local_site_form = LocalSiteInsertForm::builder().site_id(site.id).build();
|
||||
let local_site_form = LocalSiteInsertForm::new(site.id);
|
||||
LocalSite::create(pool, &local_site_form).await.unwrap();
|
||||
|
||||
(site, inserted_instance)
|
||||
@ -576,12 +573,12 @@ mod tests {
|
||||
let read_local_site_langs = SiteLanguage::read_local_raw(pool).await.unwrap();
|
||||
assert_eq!(test_langs, read_local_site_langs);
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("test community".to_string())
|
||||
.title("test community".to_string())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(instance.id)
|
||||
.build();
|
||||
let community_form = CommunityInsertForm::new(
|
||||
instance.id,
|
||||
"test community".to_string(),
|
||||
"test community".to_string(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let community = Community::create(pool, &community_form).await.unwrap();
|
||||
let community_langs1 = CommunityLanguage::read(pool, community.id).await.unwrap();
|
||||
|
||||
@ -629,12 +626,12 @@ mod tests {
|
||||
let test_langs = test_langs1(pool).await;
|
||||
let test_langs2 = test_langs2(pool).await;
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("test community".to_string())
|
||||
.title("test community".to_string())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(instance.id)
|
||||
.build();
|
||||
let community_form = CommunityInsertForm::new(
|
||||
instance.id,
|
||||
"test community".to_string(),
|
||||
"test community".to_string(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let community = Community::create(pool, &community_form).await.unwrap();
|
||||
CommunityLanguage::update(pool, test_langs, community.id)
|
||||
.await
|
||||
|
@ -239,29 +239,26 @@ mod tests {
|
||||
|
||||
let inserted_person = Person::create(pool, &new_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
let expected_comment = Comment {
|
||||
@ -285,12 +282,11 @@ mod tests {
|
||||
language_id: LanguageId::default(),
|
||||
};
|
||||
|
||||
let child_comment_form = CommentInsertForm::builder()
|
||||
.content("A child comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let child_comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A child comment".into(),
|
||||
);
|
||||
let inserted_child_comment =
|
||||
Comment::create(pool, &child_comment_form, Some(&inserted_comment.path))
|
||||
.await
|
||||
|
@ -473,13 +473,12 @@ mod tests {
|
||||
let artemis_person = PersonInsertForm::test_form(inserted_instance.id, "artemis");
|
||||
let inserted_artemis = Person::create(pool, &artemis_person).await?;
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("TIL".into())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"TIL".into(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await?;
|
||||
|
||||
let expected_community = Community {
|
||||
|
@ -51,10 +51,8 @@ impl Instance {
|
||||
Some(i) => Ok(i),
|
||||
None => {
|
||||
// Instance not in database yet, insert it
|
||||
let form = InstanceForm::builder()
|
||||
.domain(domain_)
|
||||
.updated(Some(naive_now()))
|
||||
.build();
|
||||
let mut form = InstanceForm::new(domain_);
|
||||
form.updated = Some(naive_now());
|
||||
insert_into(instance::table)
|
||||
.values(&form)
|
||||
// Necessary because this method may be called concurrently for the same domain. This
|
||||
|
@ -49,9 +49,7 @@ impl LocalUser {
|
||||
LocalUserLanguage::update(pool, languages, local_user_.id).await?;
|
||||
|
||||
// Create their vote_display_modes
|
||||
let vote_display_mode_form = LocalUserVoteDisplayModeInsertForm::builder()
|
||||
.local_user_id(local_user_.id)
|
||||
.build();
|
||||
let vote_display_mode_form = LocalUserVoteDisplayModeInsertForm::new(local_user_.id);
|
||||
LocalUserVoteDisplayMode::create(pool, &vote_display_mode_form).await?;
|
||||
|
||||
Ok(local_user_)
|
||||
|
@ -521,29 +521,27 @@ mod tests {
|
||||
|
||||
let inserted_person = Person::create(pool, &new_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("mod_community".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"mod_community".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post thweep".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post thweep".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
// Now the actual tests
|
||||
|
@ -406,28 +406,27 @@ mod tests {
|
||||
|
||||
let inserted_person = Person::create(pool, &new_person).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community_3".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community_3".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let new_post2 = PostInsertForm::builder()
|
||||
.name("A test post 2".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
let new_post2 = PostInsertForm::new(
|
||||
"A test post 2".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post2 = Post::create(pool, &new_post2).await.unwrap();
|
||||
|
||||
let expected_post = Post {
|
||||
|
@ -104,19 +104,15 @@ mod tests {
|
||||
let person_form = PersonInsertForm::test_form(inserted_instance.id, "jim");
|
||||
let person = Person::create(pool, &person_form).await.unwrap();
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("test community_4".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
let community_form = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community_4".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let community = Community::create(pool, &community_form).await.unwrap();
|
||||
|
||||
let form = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(person.id)
|
||||
.community_id(community.id)
|
||||
.build();
|
||||
let form = PostInsertForm::new("A test post".into(), person.id, community.id);
|
||||
let post = Post::create(pool, &form).await.unwrap();
|
||||
|
||||
let report_form = PostReportForm {
|
||||
|
@ -120,11 +120,11 @@ mod tests {
|
||||
|
||||
let inserted_recipient = Person::create(pool, &recipient_form).await.unwrap();
|
||||
|
||||
let private_message_form = PrivateMessageInsertForm::builder()
|
||||
.content("A test private message".into())
|
||||
.creator_id(inserted_creator.id)
|
||||
.recipient_id(inserted_recipient.id)
|
||||
.build();
|
||||
let private_message_form = PrivateMessageInsertForm::new(
|
||||
inserted_creator.id,
|
||||
inserted_recipient.id,
|
||||
"A test private message".into(),
|
||||
);
|
||||
|
||||
let inserted_private_message = PrivateMessage::create(pool, &private_message_form)
|
||||
.await
|
||||
|
@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
@ -51,24 +50,28 @@ pub struct Comment {
|
||||
pub language_id: LanguageId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Debug, Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = comment))]
|
||||
pub struct CommentInsertForm {
|
||||
#[builder(!default)]
|
||||
pub creator_id: PersonId,
|
||||
#[builder(!default)]
|
||||
pub post_id: PostId,
|
||||
#[builder(!default)]
|
||||
pub content: String,
|
||||
#[new(default)]
|
||||
pub removed: Option<bool>,
|
||||
#[new(default)]
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub deleted: Option<bool>,
|
||||
#[new(default)]
|
||||
pub ap_id: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub local: Option<bool>,
|
||||
#[new(default)]
|
||||
pub distinguished: Option<bool>,
|
||||
#[new(default)]
|
||||
pub language_id: Option<LanguageId>,
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
@ -71,37 +70,53 @@ pub struct Community {
|
||||
pub visibility: CommunityVisibility,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder, Default)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Debug, Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = community))]
|
||||
pub struct CommunityInsertForm {
|
||||
#[builder(!default)]
|
||||
pub name: String,
|
||||
#[builder(!default)]
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub removed: Option<bool>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub nsfw: Option<bool>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub local: Option<bool>,
|
||||
pub private_key: Option<String>,
|
||||
pub public_key: String,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub icon: Option<DbUrl>,
|
||||
pub banner: Option<DbUrl>,
|
||||
pub followers_url: Option<DbUrl>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub moderators_url: Option<DbUrl>,
|
||||
pub featured_url: Option<DbUrl>,
|
||||
pub hidden: Option<bool>,
|
||||
pub posting_restricted_to_mods: Option<bool>,
|
||||
#[builder(!default)]
|
||||
pub instance_id: InstanceId,
|
||||
pub name: String,
|
||||
pub title: String,
|
||||
pub public_key: String,
|
||||
#[new(default)]
|
||||
pub description: Option<String>,
|
||||
#[new(default)]
|
||||
pub removed: Option<bool>,
|
||||
#[new(default)]
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub deleted: Option<bool>,
|
||||
#[new(default)]
|
||||
pub nsfw: Option<bool>,
|
||||
#[new(default)]
|
||||
pub actor_id: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub local: Option<bool>,
|
||||
#[new(default)]
|
||||
pub private_key: Option<String>,
|
||||
#[new(default)]
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub icon: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub banner: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub followers_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub moderators_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub featured_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub hidden: Option<bool>,
|
||||
#[new(default)]
|
||||
pub posting_restricted_to_mods: Option<bool>,
|
||||
#[new(default)]
|
||||
pub visibility: Option<CommunityVisibility>,
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
||||
@ -25,7 +24,7 @@ pub struct CustomEmoji {
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder)]
|
||||
#[derive(Debug, Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
||||
pub struct CustomEmojiInsertForm {
|
||||
@ -35,7 +34,7 @@ pub struct CustomEmojiInsertForm {
|
||||
pub category: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder)]
|
||||
#[derive(Debug, Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
||||
pub struct CustomEmojiUpdateForm {
|
||||
|
@ -4,7 +4,6 @@ use crate::schema::custom_emoji_keyword;
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(
|
||||
@ -25,7 +24,7 @@ pub struct CustomEmojiKeyword {
|
||||
pub keyword: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder)]
|
||||
#[derive(Debug, Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji_keyword))]
|
||||
pub struct CustomEmojiKeywordInsertForm {
|
||||
|
@ -7,7 +7,6 @@ use serde_with::skip_serializing_none;
|
||||
use std::fmt::Debug;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
||||
@ -30,7 +29,7 @@ pub struct ImageUpload {
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = image_upload))]
|
||||
pub struct ImageUploadForm {
|
||||
|
@ -7,7 +7,6 @@ use serde_with::skip_serializing_none;
|
||||
use std::fmt::Debug;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
@ -25,14 +24,15 @@ pub struct Instance {
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = instance))]
|
||||
pub struct InstanceForm {
|
||||
#[builder(!default)]
|
||||
pub domain: String,
|
||||
#[new(default)]
|
||||
pub software: Option<String>,
|
||||
#[new(default)]
|
||||
pub version: Option<String>,
|
||||
#[new(default)]
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize, Default)]
|
||||
@ -75,35 +74,56 @@ pub struct LocalSite {
|
||||
pub oauth_registration: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = local_site))]
|
||||
pub struct LocalSiteInsertForm {
|
||||
#[builder(!default)]
|
||||
pub site_id: SiteId,
|
||||
#[new(default)]
|
||||
pub site_setup: Option<bool>,
|
||||
#[new(default)]
|
||||
pub enable_downvotes: Option<bool>,
|
||||
#[new(default)]
|
||||
pub community_creation_admin_only: Option<bool>,
|
||||
#[new(default)]
|
||||
pub require_email_verification: Option<bool>,
|
||||
#[new(default)]
|
||||
pub application_question: Option<String>,
|
||||
#[new(default)]
|
||||
pub private_instance: Option<bool>,
|
||||
#[new(default)]
|
||||
pub default_theme: Option<String>,
|
||||
#[new(default)]
|
||||
pub default_post_listing_type: Option<ListingType>,
|
||||
#[new(default)]
|
||||
pub legal_information: Option<String>,
|
||||
#[new(default)]
|
||||
pub hide_modlog_mod_names: Option<bool>,
|
||||
#[new(default)]
|
||||
pub application_email_admins: Option<bool>,
|
||||
#[new(default)]
|
||||
pub slur_filter_regex: Option<String>,
|
||||
#[new(default)]
|
||||
pub actor_name_max_length: Option<i32>,
|
||||
#[new(default)]
|
||||
pub federation_enabled: Option<bool>,
|
||||
#[new(default)]
|
||||
pub captcha_enabled: Option<bool>,
|
||||
#[new(default)]
|
||||
pub captcha_difficulty: Option<String>,
|
||||
#[new(default)]
|
||||
pub registration_mode: Option<RegistrationMode>,
|
||||
#[new(default)]
|
||||
pub oauth_registration: Option<bool>,
|
||||
#[new(default)]
|
||||
pub reports_email_admins: Option<bool>,
|
||||
#[new(default)]
|
||||
pub federation_signed_fetch: Option<bool>,
|
||||
#[new(default)]
|
||||
pub default_post_listing_mode: Option<PostListingMode>,
|
||||
#[new(default)]
|
||||
pub default_post_sort_type: Option<PostSortType>,
|
||||
#[new(default)]
|
||||
pub default_comment_sort_type: Option<CommentSortType>,
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
||||
@ -40,26 +39,38 @@ pub struct LocalSiteRateLimit {
|
||||
pub import_user_settings_per_second: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
|
||||
pub struct LocalSiteRateLimitInsertForm {
|
||||
#[builder(!default)]
|
||||
pub local_site_id: LocalSiteId,
|
||||
#[new(default)]
|
||||
pub message: Option<i32>,
|
||||
#[new(default)]
|
||||
pub message_per_second: Option<i32>,
|
||||
#[new(default)]
|
||||
pub post: Option<i32>,
|
||||
#[new(default)]
|
||||
pub post_per_second: Option<i32>,
|
||||
#[new(default)]
|
||||
pub register: Option<i32>,
|
||||
#[new(default)]
|
||||
pub register_per_second: Option<i32>,
|
||||
#[new(default)]
|
||||
pub image: Option<i32>,
|
||||
#[new(default)]
|
||||
pub image_per_second: Option<i32>,
|
||||
#[new(default)]
|
||||
pub comment: Option<i32>,
|
||||
#[new(default)]
|
||||
pub comment_per_second: Option<i32>,
|
||||
#[new(default)]
|
||||
pub search: Option<i32>,
|
||||
#[new(default)]
|
||||
pub search_per_second: Option<i32>,
|
||||
#[new(default)]
|
||||
pub import_user_settings: Option<i32>,
|
||||
#[new(default)]
|
||||
pub import_user_settings_per_second: Option<i32>,
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Default, Serialize, Deserialize)]
|
||||
@ -28,16 +27,18 @@ pub struct LocalUserVoteDisplayMode {
|
||||
pub upvote_percentage: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = local_user_vote_display_mode))]
|
||||
pub struct LocalUserVoteDisplayModeInsertForm {
|
||||
#[builder(!default)]
|
||||
pub local_user_id: LocalUserId,
|
||||
#[new(default)]
|
||||
pub score: Option<bool>,
|
||||
#[new(default)]
|
||||
pub upvotes: Option<bool>,
|
||||
#[new(default)]
|
||||
pub downvotes: Option<bool>,
|
||||
#[new(default)]
|
||||
pub upvote_percentage: Option<bool>,
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
@ -60,35 +59,50 @@ pub struct Post {
|
||||
pub alt_text: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Debug, Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = post))]
|
||||
pub struct PostInsertForm {
|
||||
#[builder(!default)]
|
||||
pub name: String,
|
||||
#[builder(!default)]
|
||||
pub creator_id: PersonId,
|
||||
#[builder(!default)]
|
||||
pub community_id: CommunityId,
|
||||
#[new(default)]
|
||||
pub nsfw: Option<bool>,
|
||||
#[new(default)]
|
||||
pub url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub body: Option<String>,
|
||||
#[new(default)]
|
||||
pub removed: Option<bool>,
|
||||
#[new(default)]
|
||||
pub locked: Option<bool>,
|
||||
#[new(default)]
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub deleted: Option<bool>,
|
||||
#[new(default)]
|
||||
pub embed_title: Option<String>,
|
||||
#[new(default)]
|
||||
pub embed_description: Option<String>,
|
||||
#[new(default)]
|
||||
pub embed_video_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub thumbnail_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub ap_id: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub local: Option<bool>,
|
||||
#[new(default)]
|
||||
pub language_id: Option<LanguageId>,
|
||||
#[new(default)]
|
||||
pub featured_community: Option<bool>,
|
||||
#[new(default)]
|
||||
pub featured_local: Option<bool>,
|
||||
#[new(default)]
|
||||
pub url_content_type: Option<String>,
|
||||
#[new(default)]
|
||||
pub alt_text: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
@ -35,22 +34,24 @@ pub struct PrivateMessage {
|
||||
pub local: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = private_message))]
|
||||
pub struct PrivateMessageInsertForm {
|
||||
#[builder(!default)]
|
||||
pub creator_id: PersonId,
|
||||
#[builder(!default)]
|
||||
pub recipient_id: PersonId,
|
||||
#[builder(!default)]
|
||||
pub content: String,
|
||||
#[new(default)]
|
||||
pub deleted: Option<bool>,
|
||||
#[new(default)]
|
||||
pub read: Option<bool>,
|
||||
#[new(default)]
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub ap_id: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub local: Option<bool>,
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
||||
@ -47,25 +46,33 @@ pub struct Site {
|
||||
pub content_warning: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
#[builder(field_defaults(default))]
|
||||
#[derive(Clone, derive_new::new)]
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = site))]
|
||||
pub struct SiteInsertForm {
|
||||
#[builder(!default)]
|
||||
pub name: String,
|
||||
pub sidebar: Option<String>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub icon: Option<DbUrl>,
|
||||
pub banner: Option<DbUrl>,
|
||||
pub description: Option<String>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub private_key: Option<String>,
|
||||
pub public_key: Option<String>,
|
||||
#[builder(!default)]
|
||||
pub instance_id: InstanceId,
|
||||
#[new(default)]
|
||||
pub sidebar: Option<String>,
|
||||
#[new(default)]
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub icon: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub banner: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub description: Option<String>,
|
||||
#[new(default)]
|
||||
pub actor_id: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
#[new(default)]
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub private_key: Option<String>,
|
||||
#[new(default)]
|
||||
pub public_key: Option<String>,
|
||||
#[new(default)]
|
||||
pub content_warning: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -321,13 +321,12 @@ mod tests {
|
||||
|
||||
let inserted_jessica = Person::create(pool, &new_person_3).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community crv".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community crv".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
// Make timmy a mod
|
||||
@ -340,20 +339,19 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post crv".into())
|
||||
.creator_id(inserted_timmy.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post crv".into(),
|
||||
inserted_timmy.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment 32".into())
|
||||
.creator_id(inserted_timmy.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_timmy.id,
|
||||
inserted_post.id,
|
||||
"A test comment 32".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
// sara reports
|
||||
|
@ -491,21 +491,19 @@ mod tests {
|
||||
let sara_person_form = PersonInsertForm::test_form(inserted_instance.id, "sara");
|
||||
let inserted_sara_person = Person::create(pool, &sara_person_form).await?;
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community 5".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community 5".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await?;
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post 2".into())
|
||||
.creator_id(inserted_timmy_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post 2".into(),
|
||||
inserted_timmy_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await?;
|
||||
let english_id = Language::read_id_from_code(pool, Some("en")).await?;
|
||||
|
||||
@ -517,65 +515,62 @@ mod tests {
|
||||
// 3 4
|
||||
// \
|
||||
// 5
|
||||
let comment_form_0 = CommentInsertForm::builder()
|
||||
.content("Comment 0".into())
|
||||
.creator_id(inserted_timmy_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.language_id(english_id)
|
||||
.build();
|
||||
let mut comment_form_0 = CommentInsertForm::new(
|
||||
inserted_timmy_person.id,
|
||||
inserted_post.id,
|
||||
"Comment 0".into(),
|
||||
);
|
||||
comment_form_0.language_id = english_id;
|
||||
|
||||
let inserted_comment_0 = Comment::create(pool, &comment_form_0, None).await?;
|
||||
|
||||
let comment_form_1 = CommentInsertForm::builder()
|
||||
.content("Comment 1, A test blocked comment".into())
|
||||
.creator_id(inserted_sara_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.language_id(english_id)
|
||||
.build();
|
||||
|
||||
let mut comment_form_1 = CommentInsertForm::new(
|
||||
inserted_sara_person.id,
|
||||
inserted_post.id,
|
||||
"Comment 1, A test blocked comment".into(),
|
||||
);
|
||||
comment_form_1.language_id = english_id;
|
||||
let inserted_comment_1 =
|
||||
Comment::create(pool, &comment_form_1, Some(&inserted_comment_0.path)).await?;
|
||||
|
||||
let finnish_id = Language::read_id_from_code(pool, Some("fi")).await?;
|
||||
let comment_form_2 = CommentInsertForm::builder()
|
||||
.content("Comment 2".into())
|
||||
.creator_id(inserted_timmy_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.language_id(finnish_id)
|
||||
.build();
|
||||
let mut comment_form_2 = CommentInsertForm::new(
|
||||
inserted_timmy_person.id,
|
||||
inserted_post.id,
|
||||
"Comment 2".into(),
|
||||
);
|
||||
comment_form_2.language_id = finnish_id;
|
||||
|
||||
let inserted_comment_2 =
|
||||
Comment::create(pool, &comment_form_2, Some(&inserted_comment_0.path)).await?;
|
||||
|
||||
let comment_form_3 = CommentInsertForm::builder()
|
||||
.content("Comment 3".into())
|
||||
.creator_id(inserted_timmy_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.language_id(english_id)
|
||||
.build();
|
||||
|
||||
let mut comment_form_3 = CommentInsertForm::new(
|
||||
inserted_timmy_person.id,
|
||||
inserted_post.id,
|
||||
"Comment 3".into(),
|
||||
);
|
||||
comment_form_3.language_id = english_id;
|
||||
let _inserted_comment_3 =
|
||||
Comment::create(pool, &comment_form_3, Some(&inserted_comment_1.path)).await?;
|
||||
|
||||
let polish_id = Language::read_id_from_code(pool, Some("pl"))
|
||||
.await?
|
||||
.ok_or(LemmyErrorType::LanguageNotAllowed)?;
|
||||
let comment_form_4 = CommentInsertForm::builder()
|
||||
.content("Comment 4".into())
|
||||
.creator_id(inserted_timmy_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.language_id(Some(polish_id))
|
||||
.build();
|
||||
let mut comment_form_4 = CommentInsertForm::new(
|
||||
inserted_timmy_person.id,
|
||||
inserted_post.id,
|
||||
"Comment 4".into(),
|
||||
);
|
||||
comment_form_4.language_id = Some(polish_id);
|
||||
|
||||
let inserted_comment_4 =
|
||||
Comment::create(pool, &comment_form_4, Some(&inserted_comment_1.path)).await?;
|
||||
|
||||
let comment_form_5 = CommentInsertForm::builder()
|
||||
.content("Comment 5".into())
|
||||
.creator_id(inserted_timmy_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form_5 = CommentInsertForm::new(
|
||||
inserted_timmy_person.id,
|
||||
inserted_post.id,
|
||||
"Comment 5".into(),
|
||||
);
|
||||
let _inserted_comment_5 =
|
||||
Comment::create(pool, &comment_form_5, Some(&inserted_comment_4.path)).await?;
|
||||
|
||||
|
@ -343,13 +343,12 @@ mod tests {
|
||||
|
||||
let inserted_jessica = Person::create(pool, &new_person_3).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community prv".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community prv".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
// Make timmy a mod
|
||||
@ -362,12 +361,11 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post crv".into())
|
||||
.creator_id(inserted_timmy.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post crv".into(),
|
||||
inserted_timmy.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
// sara reports
|
||||
@ -382,12 +380,11 @@ mod tests {
|
||||
|
||||
PostReport::report(pool, &sara_report_form).await.unwrap();
|
||||
|
||||
let new_post_2 = PostInsertForm::builder()
|
||||
.name("A test post crv 2".into())
|
||||
.creator_id(inserted_timmy.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post_2 = PostInsertForm::new(
|
||||
"A test post crv 2".into(),
|
||||
inserted_timmy.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post_2 = Post::create(pool, &new_post_2).await.unwrap();
|
||||
|
||||
// jessica reports
|
||||
|
@ -830,13 +830,12 @@ mod tests {
|
||||
|
||||
let inserted_bot = Person::create(pool, &new_bot).await?;
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test_community_3".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test_community_3".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await?;
|
||||
|
||||
// Test a person block, make sure the post query doesn't include their post
|
||||
@ -851,13 +850,12 @@ mod tests {
|
||||
)
|
||||
.await?;
|
||||
|
||||
let post_from_blocked_person = PostInsertForm::builder()
|
||||
.name(POST_BY_BLOCKED_PERSON.to_string())
|
||||
.creator_id(inserted_blocked_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.language_id(Some(LanguageId(1)))
|
||||
.build();
|
||||
|
||||
let mut post_from_blocked_person = PostInsertForm::new(
|
||||
POST_BY_BLOCKED_PERSON.to_string(),
|
||||
inserted_blocked_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
post_from_blocked_person.language_id = Some(LanguageId(1));
|
||||
Post::create(pool, &post_from_blocked_person).await?;
|
||||
|
||||
// block that person
|
||||
@ -869,22 +867,18 @@ mod tests {
|
||||
PersonBlock::block(pool, &person_block).await?;
|
||||
|
||||
// A sample post
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name(POST.to_string())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.language_id(Some(LanguageId(47)))
|
||||
.build();
|
||||
|
||||
let mut new_post =
|
||||
PostInsertForm::new(POST.to_string(), inserted_person.id, inserted_community.id);
|
||||
new_post.language_id = Some(LanguageId(47));
|
||||
let inserted_post = Post::create(pool, &new_post).await?;
|
||||
|
||||
let new_bot_post = PostInsertForm::builder()
|
||||
.name(POST_BY_BOT.to_string())
|
||||
.creator_id(inserted_bot.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_bot_post = PostInsertForm::new(
|
||||
POST_BY_BOT.to_string(),
|
||||
inserted_bot.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_bot_post = Post::create(pool, &new_bot_post).await?;
|
||||
|
||||
let local_user_view = LocalUserView {
|
||||
local_user: inserted_local_user,
|
||||
local_user_vote_display_mode: LocalUserVoteDisplayMode::default(),
|
||||
@ -1037,13 +1031,13 @@ mod tests {
|
||||
let data = init_data(pool).await?;
|
||||
|
||||
// A post which contains the search them 'Post' not in the title (but in the body)
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name(POST_WITH_ANOTHER_TITLE.to_string())
|
||||
.creator_id(data.local_user_view.person.id)
|
||||
.community_id(data.inserted_community.id)
|
||||
.language_id(Some(LanguageId(47)))
|
||||
.body(Some("Post".to_string()))
|
||||
.build();
|
||||
let mut new_post = PostInsertForm::new(
|
||||
POST_WITH_ANOTHER_TITLE.to_string(),
|
||||
data.local_user_view.person.id,
|
||||
data.inserted_community.id,
|
||||
);
|
||||
new_post.language_id = Some(LanguageId(47));
|
||||
new_post.body = Some("Post".to_string());
|
||||
|
||||
let inserted_post = Post::create(pool, &new_post).await?;
|
||||
|
||||
@ -1273,13 +1267,12 @@ mod tests {
|
||||
.await?
|
||||
.expect("french should exist");
|
||||
|
||||
let post_spanish = PostInsertForm::builder()
|
||||
.name(EL_POSTO.to_string())
|
||||
.creator_id(data.local_user_view.person.id)
|
||||
.community_id(data.inserted_community.id)
|
||||
.language_id(Some(spanish_id))
|
||||
.build();
|
||||
|
||||
let mut post_spanish = PostInsertForm::new(
|
||||
EL_POSTO.to_string(),
|
||||
data.local_user_view.person.id,
|
||||
data.inserted_community.id,
|
||||
);
|
||||
post_spanish.language_id = Some(spanish_id);
|
||||
Post::create(pool, &post_spanish).await?;
|
||||
|
||||
let post_listings_all = data.default_post_query().list(&data.site, pool).await?;
|
||||
@ -1407,21 +1400,20 @@ mod tests {
|
||||
|
||||
let blocked_instance = Instance::read_or_create(pool, "another_domain.tld".to_string()).await?;
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("test_community_4".to_string())
|
||||
.title("none".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(blocked_instance.id)
|
||||
.build();
|
||||
let community_form = CommunityInsertForm::new(
|
||||
blocked_instance.id,
|
||||
"test_community_4".to_string(),
|
||||
"none".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &community_form).await?;
|
||||
|
||||
let post_form = PostInsertForm::builder()
|
||||
.name(POST_FROM_BLOCKED_INSTANCE.to_string())
|
||||
.creator_id(data.inserted_bot.id)
|
||||
.community_id(inserted_community.id)
|
||||
.language_id(Some(LanguageId(1)))
|
||||
.build();
|
||||
|
||||
let mut post_form = PostInsertForm::new(
|
||||
POST_FROM_BLOCKED_INSTANCE.to_string(),
|
||||
data.inserted_bot.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
post_form.language_id = Some(LanguageId(1));
|
||||
let post_from_blocked_instance = Post::create(pool, &post_form).await?;
|
||||
|
||||
// no instance block, should return all posts
|
||||
@ -1464,12 +1456,12 @@ mod tests {
|
||||
let pool = &mut pool.into();
|
||||
let data = init_data(pool).await?;
|
||||
|
||||
let community_form = CommunityInsertForm::builder()
|
||||
.name("yes".to_string())
|
||||
.title("yes".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(data.inserted_instance.id)
|
||||
.build();
|
||||
let community_form = CommunityInsertForm::new(
|
||||
data.inserted_instance.id,
|
||||
"yes".to_string(),
|
||||
"yes".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &community_form).await?;
|
||||
|
||||
let mut inserted_post_ids = vec![];
|
||||
@ -1479,23 +1471,23 @@ mod tests {
|
||||
// and featured
|
||||
for comments in 0..10 {
|
||||
for _ in 0..15 {
|
||||
let post_form = PostInsertForm::builder()
|
||||
.name("keep Christ in Christmas".to_owned())
|
||||
.creator_id(data.local_user_view.person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.featured_local(Some((comments % 2) == 0))
|
||||
.featured_community(Some((comments % 2) == 0))
|
||||
.published(Some(Utc::now() - Duration::from_secs(comments % 3)))
|
||||
.build();
|
||||
let mut post_form = PostInsertForm::new(
|
||||
"keep Christ in Christmas".to_owned(),
|
||||
data.local_user_view.person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
post_form.featured_local = Some((comments % 2) == 0);
|
||||
post_form.featured_community = Some((comments % 2) == 0);
|
||||
post_form.published = Some(Utc::now() - Duration::from_secs(comments % 3));
|
||||
let inserted_post = Post::create(pool, &post_form).await?;
|
||||
inserted_post_ids.push(inserted_post.id);
|
||||
|
||||
for _ in 0..comments {
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.creator_id(data.local_user_view.person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.content("yes".to_owned())
|
||||
.build();
|
||||
let comment_form = CommentInsertForm::new(
|
||||
data.local_user_view.person.id,
|
||||
inserted_post.id,
|
||||
"yes".to_owned(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await?;
|
||||
inserted_comment_ids.push(inserted_comment.id);
|
||||
}
|
||||
|
@ -147,11 +147,11 @@ mod tests {
|
||||
let inserted_jessica = Person::create(pool, &new_person_2).await.unwrap();
|
||||
|
||||
// timmy sends private message to jessica
|
||||
let pm_form = PrivateMessageInsertForm::builder()
|
||||
.creator_id(inserted_timmy.id)
|
||||
.recipient_id(inserted_jessica.id)
|
||||
.content("something offensive".to_string())
|
||||
.build();
|
||||
let pm_form = PrivateMessageInsertForm::new(
|
||||
inserted_timmy.id,
|
||||
inserted_jessica.id,
|
||||
"something offensive".to_string(),
|
||||
);
|
||||
let pm = PrivateMessage::create(pool, &pm_form).await.unwrap();
|
||||
|
||||
// jessica reports private message
|
||||
|
@ -221,38 +221,26 @@ mod tests {
|
||||
|
||||
let jess = Person::create(pool, &jess_form).await.unwrap();
|
||||
|
||||
let sara_timmy_message_form = PrivateMessageInsertForm::builder()
|
||||
.creator_id(sara.id)
|
||||
.recipient_id(timmy.id)
|
||||
.content(message_content.clone())
|
||||
.build();
|
||||
let sara_timmy_message_form =
|
||||
PrivateMessageInsertForm::new(sara.id, timmy.id, message_content.clone());
|
||||
PrivateMessage::create(pool, &sara_timmy_message_form)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sara_jess_message_form = PrivateMessageInsertForm::builder()
|
||||
.creator_id(sara.id)
|
||||
.recipient_id(jess.id)
|
||||
.content(message_content.clone())
|
||||
.build();
|
||||
let sara_jess_message_form =
|
||||
PrivateMessageInsertForm::new(sara.id, jess.id, message_content.clone());
|
||||
PrivateMessage::create(pool, &sara_jess_message_form)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let timmy_sara_message_form = PrivateMessageInsertForm::builder()
|
||||
.creator_id(timmy.id)
|
||||
.recipient_id(sara.id)
|
||||
.content(message_content.clone())
|
||||
.build();
|
||||
let timmy_sara_message_form =
|
||||
PrivateMessageInsertForm::new(timmy.id, sara.id, message_content.clone());
|
||||
PrivateMessage::create(pool, &timmy_sara_message_form)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let jess_timmy_message_form = PrivateMessageInsertForm::builder()
|
||||
.creator_id(jess.id)
|
||||
.recipient_id(timmy.id)
|
||||
.content(message_content.clone())
|
||||
.build();
|
||||
let jess_timmy_message_form =
|
||||
PrivateMessageInsertForm::new(jess.id, timmy.id, message_content.clone());
|
||||
PrivateMessage::create(pool, &jess_timmy_message_form)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -120,29 +120,26 @@ mod tests {
|
||||
|
||||
let inserted_sara = Person::create(pool, &new_person_2).await.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community vv".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community vv".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post vv".into())
|
||||
.creator_id(inserted_timmy.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post vv".into(),
|
||||
inserted_timmy.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment vv".into())
|
||||
.creator_id(inserted_timmy.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_timmy.id,
|
||||
inserted_post.id,
|
||||
"A test comment vv".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
||||
|
||||
// Timmy upvotes his own post
|
||||
|
@ -348,29 +348,23 @@ mod tests {
|
||||
let recipient_local_user =
|
||||
LocalUser::create(pool, &LocalUserInsertForm::test_form(recipient_id), vec![]).await?;
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community lake".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community lake".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await?;
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_terry.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_terry.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await?;
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_terry.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form =
|
||||
CommentInsertForm::new(inserted_terry.id, inserted_post.id, "A test comment".into());
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await?;
|
||||
|
||||
let comment_reply_form = CommentReplyInsertForm {
|
||||
|
@ -280,13 +280,12 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test_community_3".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test_community_3".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
||||
|
||||
let url = Url::parse("http://example.com").unwrap();
|
||||
|
@ -346,29 +346,26 @@ mod tests {
|
||||
let recipient_local_user =
|
||||
LocalUser::create(pool, &LocalUserInsertForm::test_form(recipient_id), vec![]).await?;
|
||||
|
||||
let new_community = CommunityInsertForm::builder()
|
||||
.name("test community lake".to_string())
|
||||
.title("nada".to_owned())
|
||||
.public_key("pubkey".to_string())
|
||||
.instance_id(inserted_instance.id)
|
||||
.build();
|
||||
|
||||
let new_community = CommunityInsertForm::new(
|
||||
inserted_instance.id,
|
||||
"test community lake".to_string(),
|
||||
"nada".to_owned(),
|
||||
"pubkey".to_string(),
|
||||
);
|
||||
let inserted_community = Community::create(pool, &new_community).await?;
|
||||
|
||||
let new_post = PostInsertForm::builder()
|
||||
.name("A test post".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.community_id(inserted_community.id)
|
||||
.build();
|
||||
|
||||
let new_post = PostInsertForm::new(
|
||||
"A test post".into(),
|
||||
inserted_person.id,
|
||||
inserted_community.id,
|
||||
);
|
||||
let inserted_post = Post::create(pool, &new_post).await?;
|
||||
|
||||
let comment_form = CommentInsertForm::builder()
|
||||
.content("A test comment".into())
|
||||
.creator_id(inserted_person.id)
|
||||
.post_id(inserted_post.id)
|
||||
.build();
|
||||
|
||||
let comment_form = CommentInsertForm::new(
|
||||
inserted_person.id,
|
||||
inserted_post.id,
|
||||
"A test comment".into(),
|
||||
);
|
||||
let inserted_comment = Comment::create(pool, &comment_form, None).await?;
|
||||
|
||||
let person_mention_form = PersonMentionInsertForm {
|
||||
|
@ -354,10 +354,8 @@ mod test {
|
||||
let mut data = TestData::init(1, 1).await?;
|
||||
|
||||
let instance = &data.instances[0];
|
||||
let form = InstanceForm::builder()
|
||||
.domain(instance.domain.clone())
|
||||
.updated(DateTime::from_timestamp(0, 0))
|
||||
.build();
|
||||
let mut form = InstanceForm::new(instance.domain.clone());
|
||||
form.updated = DateTime::from_timestamp(0, 0);
|
||||
Instance::update(&mut data.context.pool(), instance.id, form).await?;
|
||||
|
||||
data.run().await?;
|
||||
|
@ -290,10 +290,8 @@ impl InstanceWorker {
|
||||
if updated.add(Days::new(1)) < Utc::now() {
|
||||
self.instance.updated = Some(Utc::now());
|
||||
|
||||
let form = InstanceForm::builder()
|
||||
.domain(self.instance.domain.clone())
|
||||
.updated(Some(naive_now()))
|
||||
.build();
|
||||
let mut form = InstanceForm::new(self.instance.domain.clone());
|
||||
form.updated = Some(naive_now());
|
||||
Instance::update(&mut self.pool(), self.instance.id, form).await?;
|
||||
}
|
||||
Ok(())
|
||||
@ -658,10 +656,7 @@ mod test {
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn test_update_instance(data: &mut Data) -> LemmyResult<()> {
|
||||
let form = InstanceForm::builder()
|
||||
.domain(data.instance.domain.clone())
|
||||
.updated(None)
|
||||
.build();
|
||||
let form = InstanceForm::new(data.instance.domain.clone());
|
||||
Instance::update(&mut data.context.pool(), data.instance.id, form).await?;
|
||||
|
||||
send_activity(data.person.actor_id.clone(), &data.context, true).await?;
|
||||
|
@ -480,44 +480,36 @@ async fn initialize_local_site_2022_10_10(
|
||||
let site_key_pair = generate_actor_keypair()?;
|
||||
let site_actor_id = Url::parse(&settings.get_protocol_and_hostname())?;
|
||||
|
||||
let site_form = SiteInsertForm::builder()
|
||||
.name(
|
||||
settings
|
||||
let name = settings
|
||||
.setup
|
||||
.clone()
|
||||
.map(|s| s.site_name)
|
||||
.unwrap_or_else(|| "New Site".to_string()),
|
||||
)
|
||||
.instance_id(instance.id)
|
||||
.actor_id(Some(site_actor_id.clone().into()))
|
||||
.last_refreshed_at(Some(naive_now()))
|
||||
.inbox_url(Some(generate_shared_inbox_url(settings)?))
|
||||
.private_key(Some(site_key_pair.private_key))
|
||||
.public_key(Some(site_key_pair.public_key))
|
||||
.build();
|
||||
.unwrap_or_else(|| "New Site".to_string());
|
||||
let mut site_form = SiteInsertForm::new(name, instance.id);
|
||||
site_form.actor_id = Some(site_actor_id.clone().into());
|
||||
site_form.last_refreshed_at = Some(naive_now());
|
||||
site_form.inbox_url = Some(generate_shared_inbox_url(settings)?);
|
||||
site_form.private_key = Some(site_key_pair.private_key);
|
||||
site_form.public_key = Some(site_key_pair.public_key);
|
||||
let site = Site::create(pool, &site_form).await?;
|
||||
|
||||
// Finally create the local_site row
|
||||
let local_site_form = LocalSiteInsertForm::builder()
|
||||
.site_id(site.id)
|
||||
.site_setup(Some(settings.setup.is_some()))
|
||||
.build();
|
||||
let mut local_site_form = LocalSiteInsertForm::new(site.id);
|
||||
local_site_form.site_setup = Some(settings.setup.is_some());
|
||||
let local_site = LocalSite::create(pool, &local_site_form).await?;
|
||||
|
||||
// Create the rate limit table
|
||||
let local_site_rate_limit_form = LocalSiteRateLimitInsertForm::builder()
|
||||
let mut local_site_rate_limit_form = LocalSiteRateLimitInsertForm::new(local_site.id);
|
||||
// TODO these have to be set, because the database defaults are too low for the federation
|
||||
// tests to pass, and there's no way to live update the rate limits without restarting the
|
||||
// server.
|
||||
// This can be removed once live rate limits are enabled.
|
||||
.message(Some(999))
|
||||
.post(Some(999))
|
||||
.register(Some(999))
|
||||
.image(Some(999))
|
||||
.comment(Some(999))
|
||||
.search(Some(999))
|
||||
.local_site_id(local_site.id)
|
||||
.build();
|
||||
local_site_rate_limit_form.message = Some(999);
|
||||
local_site_rate_limit_form.post = Some(999);
|
||||
local_site_rate_limit_form.register = Some(999);
|
||||
local_site_rate_limit_form.image = Some(999);
|
||||
local_site_rate_limit_form.comment = Some(999);
|
||||
local_site_rate_limit_form.search = Some(999);
|
||||
LocalSiteRateLimit::create(pool, &local_site_rate_limit_form).await?;
|
||||
|
||||
Ok(())
|
||||
|
@ -493,10 +493,8 @@ async fn build_update_instance_form(
|
||||
// not every Fediverse instance has a valid Nodeinfo endpoint (its not required for
|
||||
// Activitypub). That's why we always need to mark instances as updated if they are
|
||||
// alive.
|
||||
let mut instance_form = InstanceForm::builder()
|
||||
.domain(domain.to_string())
|
||||
.updated(Some(naive_now()))
|
||||
.build();
|
||||
let mut instance_form = InstanceForm::new(domain.to_string());
|
||||
instance_form.updated = Some(naive_now());
|
||||
|
||||
// First, fetch their /.well-known/nodeinfo, then extract the correct nodeinfo link from it
|
||||
let well_known_url = format!("https://{}/.well-known/nodeinfo", domain);
|
||||
|
Loading…
Reference in New Issue
Block a user