Remove PersonInsertForm builder (#4779)

* Update session_middleware.rs

* Update private_message_report_view.rs

* Update session_middleware.rs

* Update private_message_view.rs

* Update private_message.rs

* Update registration_application_view.rs

* Update actor_language.rs

* Update vote_view.rs

* Update code_migrations.rs

* Update comment_aggregates.rs

* Update person_view.rs

* Update user_settings_backup.rs

* Update person.rs

* Update create.rs

* Update comment_view.rs

* Update moderator.rs

* Update site_aggregates.rs

* Update claims.rs

* Update community_aggregates.rs

* Update post_report.rs

* Update person_mention_view.rs

* Update community_view.rs

* Update comment_report_view.rs

* Update post_report_view.rs

* Update community_moderators.rs

* Update comment.rs

* Update person_aggregates.rs

* Update comment_reply_view.rs

* Update password_reset_request.rs

* Update post_aggregates.rs

* Update community.rs

* Update main.rs

* Update post.rs

* Update person.rs

* Update person.rs

* Update claims.rs

* Update person.rs

* Update create.rs

* Update user_settings_backup.rs

* Update community_moderators.rs

* Update main.rs

* Update comment_aggregates.rs

* Update community_aggregates.rs

* Update person.rs

* Update Cargo.toml

* Update Cargo.toml

* Update person.rs

* fix

* Update code_migrations.rs

* fix submodule

* Update person.rs
This commit is contained in:
dullbananas 2024-06-06 05:29:18 -07:00 committed by GitHub
parent fda5ce4482
commit 79e6dbf0de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 125 additions and 311 deletions

12
Cargo.lock generated
View file

@ -1423,6 +1423,17 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "derive-new"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d150dea618e920167e5973d70ae6ece4385b7164e0d799fe7c122dd0a5d912ad"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
]
[[package]]
name = "derive_builder"
version = "0.20.0"
@ -2850,6 +2861,7 @@ dependencies = [
"bcrypt",
"chrono",
"deadpool 0.12.1",
"derive-new",
"diesel",
"diesel-async",
"diesel-derive-enum",

View file

@ -167,6 +167,7 @@ moka = { version = "0.12.7", features = ["future"] }
i-love-jesus = { version = "0.1.0" }
clap = { version = "4.5.4", features = ["derive", "env"] }
pretty_assertions = "1.4.0"
derive-new = "0.6.0"
[dependencies]
lemmy_api = { workspace = true }

View file

@ -112,11 +112,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("Gerry9812".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "Gerry9812");
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -112,15 +112,17 @@ pub async fn register(
// We have to create both a person, and local_user
// Register the new person
let person_form = PersonInsertForm::builder()
.name(data.username.clone())
.actor_id(Some(actor_id.clone()))
.private_key(Some(actor_keypair.private_key))
.public_key(actor_keypair.public_key)
.inbox_url(Some(generate_inbox_url(&actor_id)?))
.shared_inbox_url(Some(generate_shared_inbox_url(context.settings())?))
.instance_id(site_view.site.instance_id)
.build();
let person_form = PersonInsertForm {
actor_id: Some(actor_id.clone()),
inbox_url: Some(generate_inbox_url(&actor_id)?),
shared_inbox_url: Some(generate_shared_inbox_url(context.settings())?),
private_key: Some(actor_keypair.private_key),
..PersonInsertForm::new(
data.username.clone(),
actor_keypair.public_key,
site_view.site.instance_id,
)
};
// insert the person
let inserted_person = Person::create(&mut context.pool(), &person_form)

View file

@ -338,13 +338,11 @@ mod tests {
context: &Data<LemmyContext>,
) -> LemmyResult<LocalUserView> {
let instance = Instance::read_or_create(&mut context.pool(), "example.com".to_string()).await?;
let person_form = PersonInsertForm::builder()
.name(name.clone())
.display_name(Some(name.clone()))
.bio(bio)
.public_key("asd".to_string())
.instance_id(instance.id)
.build();
let person_form = PersonInsertForm {
display_name: Some(name.clone()),
bio,
..PersonInsertForm::test_form(instance.id, &name)
};
let person = Person::create(&mut context.pool(), &person_form).await?;
let user_form = LocalUserInsertForm::builder()

View file

@ -129,11 +129,7 @@ mod tests {
let inserted_instance =
Instance::read_or_create(&mut context.pool(), "my_domain.tld".to_string()).await?;
let old_mod = PersonInsertForm::builder()
.name("holly".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let old_mod = PersonInsertForm::test_form(inserted_instance.id, "holly");
let old_mod = Person::create(&mut context.pool(), &old_mod).await?;
let community_moderator_form = CommunityModeratorForm {

View file

@ -72,11 +72,7 @@ async fn try_main() -> LemmyResult<()> {
println!("🫃 creating {} people", args.people);
let mut person_ids = vec![];
for i in 0..args.people.get() {
let form = PersonInsertForm::builder()
.name(format!("p{i}"))
.public_key("pubkey".to_owned())
.instance_id(instance.id)
.build();
let form = PersonInsertForm::test_form(instance.id, &format!("p{i}"));
person_ids.push(Person::create(&mut conn.into(), &form).await?.id);
}

View file

@ -81,6 +81,7 @@ uuid = { workspace = true, features = ["v4"] }
i-love-jesus = { workspace = true, optional = true }
anyhow = { workspace = true }
moka.workspace = true
derive-new.workspace = true
[dev-dependencies]
serial_test = { workspace = true }

View file

@ -64,19 +64,11 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("thommy_comment_agg".into())
.public_key("pubkey".into())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_comment_agg");
let inserted_person = Person::create(pool, &new_person).await.unwrap();
let another_person = PersonInsertForm::builder()
.name("jerry_comment_agg".into())
.public_key("pubkey".into())
.instance_id(inserted_instance.id)
.build();
let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_comment_agg");
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();

View file

@ -65,19 +65,11 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("thommy_community_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_community_agg");
let inserted_person = Person::create(pool, &new_person).await.unwrap();
let another_person = PersonInsertForm::builder()
.name("jerry_community_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_community_agg");
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();

View file

@ -49,19 +49,11 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("thommy_user_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_user_agg");
let inserted_person = Person::create(pool, &new_person).await.unwrap();
let another_person = PersonInsertForm::builder()
.name("jerry_user_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_user_agg");
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();

View file

@ -83,19 +83,11 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("thommy_community_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_community_agg");
let inserted_person = Person::create(pool, &new_person).await.unwrap();
let another_person = PersonInsertForm::builder()
.name("jerry_community_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_community_agg");
let another_inserted_person = Person::create(pool, &another_person).await.unwrap();
@ -229,11 +221,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("thommy_community_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_community_agg");
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -42,11 +42,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("thommy_site_agg".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_site_agg");
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -531,11 +531,7 @@ mod tests {
let (site, instance) = create_test_site(pool).await;
let person_form = PersonInsertForm::builder()
.name("my test person".to_string())
.public_key("pubkey".to_string())
.instance_id(instance.id)
.build();
let person_form = PersonInsertForm::test_form(instance.id, "my test person");
let person = Person::create(pool, &person_form).await.unwrap();
let local_user_form = LocalUserInsertForm::builder()
.person_id(person.id)
@ -647,11 +643,7 @@ mod tests {
.await
.unwrap();
let person_form = PersonInsertForm::builder()
.name("my test person".to_string())
.public_key("pubkey".to_string())
.instance_id(instance.id)
.build();
let person_form = PersonInsertForm::test_form(instance.id, "my test person");
let person = Person::create(pool, &person_form).await.unwrap();
let local_user_form = LocalUserInsertForm::builder()
.person_id(person.id)

View file

@ -233,11 +233,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("terry".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "terry");
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -434,11 +434,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("bobbee".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "bobbee");
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -513,19 +513,11 @@ mod tests {
.await
.unwrap();
let new_mod = PersonInsertForm::builder()
.name("the mod".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_mod = PersonInsertForm::test_form(inserted_instance.id, "the mod");
let inserted_mod = Person::create(pool, &new_mod).await.unwrap();
let new_person = PersonInsertForm::builder()
.name("jim2".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "jim2");
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -70,11 +70,7 @@ mod tests {
// Setup
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
let new_person = PersonInsertForm::builder()
.name("thommy prw".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy prw");
let inserted_person = Person::create(pool, &new_person).await?;
let new_local_user = LocalUserInsertForm::builder()
.person_id(inserted_person.id)

View file

@ -125,11 +125,7 @@ impl Person {
impl PersonInsertForm {
pub fn test_form(instance_id: InstanceId, name: &str) -> Self {
Self::builder()
.name(name.to_owned())
.public_key("pubkey".to_string())
.instance_id(instance_id)
.build()
Self::new(name.to_owned(), "pubkey".to_string(), instance_id)
}
}
@ -249,11 +245,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("holly".into())
.public_key("nada".to_owned())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "holly");
let inserted_person = Person::create(pool, &new_person).await.unwrap();
@ -272,7 +264,7 @@ mod tests {
local: true,
bot_account: false,
private_key: None,
public_key: "nada".to_owned(),
public_key: "pubkey".to_owned(),
last_refreshed_at: inserted_person.published,
inbox_url: inserted_person.inbox_url.clone(),
shared_inbox_url: None,
@ -312,17 +304,9 @@ mod tests {
.await
.unwrap();
let person_form_1 = PersonInsertForm::builder()
.name("erich".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let person_form_1 = PersonInsertForm::test_form(inserted_instance.id, "erich");
let person_1 = Person::create(pool, &person_form_1).await.unwrap();
let person_form_2 = PersonInsertForm::builder()
.name("michele".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let person_form_2 = PersonInsertForm::test_form(inserted_instance.id, "michele");
let person_2 = Person::create(pool, &person_form_2).await.unwrap();
let follow_form = PersonFollowerForm {

View file

@ -401,11 +401,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("jim".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "jim");
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -101,11 +101,7 @@ mod tests {
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
.await
.unwrap();
let person_form = PersonInsertForm::builder()
.name("jim".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let person_form = PersonInsertForm::test_form(inserted_instance.id, "jim");
let person = Person::create(pool, &person_form).await.unwrap();
let community_form = CommunityInsertForm::builder()

View file

@ -111,19 +111,11 @@ mod tests {
.await
.unwrap();
let creator_form = PersonInsertForm::builder()
.name("creator_pm".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let creator_form = PersonInsertForm::test_form(inserted_instance.id, "creator_pm");
let inserted_creator = Person::create(pool, &creator_form).await.unwrap();
let recipient_form = PersonInsertForm::builder()
.name("recipient_pm".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let recipient_form = PersonInsertForm::test_form(inserted_instance.id, "recipient_pm");
let inserted_recipient = Person::create(pool, &recipient_form).await.unwrap();

View file

@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
#[cfg(feature = "full")]
use ts_rs::TS;
use typed_builder::TypedBuilder;
#[skip_serializing_none]
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
@ -60,33 +59,46 @@ pub struct Person {
pub instance_id: InstanceId,
}
#[derive(Clone, TypedBuilder)]
#[builder(field_defaults(default))]
#[derive(Clone, derive_new::new)]
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = person))]
pub struct PersonInsertForm {
#[builder(!default)]
pub name: String,
#[builder(!default)]
pub public_key: String,
#[builder(!default)]
pub instance_id: InstanceId,
#[new(default)]
pub display_name: Option<String>,
#[new(default)]
pub avatar: Option<DbUrl>,
#[new(default)]
pub banned: Option<bool>,
#[new(default)]
pub published: Option<DateTime<Utc>>,
#[new(default)]
pub updated: Option<DateTime<Utc>>,
#[new(default)]
pub actor_id: Option<DbUrl>,
#[new(default)]
pub bio: Option<String>,
#[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 banner: Option<DbUrl>,
#[new(default)]
pub deleted: Option<bool>,
#[new(default)]
pub inbox_url: Option<DbUrl>,
#[new(default)]
pub shared_inbox_url: Option<DbUrl>,
#[new(default)]
pub matrix_user_id: Option<String>,
#[new(default)]
pub bot_account: Option<bool>,
#[new(default)]
pub ban_expires: Option<DateTime<Utc>>,
}

View file

@ -297,11 +297,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("timmy_crv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "timmy_crv");
let inserted_timmy = Person::create(pool, &new_person).await.unwrap();
@ -319,20 +315,12 @@ mod tests {
counts: Default::default(),
};
let new_person_2 = PersonInsertForm::builder()
.name("sara_crv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "sara_crv");
let inserted_sara = Person::create(pool, &new_person_2).await.unwrap();
// Add a third person, since new ppl can only report something once.
let new_person_3 = PersonInsertForm::builder()
.name("jessica_crv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_3 = PersonInsertForm::test_form(inserted_instance.id, "jessica_crv");
let inserted_jessica = Person::create(pool, &new_person_3).await.unwrap();

View file

@ -488,11 +488,7 @@ mod tests {
async fn init_data(pool: &mut DbPool<'_>) -> LemmyResult<Data> {
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
let timmy_person_form = PersonInsertForm::builder()
.name("timmy".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let timmy_person_form = PersonInsertForm::test_form(inserted_instance.id, "timmy");
let inserted_timmy_person = Person::create(pool, &timmy_person_form).await?;
let timmy_local_user_form = LocalUserInsertForm::builder()
.person_id(inserted_timmy_person.id)
@ -501,11 +497,7 @@ mod tests {
.build();
let inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form, vec![]).await?;
let sara_person_form = PersonInsertForm::builder()
.name("sara".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let sara_person_form = PersonInsertForm::test_form(inserted_instance.id, "sara");
let inserted_sara_person = Person::create(pool, &sara_person_form).await?;
let new_community = CommunityInsertForm::builder()

View file

@ -319,11 +319,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("timmy_prv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "timmy_prv");
let inserted_timmy = Person::create(pool, &new_person).await.unwrap();
@ -341,20 +337,12 @@ mod tests {
counts: Default::default(),
};
let new_person_2 = PersonInsertForm::builder()
.name("sara_prv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "sara_prv");
let inserted_sara = Person::create(pool, &new_person_2).await.unwrap();
// Add a third person, since new ppl can only report something once.
let new_person_3 = PersonInsertForm::builder()
.name("jessica_prv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_3 = PersonInsertForm::test_form(inserted_instance.id, "jessica_prv");
let inserted_jessica = Person::create(pool, &new_person_3).await.unwrap();

View file

@ -140,18 +140,10 @@ mod tests {
.await
.unwrap();
let new_person_1 = PersonInsertForm::builder()
.name("timmy_mrv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_1 = PersonInsertForm::test_form(inserted_instance.id, "timmy_mrv");
let inserted_timmy = Person::create(pool, &new_person_1).await.unwrap();
let new_person_2 = PersonInsertForm::builder()
.name("jessica_mrv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "jessica_mrv");
let inserted_jessica = Person::create(pool, &new_person_2).await.unwrap();
// timmy sends private message to jessica
@ -184,11 +176,7 @@ mod tests {
assert_eq!(pm_report.reason, reports[0].private_message_report.reason);
assert_eq!(pm.content, reports[0].private_message.content);
let new_person_3 = PersonInsertForm::builder()
.name("admin_mrv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_3 = PersonInsertForm::test_form(inserted_instance.id, "admin_mrv");
let inserted_admin = Person::create(pool, &new_person_3).await.unwrap();
// admin resolves the report (after taking appropriate action)

View file

@ -209,27 +209,15 @@ mod tests {
.await
.unwrap();
let timmy_form = PersonInsertForm::builder()
.name("timmy_rav".into())
.public_key("pubkey".to_string())
.instance_id(instance.id)
.build();
let timmy_form = PersonInsertForm::test_form(instance.id, "timmy_rav");
let timmy = Person::create(pool, &timmy_form).await.unwrap();
let sara_form = PersonInsertForm::builder()
.name("sara_rav".into())
.public_key("pubkey".to_string())
.instance_id(instance.id)
.build();
let sara_form = PersonInsertForm::test_form(instance.id, "sara_rav");
let sara = Person::create(pool, &sara_form).await.unwrap();
let jess_form = PersonInsertForm::builder()
.name("jess_rav".into())
.public_key("pubkey".to_string())
.instance_id(instance.id)
.build();
let jess_form = PersonInsertForm::test_form(instance.id, "jess_rav");
let jess = Person::create(pool, &jess_form).await.unwrap();

View file

@ -163,11 +163,7 @@ mod tests {
.await
.unwrap();
let timmy_person_form = PersonInsertForm::builder()
.name("timmy_rav".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let timmy_person_form = PersonInsertForm::test_form(inserted_instance.id, "timmy_rav");
let inserted_timmy_person = Person::create(pool, &timmy_person_form).await.unwrap();
@ -181,11 +177,7 @@ mod tests {
.await
.unwrap();
let sara_person_form = PersonInsertForm::builder()
.name("sara_rav".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let sara_person_form = PersonInsertForm::test_form(inserted_instance.id, "sara_rav");
let inserted_sara_person = Person::create(pool, &sara_person_form).await.unwrap();
@ -213,11 +205,7 @@ mod tests {
.unwrap()
.unwrap();
let jess_person_form = PersonInsertForm::builder()
.name("jess_rav".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let jess_person_form = PersonInsertForm::test_form(inserted_instance.id, "jess_rav");
let inserted_jess_person = Person::create(pool, &jess_person_form).await.unwrap();

View file

@ -112,19 +112,11 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("timmy_vv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "timmy_vv");
let inserted_timmy = Person::create(pool, &new_person).await.unwrap();
let new_person_2 = PersonInsertForm::builder()
.name("sara_vv".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "sara_vv");
let inserted_sara = Person::create(pool, &new_person_2).await.unwrap();

View file

@ -334,19 +334,13 @@ mod tests {
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
let terry_form = PersonInsertForm::builder()
.name("terrylake".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let terry_form = PersonInsertForm::test_form(inserted_instance.id, "terrylake");
let inserted_terry = Person::create(pool, &terry_form).await?;
let recipient_form = PersonInsertForm::builder()
.name("terrylakes recipient".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.local(Some(true))
.build();
let recipient_form = PersonInsertForm {
local: Some(true),
..PersonInsertForm::test_form(inserted_instance.id, "terrylakes recipient")
};
let inserted_recipient = Person::create(pool, &recipient_form).await?;
let recipient_id = inserted_recipient.id;

View file

@ -286,11 +286,7 @@ mod tests {
let person_name = "tegan".to_string();
let new_person = PersonInsertForm::builder()
.name(person_name.clone())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, &person_name);
let inserted_person = Person::create(pool, &new_person).await.unwrap();

View file

@ -334,19 +334,11 @@ mod tests {
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
let new_person = PersonInsertForm::builder()
.name("terrylake".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "terrylake");
let inserted_person = Person::create(pool, &new_person).await?;
let recipient_form = PersonInsertForm::builder()
.name("terrylakes recipient".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let recipient_form = PersonInsertForm::test_form(inserted_instance.id, "terrylakes recipient");
let inserted_recipient = Person::create(pool, &recipient_form).await?;
let recipient_id = inserted_recipient.id;

View file

@ -191,12 +191,10 @@ mod tests {
async fn init_data(pool: &mut DbPool<'_>) -> LemmyResult<Data> {
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
let alice_form = PersonInsertForm::builder()
.name("alice".to_string())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.local(Some(true))
.build();
let alice_form = PersonInsertForm {
local: Some(true),
..PersonInsertForm::test_form(inserted_instance.id, "alice")
};
let alice = Person::create(pool, &alice_form).await?;
let alice_local_user_form = LocalUserInsertForm::builder()
.person_id(alice.id)
@ -204,13 +202,11 @@ mod tests {
.build();
let alice_local_user = LocalUser::create(pool, &alice_local_user_form, vec![]).await?;
let bob_form = PersonInsertForm::builder()
.name("bob".to_string())
.bot_account(Some(true))
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.local(Some(false))
.build();
let bob_form = PersonInsertForm {
bot_account: Some(true),
local: Some(false),
..PersonInsertForm::test_form(inserted_instance.id, "bob")
};
let bob = Person::create(pool, &bob_form).await?;
let bob_local_user_form = LocalUserInsertForm::builder()
.person_id(bob.id)

View file

@ -455,15 +455,17 @@ async fn initialize_local_site_2022_10_10(
)?;
// Register the user if there's a site setup
let person_form = PersonInsertForm::builder()
.name(setup.admin_username.clone())
.instance_id(instance.id)
.actor_id(Some(person_actor_id.clone()))
.private_key(Some(person_keypair.private_key))
.public_key(person_keypair.public_key)
.inbox_url(Some(generate_inbox_url(&person_actor_id)?))
.shared_inbox_url(Some(generate_shared_inbox_url(settings)?))
.build();
let person_form = PersonInsertForm {
actor_id: Some(person_actor_id.clone()),
inbox_url: Some(generate_inbox_url(&person_actor_id)?),
shared_inbox_url: Some(generate_shared_inbox_url(settings)?),
private_key: Some(person_keypair.private_key),
..PersonInsertForm::new(
setup.admin_username.clone(),
person_keypair.public_key,
instance.id,
)
};
let person_inserted = Person::create(pool, &person_form).await?;
let local_user_form = LocalUserInsertForm::builder()

View file

@ -142,11 +142,7 @@ mod tests {
.await
.unwrap();
let new_person = PersonInsertForm::builder()
.name("Gerry9812".into())
.public_key("pubkey".to_string())
.instance_id(inserted_instance.id)
.build();
let new_person = PersonInsertForm::test_form(inserted_instance.id, "Gerry9812");
let inserted_person = Person::create(pool, &new_person).await.unwrap();