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

feat(notification): add Twillio notification provider #344

Merged
merged 2 commits into from Sep 27, 2020

Conversation

WillsB3
Copy link
Contributor

@WillsB3 WillsB3 commented Sep 27, 2020

Description

Adds Twilio (https://www.twilio.com/) as a notification provider so that users outside of the US can receive stock notifications via SMS.

Fixes #342
Discord: Wills#6846

Testing

  • Ran npm run test:notification and received the test SMS.
  • Tested using my own Twilio account and received notifcation for test:series in sock via SHOW_ONLY_SERIES="test:series".

New dependencies

Adds Twilio (https://www.twilio.com/) as a notification provider so that users outside of the US can receive stock notifications via SMS.
@WillsB3 WillsB3 requested a review from jef as a code owner September 27, 2020 11:50
Comment on lines +57 to +60
if (notifications.twilio.accountSid && notifications.twilio.authToken) {
Logger.debug('↗ sending twilio message');
sendTwilioMessage(link, store);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this causes a code complexity linting warning. Not sure on how you'd prefer this be solved. Does this function need a refactor?

Copy link
Owner

Choose a reason for hiding this comment

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

Nah, that's ok. We need to separate these out at some point. It's probably just complaining because of the line length within this function.

Copy link
Owner

@jef jef left a comment

Choose a reason for hiding this comment

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

Straight forward! Looks good to me.

Thanks!

Comment on lines +57 to +60
if (notifications.twilio.accountSid && notifications.twilio.authToken) {
Logger.debug('↗ sending twilio message');
sendTwilioMessage(link, store);
}
Copy link
Owner

Choose a reason for hiding this comment

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

Nah, that's ok. We need to separate these out at some point. It's probably just complaining because of the line length within this function.

@jef jef merged commit f2f8d81 into jef:main Sep 27, 2020
@ghost
Copy link

ghost commented Sep 27, 2020

this is making the latest build fail, as it appears a Twilio username is now required?

@rrbailey89
Copy link

rrbailey89 commented Sep 27, 2020

can confirm, latest build wont start now. I dont have any mentions of Twilio in my .env, but its crashing saying error:username is required for Twilio.


const config = Config.notifications.twilio;

const client = twilio(config.accountSid, config.authToken);
Copy link
Contributor Author

@WillsB3 WillsB3 Sep 29, 2020

Choose a reason for hiding this comment

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

@jef Sorry - only just seen this was merged. Didn't get GitHub email notifications for some reason.

I've seen reports of users having issues since this has been merged, saying that they are getting an error that Twilio credentials are needed even when they haven't set any of the Twilio config options.

I have a suspicion that this line is the cause. We should move it so we are only initalizing the client inside sendTwilioMessage. I'll try and get a PR up later.

Copy link
Contributor

Choose a reason for hiding this comment

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

@WillsB3 another user provided a fix in #349 which has been merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah great, thanks.

Sorry for the trouble

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.

Support sending notifications via Twilio
4 participants