Skip to content
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

BE invitation dialog 40 #45

Merged
merged 57 commits into from
May 27, 2020
Merged

BE invitation dialog 40 #45

merged 57 commits into from
May 27, 2020

Conversation

cch5ng
Copy link
Collaborator

@cch5ng cch5ng commented May 27, 2020

updates create invitation api route (post)

requirements

at #40 (comment)

to test

used curl to make BE requests, with the jwt auth step commented out

tested the following cases (verifying results in cloud database with mongo shell; I can provide a connection string):

  • invite recipients (toEmailAr) includes some users who are registered ([email protected], [email protected]) and some who are not registered. invitations should be created for registered users. sendgrid should send email invites to the non-registered recipients.

  • invite recipients include only registered users (multiple and single)

  • invite recipients include only non-registered users (multiple and single)

Notes: I didn't test really hard on the multiples. I'm not entirely clear on the error handling like if there are multiple error scenarios, how to gather all those. I'm aware that there is a bit of redundancy in the code (creating invites and making sendgrid requests but I'm not clear how to make it more dry b/c of the nesting.

curl example:

curl -d  '{"toEmailAr": ["[email protected]", "[email protected]", "[email protected]", "[email protected]"], "fromEmail": "[email protected]", "referralId": "test-referral_id"}' -H "Content-Type: application/json" -X POST http://127.0.0.1:3001/invitations

(old messages)
@sina-jamshidi I'm a little bit unclear of when I should return a result to the browser. I think the timing is ok for these cases:

  • all invitation recipients are registered users

  • all invitation recipients are not registered

(update with proposed solution) I suppose I have to check the cases in this order

1 if there are both invite recipients who are registered and who are not registered

  • for this case, I suppose, I might nest the requests like first make the local database changes and after completion, make the sendgrid requests; I will try this

2 if there are invite recipients who are all registered

3 if there are invite recipients who are all not registered

cch5ng added 30 commits May 21, 2020 15:12
…ation of invitations for existing users (in progress)
@cch5ng cch5ng changed the title [in progress] BE invitation dialog 40 BE invitation dialog 40 May 27, 2020
server/routes/invitation.js Outdated Show resolved Hide resolved
server/routes/invitation.js Outdated Show resolved Hide resolved
return sgMail.send(msg);
}

const sendEmailMultiple = ({from_email, to_email_ar, referral_id}) => {

Choose a reason for hiding this comment

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

as per the sendgrid npm package it looks like you can just do sgMail.send(messages). That also means you can probably refactor to only have one sendEmail function.

@cch5ng
Copy link
Collaborator Author

cch5ng commented May 27, 2020 via email

@sina-jamshidi
Copy link

(update with proposed solution) I suppose I have to check the cases in this order

1 if there are both invite recipients who are registered and who are not registered

  • for this case, I suppose, I might nest the requests like first make the local database changes and after completion, make the sendgrid requests; I will try this

2 if there are invite recipients who are all registered

3 if there are invite recipients who are all not registered

Yup makes sense. This PR looks good to me once you make the commented changes.

@cch5ng cch5ng merged commit 3a80db2 into dev May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants