mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
Merge branch 'main' into simplify-not-found
This commit is contained in:
commit
f967ffcd52
61 changed files with 810 additions and 844 deletions
21
Cargo.lock
generated
21
Cargo.lock
generated
|
@ -2640,7 +2640,6 @@ dependencies = [
|
||||||
"tokio-postgres-rustls",
|
"tokio-postgres-rustls",
|
||||||
"tracing",
|
"tracing",
|
||||||
"ts-rs",
|
"ts-rs",
|
||||||
"typed-builder",
|
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
@ -5237,26 +5236,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.77",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "typenum"
|
||||||
version = "1.17.0"
|
version = "1.17.0"
|
||||||
|
|
|
@ -131,7 +131,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"
|
||||||
|
|
|
@ -56,28 +56,23 @@ async fn create_test_site(context: &Data<LemmyContext>) -> LemmyResult<(Instance
|
||||||
|
|
||||||
let admin_local_user_view = LocalUserView::read_person(pool, admin_person.id).await?;
|
let admin_local_user_view = LocalUserView::read_person(pool, admin_person.id).await?;
|
||||||
|
|
||||||
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 local_site_form = LocalSiteInsertForm {
|
||||||
.site_id(site.id)
|
require_email_verification: Some(true),
|
||||||
.require_email_verification(Some(true))
|
application_question: Some(".".to_string()),
|
||||||
.application_question(Some(".".to_string()))
|
registration_mode: Some(RegistrationMode::RequireApplication),
|
||||||
.registration_mode(Some(RegistrationMode::RequireApplication))
|
site_setup: Some(true),
|
||||||
.site_setup(Some(true))
|
..LocalSiteInsertForm::new(site.id)
|
||||||
.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();
|
||||||
|
|
|
@ -17,7 +17,7 @@ use lemmy_db_schema::{
|
||||||
community::{Community, CommunityModerator, CommunityUpdateForm},
|
community::{Community, CommunityModerator, CommunityUpdateForm},
|
||||||
community_block::CommunityBlock,
|
community_block::CommunityBlock,
|
||||||
email_verification::{EmailVerification, EmailVerificationForm},
|
email_verification::{EmailVerification, EmailVerificationForm},
|
||||||
images::RemoteImage,
|
images::{ImageDetails, RemoteImage},
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
instance_block::InstanceBlock,
|
instance_block::InstanceBlock,
|
||||||
local_site::LocalSite,
|
local_site::LocalSite,
|
||||||
|
@ -1002,6 +1002,7 @@ pub async fn process_markdown(
|
||||||
|
|
||||||
if context.settings().pictrs_config()?.image_mode() == PictrsImageMode::ProxyAllImages {
|
if context.settings().pictrs_config()?.image_mode() == PictrsImageMode::ProxyAllImages {
|
||||||
let (text, links) = markdown_rewrite_image_links(text);
|
let (text, links) = markdown_rewrite_image_links(text);
|
||||||
|
RemoteImage::create(&mut context.pool(), links.clone()).await?;
|
||||||
|
|
||||||
// Create images and image detail rows
|
// Create images and image detail rows
|
||||||
for link in links {
|
for link in links {
|
||||||
|
@ -1011,7 +1012,7 @@ pub async fn process_markdown(
|
||||||
let proxied =
|
let proxied =
|
||||||
build_proxied_image_url(&link, &context.settings().get_protocol_and_hostname())?;
|
build_proxied_image_url(&link, &context.settings().get_protocol_and_hostname())?;
|
||||||
let details_form = details.build_image_details_form(&proxied);
|
let details_form = details.build_image_details_form(&proxied);
|
||||||
RemoteImage::create(&mut context.pool(), &details_form).await?;
|
ImageDetails::create(&mut context.pool(), &details_form).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(text)
|
Ok(text)
|
||||||
|
@ -1047,13 +1048,15 @@ async fn proxy_image_link_internal(
|
||||||
if link.domain() == Some(&context.settings().hostname) {
|
if link.domain() == Some(&context.settings().hostname) {
|
||||||
Ok(link.into())
|
Ok(link.into())
|
||||||
} else if image_mode == PictrsImageMode::ProxyAllImages {
|
} else if image_mode == PictrsImageMode::ProxyAllImages {
|
||||||
|
RemoteImage::create(&mut context.pool(), vec![link.clone()]).await?;
|
||||||
|
|
||||||
let proxied = build_proxied_image_url(&link, &context.settings().get_protocol_and_hostname())?;
|
let proxied = build_proxied_image_url(&link, &context.settings().get_protocol_and_hostname())?;
|
||||||
// This should fail softly, since pictrs might not even be running
|
// This should fail softly, since pictrs might not even be running
|
||||||
let details_res = fetch_pictrs_proxied_image_details(&link, context).await;
|
let details_res = fetch_pictrs_proxied_image_details(&link, context).await;
|
||||||
|
|
||||||
if let Ok(details) = details_res {
|
if let Ok(details) = details_res {
|
||||||
let details_form = details.build_image_details_form(&proxied);
|
let details_form = details.build_image_details_form(&proxied);
|
||||||
RemoteImage::create(&mut context.pool(), &details_form).await?;
|
ImageDetails::create(&mut context.pool(), &details_form).await?;
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(proxied.into())
|
Ok(proxied.into())
|
||||||
|
@ -1199,7 +1202,7 @@ mod tests {
|
||||||
assert!(
|
assert!(
|
||||||
RemoteImage::validate(&mut context.pool(), remote_image.into())
|
RemoteImage::validate(&mut context.pool(), remote_image.into())
|
||||||
.await
|
.await
|
||||||
.is_err()
|
.is_ok()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,12 +109,10 @@ pub async fn create_comment(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let comment_form = CommentInsertForm::builder()
|
let comment_form = CommentInsertForm {
|
||||||
.content(content.clone())
|
language_id,
|
||||||
.post_id(data.post_id)
|
..CommentInsertForm::new(local_user_view.person.id, data.post_id, content.clone())
|
||||||
.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);
|
||||||
|
|
|
@ -88,23 +88,25 @@ 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 community_form = CommunityInsertForm {
|
||||||
.name(data.name.clone())
|
description,
|
||||||
.title(data.title.clone())
|
icon,
|
||||||
.description(description)
|
banner,
|
||||||
.icon(icon)
|
nsfw: data.nsfw,
|
||||||
.banner(banner)
|
actor_id: Some(community_actor_id.clone()),
|
||||||
.nsfw(data.nsfw)
|
private_key: Some(keypair.private_key),
|
||||||
.actor_id(Some(community_actor_id.clone()))
|
followers_url: Some(generate_followers_url(&community_actor_id)?),
|
||||||
.private_key(Some(keypair.private_key))
|
inbox_url: Some(generate_inbox_url(&community_actor_id)?),
|
||||||
.public_key(keypair.public_key)
|
shared_inbox_url: Some(generate_shared_inbox_url(context.settings())?),
|
||||||
.followers_url(Some(generate_followers_url(&community_actor_id)?))
|
posting_restricted_to_mods: data.posting_restricted_to_mods,
|
||||||
.inbox_url(Some(generate_inbox_url(&community_actor_id)?))
|
visibility: data.visibility,
|
||||||
.shared_inbox_url(Some(generate_shared_inbox_url(context.settings())?))
|
..CommunityInsertForm::new(
|
||||||
.posting_restricted_to_mods(data.posting_restricted_to_mods)
|
site_view.site.instance_id,
|
||||||
.instance_id(site_view.site.instance_id)
|
data.name.clone(),
|
||||||
.visibility(data.visibility)
|
data.title.clone(),
|
||||||
.build();
|
keypair.public_key,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let inserted_community = Community::create(&mut context.pool(), &community_form)
|
let inserted_community = Community::create(&mut context.pool(), &community_form)
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -24,19 +24,17 @@ 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(
|
||||||
.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?;
|
||||||
|
|
|
@ -24,19 +24,17 @@ 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(
|
||||||
.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?;
|
||||||
|
|
|
@ -128,16 +128,18 @@ pub async fn create_post(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let post_form = PostInsertForm::builder()
|
let post_form = PostInsertForm {
|
||||||
.name(data.name.trim().to_string())
|
url: url.map(Into::into),
|
||||||
.url(url.map(Into::into))
|
body,
|
||||||
.body(body)
|
alt_text: data.alt_text.clone(),
|
||||||
.alt_text(data.alt_text.clone())
|
nsfw: data.nsfw,
|
||||||
.community_id(data.community_id)
|
language_id,
|
||||||
.creator_id(local_user_view.person.id)
|
..PostInsertForm::new(
|
||||||
.nsfw(data.nsfw)
|
data.name.trim().to_string(),
|
||||||
.language_id(language_id)
|
local_user_view.person.id,
|
||||||
.build();
|
data.community_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
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use super::not_zero;
|
||||||
use crate::site::{application_question_check, site_default_post_listing_type_check};
|
use crate::site::{application_question_check, site_default_post_listing_type_check};
|
||||||
use activitypub_federation::{config::Data, http_signatures::generate_actor_keypair};
|
use activitypub_federation::{config::Data, http_signatures::generate_actor_keypair};
|
||||||
use actix_web::web::Json;
|
use actix_web::web::Json;
|
||||||
|
@ -116,17 +117,17 @@ pub async fn create_site(
|
||||||
|
|
||||||
let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
|
let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
|
||||||
message: data.rate_limit_message,
|
message: data.rate_limit_message,
|
||||||
message_per_second: data.rate_limit_message_per_second,
|
message_per_second: not_zero(data.rate_limit_message_per_second),
|
||||||
post: data.rate_limit_post,
|
post: data.rate_limit_post,
|
||||||
post_per_second: data.rate_limit_post_per_second,
|
post_per_second: not_zero(data.rate_limit_post_per_second),
|
||||||
register: data.rate_limit_register,
|
register: data.rate_limit_register,
|
||||||
register_per_second: data.rate_limit_register_per_second,
|
register_per_second: not_zero(data.rate_limit_register_per_second),
|
||||||
image: data.rate_limit_image,
|
image: data.rate_limit_image,
|
||||||
image_per_second: data.rate_limit_image_per_second,
|
image_per_second: not_zero(data.rate_limit_image_per_second),
|
||||||
comment: data.rate_limit_comment,
|
comment: data.rate_limit_comment,
|
||||||
comment_per_second: data.rate_limit_comment_per_second,
|
comment_per_second: not_zero(data.rate_limit_comment_per_second),
|
||||||
search: data.rate_limit_search,
|
search: data.rate_limit_search,
|
||||||
search_per_second: data.rate_limit_search_per_second,
|
search_per_second: not_zero(data.rate_limit_search_per_second),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,19 @@ pub fn application_question_check(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn not_zero(val: Option<i32>) -> Option<i32> {
|
||||||
|
match val {
|
||||||
|
Some(0) => None,
|
||||||
|
v => v,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
#[allow(clippy::indexing_slicing)]
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use crate::site::{application_question_check, site_default_post_listing_type_check};
|
use crate::site::{application_question_check, not_zero, site_default_post_listing_type_check};
|
||||||
use lemmy_db_schema::{ListingType, RegistrationMode};
|
use lemmy_db_schema::{ListingType, RegistrationMode};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -93,4 +100,11 @@ mod tests {
|
||||||
RegistrationMode::RequireApplication
|
RegistrationMode::RequireApplication
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_not_zero() {
|
||||||
|
assert_eq!(None, not_zero(None));
|
||||||
|
assert_eq!(None, not_zero(Some(0)));
|
||||||
|
assert_eq!(Some(5), not_zero(Some(5)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use super::not_zero;
|
||||||
use crate::site::{application_question_check, site_default_post_listing_type_check};
|
use crate::site::{application_question_check, site_default_post_listing_type_check};
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::Json;
|
||||||
|
@ -129,17 +130,17 @@ pub async fn update_site(
|
||||||
|
|
||||||
let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
|
let local_site_rate_limit_form = LocalSiteRateLimitUpdateForm {
|
||||||
message: data.rate_limit_message,
|
message: data.rate_limit_message,
|
||||||
message_per_second: data.rate_limit_message_per_second,
|
message_per_second: not_zero(data.rate_limit_message_per_second),
|
||||||
post: data.rate_limit_post,
|
post: data.rate_limit_post,
|
||||||
post_per_second: data.rate_limit_post_per_second,
|
post_per_second: not_zero(data.rate_limit_post_per_second),
|
||||||
register: data.rate_limit_register,
|
register: data.rate_limit_register,
|
||||||
register_per_second: data.rate_limit_register_per_second,
|
register_per_second: not_zero(data.rate_limit_register_per_second),
|
||||||
image: data.rate_limit_image,
|
image: data.rate_limit_image,
|
||||||
image_per_second: data.rate_limit_image_per_second,
|
image_per_second: not_zero(data.rate_limit_image_per_second),
|
||||||
comment: data.rate_limit_comment,
|
comment: data.rate_limit_comment,
|
||||||
comment_per_second: data.rate_limit_comment_per_second,
|
comment_per_second: not_zero(data.rate_limit_comment_per_second),
|
||||||
search: data.rate_limit_search,
|
search: data.rate_limit_search,
|
||||||
search_per_second: data.rate_limit_search_per_second,
|
search_per_second: not_zero(data.rate_limit_search_per_second),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -359,11 +359,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,
|
||||||
|
@ -408,11 +409,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,16 @@ 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 community_form = CommunityInsertForm {
|
||||||
.name("testcom6".to_string())
|
deleted: Some(deleted),
|
||||||
.title("nada".to_owned())
|
visibility: Some(visibility),
|
||||||
.public_key("pubkey".to_string())
|
..CommunityInsertForm::new(
|
||||||
.instance_id(instance.id)
|
instance.id,
|
||||||
.deleted(Some(deleted))
|
"testcom6".to_string(),
|
||||||
.visibility(Some(visibility))
|
"nada".to_owned(),
|
||||||
.build();
|
"pubkey".to_string(),
|
||||||
|
)
|
||||||
|
};
|
||||||
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 +171,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(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,27 +152,28 @@ impl Object for ApubCommunity {
|
||||||
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 form = CommunityInsertForm {
|
||||||
name: group.preferred_username.clone(),
|
|
||||||
title: group.name.unwrap_or(group.preferred_username.clone()),
|
|
||||||
description,
|
|
||||||
published: group.published,
|
published: group.published,
|
||||||
updated: group.updated,
|
updated: group.updated,
|
||||||
deleted: Some(false),
|
deleted: Some(false),
|
||||||
nsfw: Some(group.sensitive.unwrap_or(false)),
|
nsfw: Some(group.sensitive.unwrap_or(false)),
|
||||||
actor_id: Some(group.id.into()),
|
actor_id: Some(group.id.into()),
|
||||||
local: Some(false),
|
local: Some(false),
|
||||||
public_key: group.public_key.public_key_pem,
|
|
||||||
last_refreshed_at: Some(naive_now()),
|
last_refreshed_at: Some(naive_now()),
|
||||||
icon,
|
icon,
|
||||||
banner,
|
banner,
|
||||||
|
description,
|
||||||
followers_url: group.followers.clone().map(Into::into),
|
followers_url: group.followers.clone().map(Into::into),
|
||||||
inbox_url: Some(group.inbox.into()),
|
inbox_url: Some(group.inbox.into()),
|
||||||
shared_inbox_url: group.endpoints.map(|e| e.shared_inbox.into()),
|
shared_inbox_url: group.endpoints.map(|e| e.shared_inbox.into()),
|
||||||
moderators_url: group.attributed_to.clone().map(Into::into),
|
moderators_url: group.attributed_to.clone().map(Into::into),
|
||||||
posting_restricted_to_mods: group.posting_restricted_to_mods,
|
posting_restricted_to_mods: group.posting_restricted_to_mods,
|
||||||
instance_id,
|
|
||||||
featured_url: group.featured.clone().map(Into::into),
|
featured_url: group.featured.clone().map(Into::into),
|
||||||
..Default::default()
|
..CommunityInsertForm::new(
|
||||||
|
instance_id,
|
||||||
|
group.preferred_username.clone(),
|
||||||
|
group.name.unwrap_or(group.preferred_username.clone()),
|
||||||
|
group.public_key.public_key_pem,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
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?;
|
||||||
|
|
|
@ -243,21 +243,19 @@ 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 form = PostInsertForm {
|
||||||
.name(name)
|
url: url.map(Into::into),
|
||||||
.url(url.map(Into::into))
|
body,
|
||||||
.body(body)
|
alt_text,
|
||||||
.alt_text(alt_text)
|
published: page.published.map(Into::into),
|
||||||
.creator_id(creator.id)
|
updated: page.updated.map(Into::into),
|
||||||
.community_id(community.id)
|
deleted: Some(false),
|
||||||
.published(page.published.map(Into::into))
|
nsfw: page.sensitive,
|
||||||
.updated(page.updated.map(Into::into))
|
ap_id: Some(page.id.clone().into()),
|
||||||
.deleted(Some(false))
|
local: Some(false),
|
||||||
.nsfw(page.sensitive)
|
language_id,
|
||||||
.ap_id(Some(page.id.clone().into()))
|
..PostInsertForm::new(name, creator.id, community.id)
|
||||||
.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 }
|
||||||
|
|
|
@ -67,37 +67,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
|
||||||
|
|
|
@ -86,37 +86,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
|
||||||
|
@ -208,28 +204,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
|
||||||
|
|
|
@ -471,13 +471,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 {
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::DbUrl,
|
newtypes::DbUrl,
|
||||||
schema::{image_details, local_image, remote_image},
|
schema::{image_details, local_image, remote_image},
|
||||||
source::images::{
|
source::images::{ImageDetails, ImageDetailsForm, LocalImage, LocalImageForm, RemoteImage},
|
||||||
ImageDetails,
|
|
||||||
ImageDetailsForm,
|
|
||||||
LocalImage,
|
|
||||||
LocalImageForm,
|
|
||||||
RemoteImage,
|
|
||||||
RemoteImageForm,
|
|
||||||
},
|
|
||||||
utils::{get_conn, DbPool},
|
utils::{get_conn, DbPool},
|
||||||
};
|
};
|
||||||
use diesel::{
|
use diesel::{
|
||||||
|
@ -20,7 +13,8 @@ use diesel::{
|
||||||
NotFound,
|
NotFound,
|
||||||
QueryDsl,
|
QueryDsl,
|
||||||
};
|
};
|
||||||
use diesel_async::{AsyncPgConnection, RunQueryDsl};
|
use diesel_async::RunQueryDsl;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
impl LocalImage {
|
impl LocalImage {
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
|
@ -38,7 +32,7 @@ impl LocalImage {
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
ImageDetails::create(conn, image_details_form).await?;
|
ImageDetails::create(&mut conn.into(), image_details_form).await?;
|
||||||
|
|
||||||
local_insert
|
local_insert
|
||||||
}) as _
|
}) as _
|
||||||
|
@ -60,26 +54,16 @@ impl LocalImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RemoteImage {
|
impl RemoteImage {
|
||||||
pub async fn create(pool: &mut DbPool<'_>, form: &ImageDetailsForm) -> Result<usize, Error> {
|
pub async fn create(pool: &mut DbPool<'_>, links: Vec<Url>) -> Result<usize, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
conn
|
let forms = links
|
||||||
.build_transaction()
|
.into_iter()
|
||||||
.run(|conn| {
|
.map(|url| remote_image::dsl::link.eq::<DbUrl>(url.into()))
|
||||||
Box::pin(async move {
|
.collect::<Vec<_>>();
|
||||||
let remote_image_form = RemoteImageForm {
|
insert_into(remote_image::table)
|
||||||
link: form.link.clone(),
|
.values(forms)
|
||||||
};
|
|
||||||
let remote_insert = insert_into(remote_image::table)
|
|
||||||
.values(remote_image_form)
|
|
||||||
.on_conflict_do_nothing()
|
.on_conflict_do_nothing()
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.await;
|
|
||||||
|
|
||||||
ImageDetails::create(conn, form).await?;
|
|
||||||
|
|
||||||
remote_insert
|
|
||||||
}) as _
|
|
||||||
})
|
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,10 +84,9 @@ impl RemoteImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImageDetails {
|
impl ImageDetails {
|
||||||
pub(crate) async fn create(
|
pub async fn create(pool: &mut DbPool<'_>, form: &ImageDetailsForm) -> Result<usize, Error> {
|
||||||
conn: &mut AsyncPgConnection,
|
let conn = &mut get_conn(pool).await?;
|
||||||
form: &ImageDetailsForm,
|
|
||||||
) -> Result<usize, Error> {
|
|
||||||
insert_into(image_details::table)
|
insert_into(image_details::table)
|
||||||
.values(form)
|
.values(form)
|
||||||
.on_conflict_do_nothing()
|
.on_conflict_do_nothing()
|
||||||
|
|
|
@ -51,10 +51,10 @@ 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 form = InstanceForm {
|
||||||
.domain(domain_)
|
updated: Some(naive_now()),
|
||||||
.updated(Some(naive_now()))
|
..InstanceForm::new(domain_)
|
||||||
.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
|
||||||
|
|
|
@ -49,9 +49,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
|
||||||
|
|
|
@ -410,28 +410,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)]
|
||||||
|
@ -25,7 +24,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 {
|
||||||
|
@ -35,7 +34,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 {
|
||||||
|
|
|
@ -51,13 +51,6 @@ pub struct RemoteImage {
|
||||||
pub published: DateTime<Utc>,
|
pub published: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = remote_image))]
|
|
||||||
pub struct RemoteImageForm {
|
|
||||||
pub link: DbUrl,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[skip_serializing_none]
|
#[skip_serializing_none]
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
|
|
|
@ -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>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,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)]
|
||||||
|
@ -75,35 +74,56 @@ pub struct LocalSite {
|
||||||
pub oauth_registration: bool,
|
pub oauth_registration: 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_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 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 oauth_registration: Option<bool>,
|
pub oauth_registration: Option<bool>,
|
||||||
|
#[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_post_sort_type: Option<PostSortType>,
|
pub default_post_sort_type: Option<PostSortType>,
|
||||||
|
#[new(default)]
|
||||||
pub default_comment_sort_type: Option<CommentSortType>,
|
pub default_comment_sort_type: Option<CommentSortType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -489,21 +489,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?;
|
||||||
|
|
||||||
|
@ -515,65 +513,72 @@ mod tests {
|
||||||
// 3 4
|
// 3 4
|
||||||
// \
|
// \
|
||||||
// 5
|
// 5
|
||||||
let comment_form_0 = CommentInsertForm::builder()
|
let comment_form_0 = CommentInsertForm {
|
||||||
.content("Comment 0".into())
|
language_id: english_id,
|
||||||
.creator_id(inserted_timmy_person.id)
|
..CommentInsertForm::new(
|
||||||
.post_id(inserted_post.id)
|
inserted_timmy_person.id,
|
||||||
.language_id(english_id)
|
inserted_post.id,
|
||||||
.build();
|
"Comment 0".into(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
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 comment_form_1 = CommentInsertForm {
|
||||||
.content("Comment 1, A test blocked comment".into())
|
language_id: english_id,
|
||||||
.creator_id(inserted_sara_person.id)
|
..CommentInsertForm::new(
|
||||||
.post_id(inserted_post.id)
|
inserted_sara_person.id,
|
||||||
.language_id(english_id)
|
inserted_post.id,
|
||||||
.build();
|
"Comment 1, A test blocked comment".into(),
|
||||||
|
)
|
||||||
|
};
|
||||||
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 comment_form_2 = CommentInsertForm {
|
||||||
.content("Comment 2".into())
|
language_id: finnish_id,
|
||||||
.creator_id(inserted_timmy_person.id)
|
..CommentInsertForm::new(
|
||||||
.post_id(inserted_post.id)
|
inserted_timmy_person.id,
|
||||||
.language_id(finnish_id)
|
inserted_post.id,
|
||||||
.build();
|
"Comment 2".into(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
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 comment_form_3 = CommentInsertForm {
|
||||||
.content("Comment 3".into())
|
language_id: english_id,
|
||||||
.creator_id(inserted_timmy_person.id)
|
..CommentInsertForm::new(
|
||||||
.post_id(inserted_post.id)
|
inserted_timmy_person.id,
|
||||||
.language_id(english_id)
|
inserted_post.id,
|
||||||
.build();
|
"Comment 3".into(),
|
||||||
|
)
|
||||||
|
};
|
||||||
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?
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let comment_form_4 = CommentInsertForm::builder()
|
let comment_form_4 = CommentInsertForm {
|
||||||
.content("Comment 4".into())
|
language_id: Some(polish_id),
|
||||||
.creator_id(inserted_timmy_person.id)
|
..CommentInsertForm::new(
|
||||||
.post_id(inserted_post.id)
|
inserted_timmy_person.id,
|
||||||
.language_id(Some(polish_id))
|
inserted_post.id,
|
||||||
.build();
|
"Comment 4".into(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -830,13 +830,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
|
||||||
|
@ -851,13 +850,14 @@ mod tests {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let post_from_blocked_person = PostInsertForm::builder()
|
let post_from_blocked_person = PostInsertForm {
|
||||||
.name(POST_BY_BLOCKED_PERSON.to_string())
|
language_id: Some(LanguageId(1)),
|
||||||
.creator_id(inserted_blocked_person.id)
|
..PostInsertForm::new(
|
||||||
.community_id(inserted_community.id)
|
POST_BY_BLOCKED_PERSON.to_string(),
|
||||||
.language_id(Some(LanguageId(1)))
|
inserted_blocked_person.id,
|
||||||
.build();
|
inserted_community.id,
|
||||||
|
)
|
||||||
|
};
|
||||||
Post::create(pool, &post_from_blocked_person).await?;
|
Post::create(pool, &post_from_blocked_person).await?;
|
||||||
|
|
||||||
// block that person
|
// block that person
|
||||||
|
@ -869,22 +869,19 @@ 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 new_post = PostInsertForm {
|
||||||
.name(POST.to_string())
|
language_id: Some(LanguageId(47)),
|
||||||
.creator_id(inserted_person.id)
|
..PostInsertForm::new(POST.to_string(), inserted_person.id, inserted_community.id)
|
||||||
.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(),
|
||||||
|
@ -1034,13 +1031,15 @@ mod tests {
|
||||||
let data = init_data(pool).await?;
|
let data = init_data(pool).await?;
|
||||||
|
|
||||||
// A post which contains the search them 'Post' not in the title (but in the body)
|
// A post which contains the search them 'Post' not in the title (but in the body)
|
||||||
let new_post = PostInsertForm::builder()
|
let new_post = PostInsertForm {
|
||||||
.name(POST_WITH_ANOTHER_TITLE.to_string())
|
language_id: Some(LanguageId(47)),
|
||||||
.creator_id(data.local_user_view.person.id)
|
body: Some("Post".to_string()),
|
||||||
.community_id(data.inserted_community.id)
|
..PostInsertForm::new(
|
||||||
.language_id(Some(LanguageId(47)))
|
POST_WITH_ANOTHER_TITLE.to_string(),
|
||||||
.body(Some("Post".to_string()))
|
data.local_user_view.person.id,
|
||||||
.build();
|
data.inserted_community.id,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let inserted_post = Post::create(pool, &new_post).await?;
|
let inserted_post = Post::create(pool, &new_post).await?;
|
||||||
|
|
||||||
|
@ -1269,13 +1268,14 @@ mod tests {
|
||||||
.await?
|
.await?
|
||||||
.expect("french should exist");
|
.expect("french should exist");
|
||||||
|
|
||||||
let post_spanish = PostInsertForm::builder()
|
let post_spanish = PostInsertForm {
|
||||||
.name(EL_POSTO.to_string())
|
language_id: Some(spanish_id),
|
||||||
.creator_id(data.local_user_view.person.id)
|
..PostInsertForm::new(
|
||||||
.community_id(data.inserted_community.id)
|
EL_POSTO.to_string(),
|
||||||
.language_id(Some(spanish_id))
|
data.local_user_view.person.id,
|
||||||
.build();
|
data.inserted_community.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?;
|
||||||
|
@ -1403,21 +1403,22 @@ 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 post_form = PostInsertForm {
|
||||||
.name(POST_FROM_BLOCKED_INSTANCE.to_string())
|
language_id: Some(LanguageId(1)),
|
||||||
.creator_id(data.inserted_bot.id)
|
..PostInsertForm::new(
|
||||||
.community_id(inserted_community.id)
|
POST_FROM_BLOCKED_INSTANCE.to_string(),
|
||||||
.language_id(Some(LanguageId(1)))
|
data.inserted_bot.id,
|
||||||
.build();
|
inserted_community.id,
|
||||||
|
)
|
||||||
|
};
|
||||||
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
|
||||||
|
@ -1460,12 +1461,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![];
|
||||||
|
@ -1475,23 +1476,25 @@ 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 post_form = PostInsertForm {
|
||||||
.name("keep Christ in Christmas".to_owned())
|
featured_local: Some((comments % 2) == 0),
|
||||||
.creator_id(data.local_user_view.person.id)
|
featured_community: Some((comments % 2) == 0),
|
||||||
.community_id(inserted_community.id)
|
published: Some(Utc::now() - Duration::from_secs(comments % 3)),
|
||||||
.featured_local(Some((comments % 2) == 0))
|
..PostInsertForm::new(
|
||||||
.featured_community(Some((comments % 2) == 0))
|
"keep Christ in Christmas".to_owned(),
|
||||||
.published(Some(Utc::now() - Duration::from_secs(comments % 3)))
|
data.local_user_view.person.id,
|
||||||
.build();
|
inserted_community.id,
|
||||||
|
)
|
||||||
|
};
|
||||||
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,10 @@ 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 form = InstanceForm {
|
||||||
.domain(instance.domain.clone())
|
updated: DateTime::from_timestamp(0, 0),
|
||||||
.updated(DateTime::from_timestamp(0, 0))
|
..InstanceForm::new(instance.domain.clone())
|
||||||
.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,10 @@ 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 form = InstanceForm {
|
||||||
.domain(self.instance.domain.clone())
|
updated: Some(naive_now()),
|
||||||
.updated(Some(naive_now()))
|
..InstanceForm::new(self.instance.domain.clone())
|
||||||
.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 +658,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,43 @@ 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(
|
|
||||||
settings
|
|
||||||
.setup
|
.setup
|
||||||
.clone()
|
.clone()
|
||||||
.map(|s| s.site_name)
|
.map(|s| s.site_name)
|
||||||
.unwrap_or_else(|| "New Site".to_string()),
|
.unwrap_or_else(|| "New Site".to_string());
|
||||||
)
|
let site_form = SiteInsertForm {
|
||||||
.instance_id(instance.id)
|
actor_id: Some(site_actor_id.clone().into()),
|
||||||
.actor_id(Some(site_actor_id.clone().into()))
|
last_refreshed_at: Some(naive_now()),
|
||||||
.last_refreshed_at(Some(naive_now()))
|
inbox_url: Some(generate_shared_inbox_url(settings)?),
|
||||||
.inbox_url(Some(generate_shared_inbox_url(settings)?))
|
private_key: Some(site_key_pair.private_key),
|
||||||
.private_key(Some(site_key_pair.private_key))
|
public_key: Some(site_key_pair.public_key),
|
||||||
.public_key(Some(site_key_pair.public_key))
|
|
||||||
.build();
|
..SiteInsertForm::new(name, instance.id)
|
||||||
|
};
|
||||||
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 local_site_form = LocalSiteInsertForm {
|
||||||
.site_id(site.id)
|
site_setup: Some(settings.setup.is_some()),
|
||||||
.site_setup(Some(settings.setup.is_some()))
|
..LocalSiteInsertForm::new(site.id)
|
||||||
.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 local_site_rate_limit_form = LocalSiteRateLimitInsertForm {
|
||||||
|
message: Some(999),
|
||||||
|
post: Some(999),
|
||||||
|
register: Some(999),
|
||||||
|
image: Some(999),
|
||||||
|
comment: Some(999),
|
||||||
|
search: Some(999),
|
||||||
|
..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))
|
|
||||||
.post(Some(999))
|
|
||||||
.register(Some(999))
|
|
||||||
.image(Some(999))
|
|
||||||
.comment(Some(999))
|
|
||||||
.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,10 @@ 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 {
|
||||||
.domain(domain.to_string())
|
updated: Some(naive_now()),
|
||||||
.updated(Some(naive_now()))
|
..InstanceForm::new(domain.to_string())
|
||||||
.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 a new issue