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