mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-06 15:39:22 +00:00
fix
This commit is contained in:
parent
76c1dc2ad7
commit
638901a2b2
|
@ -71,11 +71,11 @@ impl PerformCrud for CreatePost {
|
||||||
.unwrap_or((None, None, None));
|
.unwrap_or((None, None, None));
|
||||||
|
|
||||||
let post_form = PostForm {
|
let post_form = PostForm {
|
||||||
name: Some(data.name.trim().to_owned()),
|
name: data.name.trim().to_owned(),
|
||||||
url: data_url.map(|u| clean_url_params(u.to_owned()).into()),
|
url: data_url.map(|u| clean_url_params(u.to_owned()).into()),
|
||||||
body: clean_optional_text(&data.body),
|
body: clean_optional_text(&data.body),
|
||||||
community_id: Some(data.community_id),
|
community_id: data.community_id,
|
||||||
creator_id: Some(local_user_view.person.id),
|
creator_id: local_user_view.person.id,
|
||||||
nsfw: data.nsfw,
|
nsfw: data.nsfw,
|
||||||
embed_title,
|
embed_title,
|
||||||
embed_description,
|
embed_description,
|
||||||
|
|
|
@ -75,9 +75,9 @@ impl PerformCrud for EditPost {
|
||||||
.unwrap_or((None, None, None));
|
.unwrap_or((None, None, None));
|
||||||
|
|
||||||
let post_form = PostForm {
|
let post_form = PostForm {
|
||||||
creator_id: Some(orig_post.creator_id.to_owned()),
|
creator_id: orig_post.creator_id.to_owned(),
|
||||||
community_id: Some(orig_post.community_id),
|
community_id: orig_post.community_id,
|
||||||
name: Some(data.name.to_owned().unwrap_or(orig_post.name)),
|
name: data.name.to_owned().unwrap_or(orig_post.name),
|
||||||
url: data_url.map(|u| clean_url_params(u.to_owned()).into()),
|
url: data_url.map(|u| clean_url_params(u.to_owned()).into()),
|
||||||
body: clean_optional_text(&data.body),
|
body: clean_optional_text(&data.body),
|
||||||
nsfw: data.nsfw,
|
nsfw: data.nsfw,
|
||||||
|
|
|
@ -182,11 +182,11 @@ impl ApubObject for ApubPost {
|
||||||
.map(|s| remove_slurs(&s, &context.settings().slur_regex()));
|
.map(|s| remove_slurs(&s, &context.settings().slur_regex()));
|
||||||
|
|
||||||
PostForm {
|
PostForm {
|
||||||
name: Some(page.name.clone()),
|
name: page.name.clone(),
|
||||||
url: url.map(Into::into),
|
url: url.map(Into::into),
|
||||||
body: body_slurs_removed,
|
body: body_slurs_removed,
|
||||||
creator_id: Some(creator.id),
|
creator_id: creator.id,
|
||||||
community_id: Some(community.id),
|
community_id: community.id,
|
||||||
removed: None,
|
removed: None,
|
||||||
locked: page.comments_enabled.map(|e| !e),
|
locked: page.comments_enabled.map(|e| !e),
|
||||||
published: page.published.map(|u| u.naive_local()),
|
published: page.published.map(|u| u.naive_local()),
|
||||||
|
@ -204,6 +204,9 @@ impl ApubObject for ApubPost {
|
||||||
} else {
|
} else {
|
||||||
// if is mod action, only update locked/stickied fields, nothing else
|
// if is mod action, only update locked/stickied fields, nothing else
|
||||||
PostForm {
|
PostForm {
|
||||||
|
name: page.name.clone(),
|
||||||
|
creator_id: creator.id,
|
||||||
|
community_id: community.id,
|
||||||
locked: page.comments_enabled.map(|e| !e),
|
locked: page.comments_enabled.map(|e| !e),
|
||||||
stickied: page.stickied,
|
stickied: page.stickied,
|
||||||
updated: page.updated.map(|u| u.naive_local()),
|
updated: page.updated.map(|u| u.naive_local()),
|
||||||
|
|
|
@ -66,9 +66,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -102,9 +102,9 @@ mod tests {
|
||||||
CommunityFollower::follow(&conn, &another_community_follow).unwrap();
|
CommunityFollower::follow(&conn, &another_community_follow).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -70,9 +70,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -69,9 +69,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -241,9 +241,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -301,9 +301,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post thweep".into()),
|
name: "A test post thweep".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -118,9 +118,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -292,9 +292,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post".into()),
|
name: "A test post".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ pub struct Post {
|
||||||
#[derive(Insertable, AsChangeset, Default)]
|
#[derive(Insertable, AsChangeset, Default)]
|
||||||
#[table_name = "post"]
|
#[table_name = "post"]
|
||||||
pub struct PostForm {
|
pub struct PostForm {
|
||||||
pub creator_id: Option<PersonId>,
|
pub name: String,
|
||||||
pub community_id: Option<CommunityId>,
|
pub creator_id: PersonId,
|
||||||
pub name: Option<String>,
|
pub community_id: CommunityId,
|
||||||
pub nsfw: Option<bool>,
|
pub nsfw: Option<bool>,
|
||||||
pub url: Option<DbUrl>,
|
pub url: Option<DbUrl>,
|
||||||
pub body: Option<String>,
|
pub body: Option<String>,
|
||||||
|
|
|
@ -372,9 +372,9 @@ mod tests {
|
||||||
let _inserted_moderator = CommunityModerator::join(&conn, &timmy_moderator_form).unwrap();
|
let _inserted_moderator = CommunityModerator::join(&conn, &timmy_moderator_form).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post crv".into()),
|
name: "A test post crv".into(),
|
||||||
creator_id: Some(inserted_timmy.id),
|
creator_id: inserted_timmy.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -579,9 +579,9 @@ mod tests {
|
||||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post 2".into()),
|
name: "A test post 2".into(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -360,9 +360,9 @@ mod tests {
|
||||||
let _inserted_moderator = CommunityModerator::join(&conn, &timmy_moderator_form).unwrap();
|
let _inserted_moderator = CommunityModerator::join(&conn, &timmy_moderator_form).unwrap();
|
||||||
|
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some("A test post crv".into()),
|
name: "A test post crv".into(),
|
||||||
creator_id: Some(inserted_timmy.id),
|
creator_id: inserted_timmy.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -571,9 +571,9 @@ mod tests {
|
||||||
let inserted_blocked_person = Person::create(&conn, &blocked_person).unwrap();
|
let inserted_blocked_person = Person::create(&conn, &blocked_person).unwrap();
|
||||||
|
|
||||||
let post_from_blocked_person = PostForm {
|
let post_from_blocked_person = PostForm {
|
||||||
name: Some("blocked_person_post".to_string()),
|
name: "blocked_person_post".to_string(),
|
||||||
creator_id: Some(inserted_blocked_person.id),
|
creator_id: inserted_blocked_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -589,18 +589,18 @@ mod tests {
|
||||||
|
|
||||||
// A sample post
|
// A sample post
|
||||||
let new_post = PostForm {
|
let new_post = PostForm {
|
||||||
name: Some(post_name.to_owned()),
|
name: post_name.to_owned(),
|
||||||
creator_id: Some(inserted_person.id),
|
creator_id: inserted_person.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||||
|
|
||||||
let new_bot_post = PostForm {
|
let new_bot_post = PostForm {
|
||||||
name: Some(bot_post_name),
|
name: bot_post_name,
|
||||||
creator_id: Some(inserted_bot.id),
|
creator_id: inserted_bot.id,
|
||||||
community_id: Some(inserted_community.id),
|
community_id: inserted_community.id,
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue