Skip to content

Commit 0c7de44

Browse files
committed
Adjust crate ownership invite conditional and email subject
1 parent 8838932 commit 0c7de44

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Diff for: src/email.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ https://crates.io/confirm/{}",
9292
/// the database and the user will see the invitation when they visit
9393
/// https://crates.io/me/pending-invites/.
9494
pub fn send_owner_invite_email(email: &str, user_name: &str, crate_name: &str) {
95-
let subject = "Please confirm crate ownership";
95+
let subject = "Crate ownership invitation";
9696
let body = format!(
9797
"{} has invited you to become an owner of the crate {}!\n
9898
Please visit https://crates.io/me/pending-invites to accept or reject

Diff for: src/models/krate.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ impl Crate {
427427

428428
match owner {
429429
// Users are invited and must accept before being added
430-
owner @ Owner::User(_) => {
430+
Owner::User(user) => {
431431
let maybe_inserted = insert_into(crate_owner_invitations::table)
432432
.values(&NewCrateOwnerInvitation {
433-
invited_user_id: owner.id(),
433+
invited_user_id: user.id,
434434
invited_by_user_id: req_user.id,
435435
crate_id: self.id,
436436
})
@@ -439,20 +439,18 @@ impl Crate {
439439
.optional()?;
440440

441441
if maybe_inserted.is_some() {
442-
if let Owner::User(user) = &owner {
443-
if let Ok(Some(email)) = user.verified_email(&conn) {
444-
email::send_owner_invite_email(
445-
&email.as_str(),
446-
&req_user.gh_login.as_str(),
447-
&self.name.as_str(),
448-
);
449-
}
442+
if let Ok(Some(email)) = user.verified_email(&conn) {
443+
email::send_owner_invite_email(
444+
&email.as_str(),
445+
&req_user.gh_login.as_str(),
446+
&self.name.as_str(),
447+
);
450448
}
451449
}
452450

453451
Ok(format!(
454452
"user {} has been invited to be an owner of crate {}",
455-
owner.login(),
453+
user.gh_login,
456454
self.name
457455
))
458456
}

0 commit comments

Comments
 (0)