clippy fixes

This commit is contained in:
Felix Ableitner 2022-08-23 23:57:44 +02:00 committed by Dessalines
parent d058e2217a
commit 5e8a37ac86
3 changed files with 26 additions and 26 deletions

View File

@ -81,7 +81,7 @@ impl PerformCrud for EditComment {
let content_slurs_removed = data let content_slurs_removed = data
.content .content
.as_ref() .as_ref()
.map(|c| remove_slurs(&c, &context.settings().slur_regex())); .map(|c| remove_slurs(c, &context.settings().slur_regex()));
let comment_id = data.comment_id; let comment_id = data.comment_id;
let form = CommentForm { let form = CommentForm {
creator_id: orig_comment.comment.creator_id, creator_id: orig_comment.comment.creator_id,

View File

@ -19,7 +19,7 @@ pub enum PostOrComment {
#[serde(untagged)] #[serde(untagged)]
pub enum PageOrNote { pub enum PageOrNote {
Page(Box<Page>), Page(Box<Page>),
Note(Note), Note(Box<Note>),
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
@ -84,7 +84,7 @@ impl ApubObject for PostOrComment {
ApubPost::from_apub(*p, context, request_counter).await?, ApubPost::from_apub(*p, context, request_counter).await?,
)), )),
PageOrNote::Note(n) => PostOrComment::Comment(Box::new( PageOrNote::Note(n) => PostOrComment::Comment(Box::new(
ApubComment::from_apub(n, context, request_counter).await?, ApubComment::from_apub(*n, context, request_counter).await?,
)), )),
}) })
} }

View File

@ -421,20 +421,20 @@ mod tests {
public_key: Some("pubkey".to_string()), public_key: Some("pubkey".to_string()),
..PersonForm::default() ..PersonForm::default()
}; };
let inserted_person = Person::create(&conn, &new_person).unwrap(); let inserted_person = Person::create(conn, &new_person).unwrap();
let local_user_form = LocalUserForm { let local_user_form = LocalUserForm {
person_id: Some(inserted_person.id), person_id: Some(inserted_person.id),
password_encrypted: Some("".to_string()), password_encrypted: Some("".to_string()),
..Default::default() ..Default::default()
}; };
let inserted_local_user = LocalUser::create(&conn, &local_user_form).unwrap(); let inserted_local_user = LocalUser::create(conn, &local_user_form).unwrap();
let new_person_2 = PersonForm { let new_person_2 = PersonForm {
name: "sara".into(), name: "sara".into(),
public_key: Some("pubkey".to_string()), public_key: Some("pubkey".to_string()),
..PersonForm::default() ..PersonForm::default()
}; };
let inserted_person_2 = Person::create(&conn, &new_person_2).unwrap(); let inserted_person_2 = Person::create(conn, &new_person_2).unwrap();
let new_community = CommunityForm { let new_community = CommunityForm {
name: "test community 5".to_string(), name: "test community 5".to_string(),
@ -443,7 +443,7 @@ mod tests {
..CommunityForm::default() ..CommunityForm::default()
}; };
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: "A test post 2".into(), name: "A test post 2".into(),
@ -452,7 +452,7 @@ mod tests {
..PostForm::default() ..PostForm::default()
}; };
let inserted_post = Post::create(&conn, &new_post).unwrap(); let inserted_post = Post::create(conn, &new_post).unwrap();
// Create a comment tree with this hierarchy // Create a comment tree with this hierarchy
// 0 // 0
@ -469,7 +469,7 @@ mod tests {
..CommentForm::default() ..CommentForm::default()
}; };
let inserted_comment_0 = Comment::create(&conn, &comment_form_0, None).unwrap(); let inserted_comment_0 = Comment::create(conn, &comment_form_0, None).unwrap();
let comment_form_1 = CommentForm { let comment_form_1 = CommentForm {
content: "Comment 1, A test blocked comment".into(), content: "Comment 1, A test blocked comment".into(),
@ -479,9 +479,9 @@ mod tests {
}; };
let inserted_comment_1 = let inserted_comment_1 =
Comment::create(&conn, &comment_form_1, Some(&inserted_comment_0.path)).unwrap(); Comment::create(conn, &comment_form_1, Some(&inserted_comment_0.path)).unwrap();
let finnish_id = Language::read_id_from_code(&conn, "fi").unwrap(); let finnish_id = Language::read_id_from_code(conn, "fi").unwrap();
let comment_form_2 = CommentForm { let comment_form_2 = CommentForm {
content: "Comment 2".into(), content: "Comment 2".into(),
creator_id: inserted_person.id, creator_id: inserted_person.id,
@ -491,7 +491,7 @@ mod tests {
}; };
let inserted_comment_2 = let inserted_comment_2 =
Comment::create(&conn, &comment_form_2, Some(&inserted_comment_0.path)).unwrap(); Comment::create(conn, &comment_form_2, Some(&inserted_comment_0.path)).unwrap();
let comment_form_3 = CommentForm { let comment_form_3 = CommentForm {
content: "Comment 3".into(), content: "Comment 3".into(),
@ -501,9 +501,9 @@ mod tests {
}; };
let _inserted_comment_3 = let _inserted_comment_3 =
Comment::create(&conn, &comment_form_3, Some(&inserted_comment_1.path)).unwrap(); Comment::create(conn, &comment_form_3, Some(&inserted_comment_1.path)).unwrap();
let polish_id = Language::read_id_from_code(&conn, "pl").unwrap(); let polish_id = Language::read_id_from_code(conn, "pl").unwrap();
let comment_form_4 = CommentForm { let comment_form_4 = CommentForm {
content: "Comment 4".into(), content: "Comment 4".into(),
creator_id: inserted_person.id, creator_id: inserted_person.id,
@ -513,7 +513,7 @@ mod tests {
}; };
let inserted_comment_4 = let inserted_comment_4 =
Comment::create(&conn, &comment_form_4, Some(&inserted_comment_1.path)).unwrap(); Comment::create(conn, &comment_form_4, Some(&inserted_comment_1.path)).unwrap();
let comment_form_5 = CommentForm { let comment_form_5 = CommentForm {
content: "Comment 5".into(), content: "Comment 5".into(),
@ -523,14 +523,14 @@ mod tests {
}; };
let _inserted_comment_5 = let _inserted_comment_5 =
Comment::create(&conn, &comment_form_5, Some(&inserted_comment_4.path)).unwrap(); Comment::create(conn, &comment_form_5, Some(&inserted_comment_4.path)).unwrap();
let timmy_blocks_sara_form = PersonBlockForm { let timmy_blocks_sara_form = PersonBlockForm {
person_id: inserted_person.id, person_id: inserted_person.id,
target_id: inserted_person_2.id, target_id: inserted_person_2.id,
}; };
let inserted_block = PersonBlock::block(&conn, &timmy_blocks_sara_form).unwrap(); let inserted_block = PersonBlock::block(conn, &timmy_blocks_sara_form).unwrap();
let expected_block = PersonBlock { let expected_block = PersonBlock {
id: inserted_block.id, id: inserted_block.id,
@ -547,7 +547,7 @@ mod tests {
score: 1, score: 1,
}; };
let _inserted_comment_like = CommentLike::like(&conn, &comment_like_form).unwrap(); let _inserted_comment_like = CommentLike::like(conn, &comment_like_form).unwrap();
Data { Data {
inserted_comment_0, inserted_comment_0,
@ -742,17 +742,17 @@ mod tests {
} }
fn cleanup(data: Data, conn: &PgConnection) { fn cleanup(data: Data, conn: &PgConnection) {
CommentLike::remove(&conn, data.inserted_person.id, data.inserted_comment_0.id).unwrap(); CommentLike::remove(conn, data.inserted_person.id, data.inserted_comment_0.id).unwrap();
Comment::delete(&conn, data.inserted_comment_0.id).unwrap(); Comment::delete(conn, data.inserted_comment_0.id).unwrap();
Comment::delete(&conn, data.inserted_comment_1.id).unwrap(); Comment::delete(conn, data.inserted_comment_1.id).unwrap();
Post::delete(&conn, data.inserted_post.id).unwrap(); Post::delete(conn, data.inserted_post.id).unwrap();
Community::delete(&conn, data.inserted_community.id).unwrap(); Community::delete(conn, data.inserted_community.id).unwrap();
Person::delete(&conn, data.inserted_person.id).unwrap(); Person::delete(conn, data.inserted_person.id).unwrap();
Person::delete(&conn, data.inserted_person_2.id).unwrap(); Person::delete(conn, data.inserted_person_2.id).unwrap();
} }
fn expected_comment_view(data: &Data, conn: &PgConnection) -> CommentView { fn expected_comment_view(data: &Data, conn: &PgConnection) -> CommentView {
let agg = CommentAggregates::read(&conn, data.inserted_comment_0.id).unwrap(); let agg = CommentAggregates::read(conn, data.inserted_comment_0.id).unwrap();
CommentView { CommentView {
creator_banned_from_community: false, creator_banned_from_community: false,
my_vote: None, my_vote: None,