Skip to content

Commit f03b0da

Browse files
committed
Resolve bad merge, run cargo fmt
1 parent 5efee7f commit f03b0da

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

src/controllers/user/email_verification.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ pub async fn resend_email_verification(
7474
// Generate a new token for the email, if it exists and is unverified
7575
conn.transaction(|conn| {
7676
async move {
77-
let email: Email = diesel::update(Email::belonging_to(auth.user()))
78-
.set(emails::token.eq(sql("DEFAULT")))
79-
.returning(Email::as_returning())
80-
.get_result(conn)
81-
.await
82-
.optional()?
83-
.ok_or_else(|| bad_request("Email could not be found"))?;
8477
let email: Email = diesel::update(
8578
emails::table
8679
.filter(emails::id.eq(email_id))

src/controllers/user/emails.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::auth::AuthCheck;
33
use crate::controllers::helpers::OkResponse;
44
use crate::email::EmailMessage;
55
use crate::models::{Email, NewEmail};
6-
use crate::util::errors::{bad_request, not_found, server_error, AppResult};
6+
use crate::util::errors::{AppResult, bad_request, not_found, server_error};
77
use crate::views::EncodableEmail;
88
use axum::Json;
99
use axum::extract::{FromRequest, Path};

src/tests/routes/users/emails.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ pub trait MockEmailHelper: RequestHelper {
1414
self.delete(&url).await
1515
}
1616

17-
async fn enable_notifications(
18-
&self,
19-
user_id: i32,
20-
email_id: i32,
21-
) -> Response<()> {
17+
async fn enable_notifications(&self, user_id: i32, email_id: i32) -> Response<()> {
2218
let url = format!("/api/v1/users/{user_id}/emails/{email_id}/notifications");
2319
self.put(&url, "").await
2420
}
@@ -214,15 +210,11 @@ async fn test_other_users_cannot_enable_my_notifications() {
214210
let another_user = app.db_new_user("not_me").await;
215211
let another_user_model = another_user.as_model();
216212

217-
let response = user
218-
.enable_notifications(another_user_model.id, 1)
219-
.await;
213+
let response = user.enable_notifications(another_user_model.id, 1).await;
220214
assert_snapshot!(response.status(), @"400 Bad Request");
221215
assert_snapshot!(response.text(), @r#"{"errors":[{"detail":"current user does not match requested user"}]}"#);
222216

223-
let response = anon
224-
.enable_notifications(another_user_model.id, 1)
225-
.await;
217+
let response = anon.enable_notifications(another_user_model.id, 1).await;
226218
assert_snapshot!(response.status(), @"403 Forbidden");
227219
assert_snapshot!(response.text(), @r#"{"errors":[{"detail":"this action requires authentication"}]}"#);
228220
}

src/tests/util.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,12 @@ impl MockCookieUser {
317317
}
318318

319319
/// Creates an email for the user, directly inserting it into the database
320-
pub async fn db_new_email(&self, email: &str, verified: bool, send_notifications: bool) -> crate::models::Email {
320+
pub async fn db_new_email(
321+
&self,
322+
email: &str,
323+
verified: bool,
324+
send_notifications: bool,
325+
) -> crate::models::Email {
321326
let mut conn = self.app.db_conn().await;
322327
let new_email = crate::models::NewEmail::builder()
323328
.user_id(self.user.id)

src/views.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,13 +700,17 @@ pub struct EncodablePrivateUser {
700700
/// Whether the user's has been sent a verification email to their notification email address, if set.
701701
#[schema(example = true)]
702702
#[serde(rename = "email_verification_sent")]
703-
#[deprecated(note = "Use `emails` array instead, check that `token_generated_at` property is not null.")]
703+
#[deprecated(
704+
note = "Use `emails` array instead, check that `token_generated_at` property is not null."
705+
)]
704706
pub notification_email_verification_sent: bool,
705707

706708
/// The user's email address for sending notifications, if set.
707709
#[schema(example = "[email protected]")]
708710
#[serde(rename = "email")]
709-
#[deprecated(note = "Use `emails` array instead, maximum of one entry will have `send_notifications` property set to true.")]
711+
#[deprecated(
712+
note = "Use `emails` array instead, maximum of one entry will have `send_notifications` property set to true."
713+
)]
710714
pub notification_email: Option<String>,
711715

712716
/// The user's avatar URL, if set.

0 commit comments

Comments
 (0)