Skip to content

Convert more endpoints to ok_true() #1933

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

Merged
merged 1 commit into from
Dec 2, 2019
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
24 changes: 4 additions & 20 deletions src/controllers/user/me.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ pub fn update_user(req: &mut dyn Request) -> AppResult<Response> {
Ok(())
})?;

#[derive(Serialize)]
struct R {
ok: bool,
}
Ok(req.json(&R { ok: true }))
ok_true()
}

/// Handles the `PUT /confirm/:email_token` route
Expand All @@ -195,11 +191,7 @@ pub fn confirm_user_email(req: &mut dyn Request) -> AppResult<Response> {
return Err(bad_request("Email belonging to token not found."));
}

#[derive(Serialize)]
struct R {
ok: bool,
}
Ok(req.json(&R { ok: true }))
ok_true()
}

/// Handles `PUT /user/:user_id/resend` route
Expand All @@ -226,11 +218,7 @@ pub fn regenerate_token_and_send(req: &mut dyn Request) -> AppResult<Response> {
.map_err(|_| bad_request("Error in sending email"))
})?;

#[derive(Serialize)]
struct R {
ok: bool,
}
Ok(req.json(&R { ok: true }))
ok_true()
}

/// Handles `PUT /me/email_notifications` route
Expand Down Expand Up @@ -283,9 +271,5 @@ pub fn update_email_notifications(req: &mut dyn Request) -> AppResult<Response>
.set(email_notifications.eq(excluded(email_notifications)))
.execute(&*conn)?;

#[derive(Serialize)]
struct R {
ok: bool,
}
Ok(req.json(&R { ok: true }))
ok_true()
}
6 changes: 1 addition & 5 deletions src/controllers/version/yank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,5 @@ fn modify_yank(req: &mut dyn Request, yanked: bool) -> AppResult<Response> {
.enqueue(&conn)
.map_err(|e| AppError::from_std_error(e))?;

#[derive(Serialize)]
struct R {
ok: bool,
}
Ok(req.json(&R { ok: true }))
ok_true()
}