Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running clippy --fix #1647

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ sha2 = "0.9.3"
async-trait = "0.1.42"
captcha = "0.0.8"
anyhow = "1.0.38"
thiserror = "1.0.23"
thiserror = "1.0.26"
background-jobs = "0.8.0"
reqwest = { version = "0.10.10", features = ["json"] }
10 changes: 5 additions & 5 deletions crates/api/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ impl Perform for MarkCommentAsRead {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<CommentResponse, LemmyError> {
let data: &MarkCommentAsRead = &self;
let data: &MarkCommentAsRead = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let comment_id = data.comment_id;
let orig_comment = blocking(context.pool(), move |conn| {
CommentView::read(&conn, comment_id, None)
CommentView::read(conn, comment_id, None)
})
.await??;

Expand Down Expand Up @@ -79,7 +79,7 @@ impl Perform for SaveComment {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<CommentResponse, LemmyError> {
let data: &SaveComment = &self;
let data: &SaveComment = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let comment_saved_form = CommentSavedForm {
Expand Down Expand Up @@ -123,7 +123,7 @@ impl Perform for CreateCommentLike {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<CommentResponse, LemmyError> {
let data: &CreateCommentLike = &self;
let data: &CreateCommentLike = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let mut recipient_ids = Vec::<LocalUserId>::new();
Expand All @@ -133,7 +133,7 @@ impl Perform for CreateCommentLike {

let comment_id = data.comment_id;
let orig_comment = blocking(context.pool(), move |conn| {
CommentView::read(&conn, comment_id, None)
CommentView::read(conn, comment_id, None)
})
.await??;

Expand Down
10 changes: 5 additions & 5 deletions crates/api/src/comment_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Perform for CreateCommentReport {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<CreateCommentReportResponse, LemmyError> {
let data: &CreateCommentReport = &self;
let data: &CreateCommentReport = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

// check size of report and check for whitespace
Expand All @@ -46,7 +46,7 @@ impl Perform for CreateCommentReport {
let person_id = local_user_view.person.id;
let comment_id = data.comment_id;
let comment_view = blocking(context.pool(), move |conn| {
CommentView::read(&conn, comment_id, None)
CommentView::read(conn, comment_id, None)
})
.await??;

Expand Down Expand Up @@ -95,12 +95,12 @@ impl Perform for ResolveCommentReport {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<ResolveCommentReportResponse, LemmyError> {
let data: &ResolveCommentReport = &self;
let data: &ResolveCommentReport = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let report_id = data.report_id;
let report = blocking(context.pool(), move |conn| {
CommentReportView::read(&conn, report_id)
CommentReportView::read(conn, report_id)
})
.await??;

Expand Down Expand Up @@ -148,7 +148,7 @@ impl Perform for ListCommentReports {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<ListCommentReportsResponse, LemmyError> {
let data: &ListCommentReports = &self;
let data: &ListCommentReports = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let person_id = local_user_view.person.id;
Expand Down
8 changes: 4 additions & 4 deletions crates/api/src/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Perform for FollowCommunity {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<CommunityResponse, LemmyError> {
let data: &FollowCommunity = &self;
let data: &FollowCommunity = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let community_id = data.community_id;
Expand Down Expand Up @@ -116,7 +116,7 @@ impl Perform for BanFromCommunity {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<BanFromCommunityResponse, LemmyError> {
let data: &BanFromCommunity = &self;
let data: &BanFromCommunity = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let community_id = data.community_id;
Expand Down Expand Up @@ -246,7 +246,7 @@ impl Perform for AddModToCommunity {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<AddModToCommunityResponse, LemmyError> {
let data: &AddModToCommunity = &self;
let data: &AddModToCommunity = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let community_id = data.community_id;
Expand Down Expand Up @@ -333,7 +333,7 @@ impl Perform for TransferCommunity {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<GetCommunityResponse, LemmyError> {
let data: &TransferCommunity = &self;
let data: &TransferCommunity = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let site_creator_id = blocking(context.pool(), move |conn| {
Expand Down
4 changes: 2 additions & 2 deletions crates/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ where
for<'de> Data: Deserialize<'de> + 'a,
Data: Perform,
{
let parsed_data: Data = serde_json::from_str(&data)?;
let parsed_data: Data = serde_json::from_str(data)?;
let res = parsed_data
.perform(&web::Data::new(context), Some(id))
.await?;
Expand Down Expand Up @@ -212,7 +212,7 @@ mod tests {

// The check should fail, since the validator time is now newer than the jwt issue time
let updated_local_user =
LocalUser::update_password(&conn, inserted_local_user.id, &"password111").unwrap();
LocalUser::update_password(&conn, inserted_local_user.id, "password111").unwrap();
let check_after = check_validator_time(&updated_local_user.validator_time, &claims);
assert!(check_after.is_err());

Expand Down
26 changes: 13 additions & 13 deletions crates/api/src/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Perform for Login {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<LoginResponse, LemmyError> {
let data: &Login = &self;
let data: &Login = self;

// Fetch that username / email
let username_or_email = data.username_or_email.clone();
Expand Down Expand Up @@ -160,7 +160,7 @@ impl Perform for SaveUserSettings {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<LoginResponse, LemmyError> {
let data: &SaveUserSettings = &self;
let data: &SaveUserSettings = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let avatar = diesel_option_overwrite_to_url(&data.avatar)?;
Expand Down Expand Up @@ -279,7 +279,7 @@ impl Perform for ChangePassword {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<LoginResponse, LemmyError> {
let data: &ChangePassword = &self;
let data: &ChangePassword = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

password_length_check(&data.new_password)?;
Expand Down Expand Up @@ -322,7 +322,7 @@ impl Perform for AddAdmin {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<AddAdminResponse, LemmyError> {
let data: &AddAdmin = &self;
let data: &AddAdmin = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

// Make sure user is an admin
Expand Down Expand Up @@ -384,7 +384,7 @@ impl Perform for BanPerson {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<BanPersonResponse, LemmyError> {
let data: &BanPerson = &self;
let data: &BanPerson = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

// Make sure user is an admin
Expand Down Expand Up @@ -460,7 +460,7 @@ impl Perform for GetReplies {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<GetRepliesResponse, LemmyError> {
let data: &GetReplies = &self;
let data: &GetReplies = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
Expand Down Expand Up @@ -497,7 +497,7 @@ impl Perform for GetPersonMentions {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<GetPersonMentionsResponse, LemmyError> {
let data: &GetPersonMentions = &self;
let data: &GetPersonMentions = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
Expand Down Expand Up @@ -531,7 +531,7 @@ impl Perform for MarkPersonMentionAsRead {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<PersonMentionResponse, LemmyError> {
let data: &MarkPersonMentionAsRead = &self;
let data: &MarkPersonMentionAsRead = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let person_mention_id = data.person_mention_id;
Expand Down Expand Up @@ -574,7 +574,7 @@ impl Perform for MarkAllAsRead {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<GetRepliesResponse, LemmyError> {
let data: &MarkAllAsRead = &self;
let data: &MarkAllAsRead = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let person_id = local_user_view.person.id;
Expand Down Expand Up @@ -629,7 +629,7 @@ impl Perform for PasswordReset {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<PasswordResetResponse, LemmyError> {
let data: &PasswordReset = &self;
let data: &PasswordReset = self;

// Fetch that email
let email = data.email.clone();
Expand Down Expand Up @@ -672,7 +672,7 @@ impl Perform for PasswordChange {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<LoginResponse, LemmyError> {
let data: &PasswordChange = &self;
let data: &PasswordChange = self;

// Fetch the user_id from the token
let token = data.token.clone();
Expand Down Expand Up @@ -712,7 +712,7 @@ impl Perform for GetReportCount {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<GetReportCountResponse, LemmyError> {
let data: &GetReportCount = &self;
let data: &GetReportCount = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let person_id = local_user_view.person.id;
Expand Down Expand Up @@ -768,7 +768,7 @@ impl Perform for GetFollowedCommunities {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<GetFollowedCommunitiesResponse, LemmyError> {
let data: &GetFollowedCommunities = &self;
let data: &GetFollowedCommunities = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let person_id = local_user_view.person.id;
Expand Down
8 changes: 4 additions & 4 deletions crates/api/src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Perform for CreatePostLike {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<PostResponse, LemmyError> {
let data: &CreatePostLike = &self;
let data: &CreatePostLike = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

// Don't do a downvote if site has downvotes disabled
Expand Down Expand Up @@ -102,7 +102,7 @@ impl Perform for LockPost {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<PostResponse, LemmyError> {
let data: &LockPost = &self;
let data: &LockPost = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let post_id = data.post_id;
Expand Down Expand Up @@ -172,7 +172,7 @@ impl Perform for StickyPost {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<PostResponse, LemmyError> {
let data: &StickyPost = &self;
let data: &StickyPost = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let post_id = data.post_id;
Expand Down Expand Up @@ -246,7 +246,7 @@ impl Perform for SavePost {
context: &Data<LemmyContext>,
_websocket_id: Option<ConnectionId>,
) -> Result<PostResponse, LemmyError> {
let data: &SavePost = &self;
let data: &SavePost = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let post_saved_form = PostSavedForm {
Expand Down
10 changes: 5 additions & 5 deletions crates/api/src/post_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Perform for CreatePostReport {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<CreatePostReportResponse, LemmyError> {
let data: &CreatePostReport = &self;
let data: &CreatePostReport = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

// check size of report and check for whitespace
Expand All @@ -53,7 +53,7 @@ impl Perform for CreatePostReport {
let person_id = local_user_view.person.id;
let post_id = data.post_id;
let post_view = blocking(context.pool(), move |conn| {
PostView::read(&conn, post_id, None)
PostView::read(conn, post_id, None)
})
.await??;

Expand Down Expand Up @@ -104,12 +104,12 @@ impl Perform for ResolvePostReport {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<ResolvePostReportResponse, LemmyError> {
let data: &ResolvePostReport = &self;
let data: &ResolvePostReport = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let report_id = data.report_id;
let report = blocking(context.pool(), move |conn| {
PostReportView::read(&conn, report_id)
PostReportView::read(conn, report_id)
})
.await??;

Expand Down Expand Up @@ -156,7 +156,7 @@ impl Perform for ListPostReports {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<ListPostReportsResponse, LemmyError> {
let data: &ListPostReports = &self;
let data: &ListPostReports = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

let person_id = local_user_view.person.id;
Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/private_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Perform for MarkPrivateMessageAsRead {
context: &Data<LemmyContext>,
websocket_id: Option<ConnectionId>,
) -> Result<PrivateMessageResponse, LemmyError> {
let data: &MarkPrivateMessageAsRead = &self;
let data: &MarkPrivateMessageAsRead = self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

// Checking permissions
Expand Down
Loading