-
Notifications
You must be signed in to change notification settings - Fork 26
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
Bl/waitlist notify #254
Bl/waitlist notify #254
Changes from 7 commits
cafe725
edf81c3
27b44a8
1edbd5a
5cd7d5e
d11daf3
06d5cab
f191563
51e9ce2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module Messenger | ||
|
||
def send_sms(number, content) | ||
sid = ENV["TWILIO_ACCT_SID"] | ||
auth = ENV["TWILIO_AUTH"] | ||
|
||
@client = Twilio::REST::Client.new sid, auth | ||
|
||
from = "+14123854063" | ||
|
||
# The following try-rescue block is needed in case user unsubscribe | ||
# if the user ubsubscribe and we attempt to message them | ||
# the api will report an error | ||
|
||
begin | ||
message = @client.account.messages.create( | ||
:from => from, | ||
:to => '+1'+number, | ||
:body => content | ||
) | ||
rescue Twilio::REST::RequestError => e | ||
case e.code | ||
when 21610 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is the un-sub error we should unsub them locally as well rather than continuing to try to message them and continuing to fail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the error code in case that a client unsubscribe from getting twilio message. The API reports a blacklist error and need to be rescued. There're several lines of comments in this file to explain what it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're missing my point. If this error means that a user un-subscribed from Twilio, we should probably make note of that locally so that we don't try to message that user again in the future, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I totally agree we should have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, can we make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, lets just do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ChaseBro There is no need to locally keep track of whoever unsubscribed. Twilio API keeps track of it and if a user blacklist our number, Twilio will not send out a message to them. Here is documentation: https://support.twilio.com/hc/en-us/articles/223133627--The-message-From-To-pair-violates-a-blacklist-rule-when-sending-messages |
||
puts e.message | ||
end | ||
end | ||
end | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're calling this
after_update
, but is the only reason this could ever get updated a check-in? Otherwise you'll be sending this randomly. I think it would be much better to make this part of the controller. That way you could even add a "notify next" button on the frontend and have the controller action half-wired up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you are saying here @ChaseBro, but if I'm not mistaken, as it stands after the check in is the only reason this should be updated. Given the proximity to Carnival, I think we should go with it and open a high priority issue / bug. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened issue #256 about this issue