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

Send email #188

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Send email #188

wants to merge 9 commits into from

Conversation

Karyum
Copy link
Collaborator

@Karyum Karyum commented Mar 15, 2018

close #187

I have made an account on sendGrid so i would build the template on their website with HTML and CSS
currentley doesn't look great but it has the name of the content and a link of the content in the data entry ( also arabic support 😉 ) :
111

this is how literately it's gonna look like in the email

this is how it looks like when you recieve it :
email1

also right now everyone who is not a BASIC user is sent an email, should we keep it like that or should i make it ADMIN recieve emails only ?

@Karyum Karyum requested review from des-des and removed request for des-des March 15, 2018 20:43
@Karyum Karyum added on hold and removed for review labels Mar 15, 2018
@mattlub
Copy link
Collaborator

mattlub commented Mar 16, 2018

will running the tests send real emails out?

EDIT: I realised It will only be sending to fake addresses but still doesn't seem like a good idea


module.exports = content =>
new Promise((resolve, reject) =>
User.find()
Copy link
Collaborator

@mattlub mattlub Mar 16, 2018

Choose a reason for hiding this comment

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

you can put parameters in the find method to filter only the users you want, and you can also select the fields you want (just email or maybe name and email). Then you won't need the extractEmails call

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

huh nice! didn't know this before

}, [])

module.exports = content =>
new Promise((resolve, reject) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

you don't need the new Promise(...) part, you can do content => User.find(...).then(...)

@Karyum
Copy link
Collaborator Author

Karyum commented Mar 16, 2018

@mattlub yeah it's currently sending emails to [email protected] every time a test is run 😅 , not sure how to do it otherwise though 🤔

@Karyum Karyum assigned des-des and unassigned des-des Mar 28, 2018
@@ -50,7 +51,7 @@ eventController.create = (req, res, next) => {

const newEvent = new Event(newEventDetails)
newEvent.save()
// TODO: .then(event => req.user.role !== roles.BASIC ? event : sendEmail(event))
.then(event => req.user.role !== roles.BASIC ? event : sendEmail(event))
Copy link
Member

Choose a reason for hiding this comment

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

Do not put side effects in a ternary! (use an if / else)
Your async flow is cray cray, does sendEmail return a promise?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i don't see any problem here other than readability maybe?, if i had this in if/else and in ternary it's just going to do the same thing if the user is BASIC then sends an email then the sendEmail function would resolve with the event, if he's not then resolve with the event without sending the email. so whats the reason here to put this in an if statement instead of ternary ?! @des-des

@@ -35,6 +36,7 @@ placeController.create = (req, res, next) => {

const newPlace = new Place(newPlaceDetails)
newPlace.save()
.then(place => req.user.role !== roles.BASIC ? place : sendEmail(place))
Copy link
Member

Choose a reason for hiding this comment

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

again this is silly

const sendEmails = (emails, content) => {
const msg = {
to: emails,
from: '[email protected]',
Copy link
Member

Choose a reason for hiding this comment

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

put this in env var?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement send email functionality
3 participants