Skip to content

Commit 0fb0f0e

Browse files
committed
Convert more endpoints to ok_true()
1 parent 4a1542c commit 0fb0f0e

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

src/controllers/user/me.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ pub fn update_user(req: &mut dyn Request) -> AppResult<Response> {
173173
Ok(())
174174
})?;
175175

176-
#[derive(Serialize)]
177-
struct R {
178-
ok: bool,
179-
}
180-
Ok(req.json(&R { ok: true }))
176+
ok_true()
181177
}
182178

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

198-
#[derive(Serialize)]
199-
struct R {
200-
ok: bool,
201-
}
202-
Ok(req.json(&R { ok: true }))
194+
ok_true()
203195
}
204196

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

229-
#[derive(Serialize)]
230-
struct R {
231-
ok: bool,
232-
}
233-
Ok(req.json(&R { ok: true }))
221+
ok_true()
234222
}
235223

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

286-
#[derive(Serialize)]
287-
struct R {
288-
ok: bool,
289-
}
290-
Ok(req.json(&R { ok: true }))
274+
ok_true()
291275
}

src/controllers/version/yank.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,5 @@ fn modify_yank(req: &mut dyn Request, yanked: bool) -> AppResult<Response> {
4040
.enqueue(&conn)
4141
.map_err(|e| AppError::from_std_error(e))?;
4242

43-
#[derive(Serialize)]
44-
struct R {
45-
ok: bool,
46-
}
47-
Ok(req.json(&R { ok: true }))
43+
ok_true()
4844
}

0 commit comments

Comments
 (0)