-
-
Notifications
You must be signed in to change notification settings - Fork 486
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
Feature/1886 Volunteer receives SMS to notify of follow up generated by admin or supervisor #3738
Changes from all commits
68a1ac6
7e68bdd
bc92a82
63fe3d5
188619f
b2336f3
5668da6
c7e7eae
25f82de
58e8b79
aedabd7
c6c4ae0
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,26 @@ | ||
class DeliveryMethods::Sms < Noticed::DeliveryMethods::Base | ||
include SmsBodyHelper | ||
def deliver | ||
if sender.casa_admin? || sender.supervisor? | ||
short_io_api = ShortUrlService.new | ||
short_io_api.create_short_url(case_contact_url) | ||
shortened_url = short_io_api.short_url | ||
twilio_api = TwilioService.new(sender.casa_org.twilio_api_key_sid, sender.casa_org.twilio_api_key_secret, sender.casa_org.twilio_account_sid) | ||
twilio_api.send_sms({From: sender.casa_org.twilio_phone_number, Body: case_contact_flagged_msg(sender.display_name, shortened_url), To: recipient.phone_number}) | ||
end | ||
end | ||
|
||
def case_contact_url | ||
Rails.application.credentials[:BASE_URL] + "/case_contacts/" + case_contact_id.to_s + "/edit?notification_id=" + record.id.to_s | ||
end | ||
|
||
private | ||
|
||
def sender | ||
User.find(params[:followup][:creator_id]) | ||
end | ||
|
||
def case_contact_id | ||
params[:followup][:case_contact_id] | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ class FollowupNotification < BaseNotification | |
# Add your delivery methods | ||
# | ||
deliver_by :database | ||
# deliver_by :email, mailer: "UserMailer" | ||
# deliver_by :email, mailer: "UserMailer", if: :email_notifications? | ||
# deliver_by :sms, class: "DeliveryMethods::Sms", if: :sms_notifications? | ||
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. is this supposed to be commented out? 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. Yes, the email one was commented out when I started this. https://github.com/rubyforgood/casa/pull/1612/files is the email and database pr 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 the "noticed gem" was first added here #1611 |
||
# deliver_by :slack | ||
# deliver_by :custom, class: "MyDeliveryMethod" | ||
|
||
|
@@ -29,6 +30,14 @@ def url | |
|
||
private | ||
|
||
def sms_notifications? | ||
recipient.receive_sms_notifications == true | ||
end | ||
|
||
def email_notifications? | ||
recipient.receive_email_notifications == true | ||
end | ||
|
||
def message_with_note(note) | ||
[ | ||
message_heading, | ||
|
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.
ideally let's not add to the skipped tests file
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.
For sure. I'm beginning to figure out how this could be tested, which will hopefully lay the groundwork for testing the other notifications in .allow_skipping_tests