-
Notifications
You must be signed in to change notification settings - Fork 640
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
Send email on crate owner invitation #1360
Comments
Hi, I would be willing to have a look at this if you want, but may need a bit of help with it. Thanks |
Several people have observed this, and people have the impression that there are such emails. At the very least until there is a mechanism for this the UI needs an update to explicitly say "there's no notification, let the proposed owner know yourself, here's the link to send them". |
I'm currently working on this! Planned behaviour (after discussion with @carols10cents) is to dispatch the email in krate.rs and allow this operation to silently fail. That is, adding an owner can succeed even if sending the invitation email fails. |
@carols10cents I'm working through the initial changes to the query in The following returns
I was attempting to chain Assuming the above query is working as I've described, does that seem alright? |
@nkanderson whoops! You're right-- I wrote |
Hi @carols10cents, I'm still chipping away at this one, but had a quick question for you - the first bit of this (send email with basic info) was pretty straightforward, and I think I could open a PR for it. Should I go ahead and do that? I'm up for continuing the work to implement the token part of it as well, but don't want to block on the improvement of having any email sent. If you'd rather review it all at once though, I can keep going and open a PR with the whole thing once it's ready. |
@nkanderson Opening a PR for a smaller part is fine with me! Please do! :) |
Send email on crate owner invitation If the recipient of a crate ownership invitation has a verified email address, they will be sent an email indicating that a specified user has invited them to become an owner of a named crate. Only sends the email on the first instance of an invitation. Completes the first part of #1360.
I'm getting into the second phase of this work, and wanted to check in about a couple things and make sure I'm on the right track:
Does that seem like a reasonable approach? Should any of that be adjusted (like route names, etc.)? |
Hm, I think as someone working on the codebase, I would expect all the crate ownership invitation URLs to be grouped together (that is, have the same prefix) rather than all the token confirmation URLs to be grouped together. Looking at the URLs and what else is under And this is also kind of nitpicky and not super important, but I would describe the action we're talking about adding here as "accepting" an invitation, rather than "confirm" like the email confirming. What do you think about I'd also accept a separate pull request to move the confirm email and resend email routes under
Similarly, I think I'm thinking about what I'd like to do next after successfully accepting an invitation to own a crate... would I want to see if I had any other invitations to accept? Would I want to go to the page of the crate I now own? Would I want to go to the list of all crates that I own? I'm not sure! The pending-invitations page is probably fine; we can adjust if we get feedback that something else would be more useful. If accepting an invitation failed, I think suggesting they go to the pending-invites page to try again is a good idea. Thanks!! |
Great, yeah, those route names sound good to me! It's helpful to have the distinction b/t accept and confirm or verify. And it sounds like the I think I should be able to modify my proof-of-concept to match what you've outlined above, then I'll move on to writing tests. It'll be my first attempt at writing Rust tests of any complexity, so I may post back here with questions! |
Hi @carols10cents - I've got a branch on my fork with all of the working code for token-based ownership acceptance, but I've got a couple of questions and not sure if I should open a PR to review there or work through it here. Do you have a preference? Specifically, I've got a couple of questions in the commits indicated by |
@nkanderson Opening a PR sounds great! You can even open a "draft PR" in GitHub now, which will make sure we don't merge it until you're happy with it. Thanks! |
1360 crate ownership invitation token Completes #1360
This is now completed and will be fully deployed soon! Thank you @nkanderson !!! |
If there's an email address for the person being invited (which we don't require yet)
It'd be awesome if the email included a one-click link to accept the invitation without logging in (so with a token like the email verification works now)
Related:
Instructions
Invitations get created in the krate.owner_add method.
Currently, if you add someone as an owner multiple times, it just updates the one existing invitation record. We don't want to send multiple emails in this situation, as this would be an easy vector for spamming someone.
You can tell whether a row was inserted or not when you say
on conflict do update
by adding areturning
method call to request that the query returns some of the data, getting the result with theget_result
method, and calling theoptional
method to tell diesel it's ok if it doesn't get a result. If the query did nothing (because that record already existed), nothing will be returned and this diesel statement will result in aNone
value. Here's an example where we do this:So after creating an invitation, and only if that invitation record was created (rather than only updated because it already existed), send the invited user an email.
Get the email address by first getting the
User
(owner
here is anOwner::User
, change the underscore in that match pattern to a variable name to be able to use the innerUser
thatOwner::User
holds)Get the email address for that
User
NOT through theemail
field; that's left over from before we verified email addresses. Instead, use theverified_email
method. If the user doesn't have a verified email address, don't send the email.Send the email by calling a new function you'll need to create in
src/email.rs
. The new function should swallow all errors likesend_user_confirm_email
does by usinglet _ =
, but should callsend_email
liketry_send_user_confirm_email
does. I think we only need one function in the case of sending owner invitation emails, rather than the two functions we have for verifying your email address, because we always want creating the invitation to succeed even if we can't send an email about it.I would merge a PR that sends an email that always has the same content; something along the lines of "You've been invited to become the owner of a crate! Please visit https://crates.io/me/pending-invites to accept or reject this invitation."
The enhancements I could see making to that email would be:
but I would rather have a PR with the basic implementation of this feature than no PR.
We don't have a great way to write tests that check emails are sent :-/ You should be able to test this out locally; the emails will be "sent" to a file in
/tmp/
.The text was updated successfully, but these errors were encountered: