Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Send confirmation email #4335

Merged
merged 23 commits into from
Apr 14, 2017
Merged

Conversation

chadwhitacre
Copy link
Contributor

@chadwhitacre chadwhitacre commented Feb 14, 2017

Part of #4305.

Requirements

(7) and (8) from the workflow:

(7) receive email
(8) click link

Todo

  • fix these three failing tests
  • write Python API w/ tests & docs—should put mail on the queue
    • make sure we don't allow connecting the same package to two accounts
      that happens on finish-claim, not start-claim
    • make sure we're validating the address, can't send to just anyone
    • extend start_email_verification to take packages
      • what about packages in the except case?
    • extend add_email to take packages
  • what happens to old claims when nonce is updated out from under it?
  • modify modify.json.spt w/ tests—should call into Python
    • consider LazyResponse
  • write the email template
  • should notify others listed as maintainers? no, too much for now
  • can we inject via npm package name?
  • don't say we're connecting when we're not (ancillary accounts)
  • should be able to start a verification for a different package w/ same email and have it not clobber the first (added? in addition?) Send confirmation email #4335 (comment)

@chadwhitacre chadwhitacre changed the base branch from master to project/claim-packages February 14, 2017 20:15
This was referenced Feb 14, 2017
@chadwhitacre chadwhitacre force-pushed the project/claim-packages branch 2 times, most recently from bdd20ac to 9ea1b0c Compare February 20, 2017 16:00
@chadwhitacre
Copy link
Contributor Author

Rebased, was f3e657f.

@chadwhitacre chadwhitacre force-pushed the project/claim-packages-send branch 4 times, most recently from 53a7f29 to 91dcc5a Compare February 20, 2017 19:33
@chadwhitacre
Copy link
Contributor Author

Gosh, this would be easier to implement if we kept it to two steps:

  • add email
  • claim package

But that makes it harder for users.

@chadwhitacre
Copy link
Contributor Author

The natural thing for a user is to claim the package and add the email in one fell swoop.

@chadwhitacre
Copy link
Contributor Author

Our email infrastructure is pretty squishy. I started really getting into it yesterday, and I'm trying to decide how deep to go.

@chadwhitacre chadwhitacre mentioned this pull request Feb 21, 2017
1 task
@chadwhitacre chadwhitacre force-pushed the project/claim-packages branch from 9ea1b0c to 4ac1d86 Compare March 3, 2017 19:52
@chadwhitacre chadwhitacre force-pushed the project/claim-packages-send branch from a9f9dfe to a487ef5 Compare March 3, 2017 20:00
@chadwhitacre
Copy link
Contributor Author

Rebased.

@chadwhitacre
Copy link
Contributor Author

I started really getting into it yesterday, and I'm trying to decide how deep to go.

Went pretty deep! 😁

@chadwhitacre chadwhitacre force-pushed the project/claim-packages-send branch from a487ef5 to ba41e6d Compare March 17, 2017 14:18
@chadwhitacre chadwhitacre force-pushed the project/claim-packages branch from 4ac1d86 to 11a436f Compare March 17, 2017 14:19
@chadwhitacre
Copy link
Contributor Author

Alright, what the heck am I doing here?

@chadwhitacre
Copy link
Contributor Author

What's the end result here? What behavior?

/me reviews ticket and parent ...

@chadwhitacre
Copy link
Contributor Author

screen shot 2017-03-22 at 1 49 47 pm

@chadwhitacre
Copy link
Contributor Author

(I updated the ticket description with requirements.)

@chadwhitacre
Copy link
Contributor Author

Blorg. Right. Gotta think through adding email vs. mailing before adding. Current infrastructure assumes ... wait, does it? Assume we're only ever sending to participant.email_address? But then how does adding non-primary emails work?

@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented Mar 22, 2017

Ah ... is the To specified in the context in that case?

@chadwhitacre
Copy link
Contributor Author

Yeah, that's it.

@chadwhitacre
Copy link
Contributor Author

Existing verification_notice should be good enough for the package claiming case as well.

@chadwhitacre
Copy link
Contributor Author

We can mostly use the existing add_email flow. The caveat is that we should send a mail even when the email already exists.

@chadwhitacre chadwhitacre force-pushed the project/claim-packages-send branch from ba41e6d to b81cb7d Compare March 22, 2017 18:45
@chadwhitacre
Copy link
Contributor Author

Rebased, was de1a0a3.

@kaguillera
Copy link
Contributor

LGTM...off to the second reviewr

Copy link
Contributor

@dowski dowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully some of this is helpful. Some of it is certainly my ignorance of Gratipay code/context/conventions.

and returns ``None``.
"""
if not packages:
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a normal condition? If not, consider logging or throwing an exception. Seems odd to start a package claim on an empty list of packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2c2a3a5. 👍

"""
if not packages:
return
VALUES, values = [], []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this Gratipay convention, to use CAPS for format strings? Normally I'd expect that to be a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had named it VALUES to harmonize with VALUES in the SQL statement, but I see your point. Addressed in 2c2a3a5.

for p in packages:
VALUES.append('(%s, %s)')
values += [nonce, p.id]
VALUES = ', '.join(VALUES)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems tricky to switch types of a variable from line to line. Maybe that's the Java coder in me though. ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 2c2a3a5. For large inputs the ', '.join idiom is more performant than string concatenation due to Python implementation details, but our inputs here are not large (order of magnitude 100 packages max to be claimed at once).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I didn't have a problem with .join(), it was just my internal type checker twitching at VALUES starting as a list of strings and then getting reassigned to a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. @kaguillera thinks this is the Java coder in you. 😛

headers = {b'HTTP_ACCEPT_LANGUAGE': b'en'}
return f('/~alice/emails/modify.json', data, auth_as=user, **headers)

# Hack to work around Aspen test client limitations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What limitation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment verbosified in 136591a.

('<b><a href="https://gratipay.com/~{0}/">{0}</a></b>'|safe).format(username)) }}
{% if new_email_verified %}
{{ ngettext( "We've received a request to connect the {package_name} npm package to the "
"{username} account on Gratipay. Sound familiar?"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it doesn't sound familiar?

What if it does, for that matter? I don't really know what I would do if I received an email like this.

Am I supposed to click the package name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Down on line 32 there's a "Yes, proceed!" button. Here's what it looks like:

screen shot 2017-04-13 at 8 41 55 am

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, woops - didn't see that! Thanks!

VALUES.append('(%s, %s)')
values += [nonce, p.id]
VALUES = ', '.join(VALUES)
c.run('INSERT INTO claims (nonce, package_id) VALUES ' + VALUES, values)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm generally unfamiliar with the Gratipay DB environment. Does anything exist to clean up claims that lay around for a long time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No! Reticketed as #4408.

for p in packages:
VALUES.append('(%s, %s)')
extra_sql += ' (%s, %s)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like maybe this isn't going to be delimited by commas anymore?

" (%s, %s) (%s, %s) (%s, %s)"

Maybe that's OK for Postgres though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. The few tests I ran passed. Lessee here ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay CI! :-)

    def execute(self, query, vars=None):
        self.Record = None
>       return super(NamedTupleCursor, self).execute(query, vars)
E       ProgrammingError: syntax error at or near "("
E       LINE 1: ...LUES ('208503b2-9283-4bc8-ab51-6ed60c28c9a3', 30) ('208503b2...
E  

https://travis-ci.org/gratipay/gratipay.com/builds/221772022#L2879-L2884

Fixing ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You okay with 9926985?

@chadwhitacre
Copy link
Contributor Author

With gratipay/inside.gratipay.com#1038 (comment) you should be cleared to merge, @dowski. Got a green button?

@dowski dowski merged commit baf8248 into project/claim-packages Apr 14, 2017
@chadwhitacre
Copy link
Contributor Author

Woo-hoo! 💃

@chadwhitacre chadwhitacre deleted the project/claim-packages-send branch April 25, 2017 00:28
chadwhitacre added a commit that referenced this pull request Apr 28, 2017
chadwhitacre added a commit that referenced this pull request Apr 28, 2017
chadwhitacre added a commit that referenced this pull request May 5, 2017
chadwhitacre added a commit that referenced this pull request May 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants