think_feel_do_engine 3.21.2 → 3.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ff553dad57d0ae0a68326a83dd251c9f44037c2
4
- data.tar.gz: ef4e2750dd4cfe73e15445ac1c3303a7fedbf3d8
3
+ metadata.gz: 4f7415b8925aa5d127cbc80d056d04a6d44ef499
4
+ data.tar.gz: d892773131b44f665850c68441d6a07cd44bc3d8
5
5
  SHA512:
6
- metadata.gz: ece5a0cd2dac5b4f0f8ad8f58cdef342323fab606075c5ecfe077d12f9bc7c5e0141f5f763d9704ff15c81f7f36c2792930f81129ee4d0bbda587d3fe227f93b
7
- data.tar.gz: 73a185e725ad537b6543f8aae77ccc55b03a78778c725089f0b326cd6d344f72b86339053d31d34a02e15cc0003f10de494012994abc566160b428361c9887cd
6
+ metadata.gz: 1d5332d7126f454e962345cc75f8d9dc7a64605e1222b60065b75fccba4061889a7f48fbddfc5a91e9b3a32f260d00c74e39c27987bc8111173322053c2f5ea4
7
+ data.tar.gz: b6194ac2ddb5d08e59bc2b090b40bbe09ab40ab1d5f2d34f59f852761d8a1bb6804e0982ae5797d6a67dcf3a93fb35a36fda1c56d1931bdbccfb140cc8e83cc5
@@ -3,6 +3,8 @@
3
3
  class MessageSmsNotification
4
4
  attr_reader :body, :phone_number
5
5
 
6
+ BLACKLIST_MESSAGE = "The message From/To pair violates a blacklist rule."
7
+
6
8
  def initialize(body:, phone_number:)
7
9
  @body = body
8
10
  @phone_number = phone_number
@@ -14,10 +16,23 @@ class MessageSmsNotification
14
16
  else
15
17
  message
16
18
  end
19
+ rescue Twilio::REST::RequestError => e
20
+ if e.message == BLACKLIST_MESSAGE
21
+ record_delivery_error!(e.message)
22
+ else
23
+ capture_message(e.message)
24
+ end
17
25
  end
18
26
 
19
27
  private
20
28
 
29
+ def capture_message(message)
30
+ Raven
31
+ .capture_message message, extra: {
32
+ phone_number: phone_number
33
+ } if defined?(Raven)
34
+ end
35
+
21
36
  def config
22
37
  Rails.application.config
23
38
  end
@@ -46,6 +61,15 @@ class MessageSmsNotification
46
61
  params
47
62
  end
48
63
 
64
+ def record_delivery_error!(message)
65
+ ThinkFeelDoEngine::SmsDeliveryError
66
+ .create!(
67
+ body: body,
68
+ error_message: message,
69
+ phone_number: phone_number
70
+ )
71
+ end
72
+
49
73
  def sms_client
50
74
  @sms_client ||= Twilio::REST::Client.new(
51
75
  config.twilio_account_sid,
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ module ThinkFeelDoEngine
3
+ module Reports
4
+ # Collects relevant/unsubscribed SMS errors
5
+ class SmsDeliveryErrorRecord
6
+ def self.columns
7
+ %w( body error_message phone_number created_at )
8
+ end
9
+
10
+ def self.all
11
+ SmsDeliveryError
12
+ .all
13
+ .map do |sms_delivery_error|
14
+ {
15
+ body: sms_delivery_error.body,
16
+ error_message: sms_delivery_error.error_message,
17
+ phone_number: sms_delivery_error.phone_number,
18
+ created_at: sms_delivery_error.created_at.iso8601
19
+ }
20
+ end
21
+ .flatten
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ThinkFeelDoEngine
3
+ # Records sms errors when they aren't delivered
4
+ class SmsDeliveryError < ActiveRecord::Base
5
+ validates :body,
6
+ :error_message,
7
+ :phone_number,
8
+ presence: true
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class CreateThinkFeelDoEngineSmsDeliveryErrors < ActiveRecord::Migration
2
+ def change
3
+ create_table :think_feel_do_engine_sms_delivery_errors do |t|
4
+ t.string :phone_number, null: false
5
+ t.text :body, null: false
6
+ t.text :error_message, null: false
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # nodoc
3
3
  module ThinkFeelDoEngine
4
- VERSION = "3.21.2"
4
+ VERSION = "3.22.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: think_feel_do_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.21.2
4
+ version: 3.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Carty-Fickes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-25 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -561,12 +561,14 @@ files:
561
561
  - app/models/think_feel_do_engine/reports/phq_assessment.rb
562
562
  - app/models/think_feel_do_engine/reports/reporter.rb
563
563
  - app/models/think_feel_do_engine/reports/site_session.rb
564
+ - app/models/think_feel_do_engine/reports/sms_delivery_error_record.rb
564
565
  - app/models/think_feel_do_engine/reports/task_completion.rb
565
566
  - app/models/think_feel_do_engine/reports/tool_access.rb
566
567
  - app/models/think_feel_do_engine/reports/tool_module.rb
567
568
  - app/models/think_feel_do_engine/reports/user_agent.rb
568
569
  - app/models/think_feel_do_engine/reports/video_session.rb
569
570
  - app/models/think_feel_do_engine/reports/wai_assessment.rb
571
+ - app/models/think_feel_do_engine/sms_delivery_error.rb
570
572
  - app/models/thought.rb
571
573
  - app/models/thought_pattern.rb
572
574
  - app/models/tool_nav_item.rb
@@ -965,6 +967,7 @@ files:
965
967
  - db/migrate/20160516143322_remove_experience.rb
966
968
  - db/migrate/20160616162347_convert_slide_options.rb
967
969
  - db/migrate/20160616201120_convert_event_payloads.rb
970
+ - db/migrate/20160712153753_create_think_feel_do_engine_sms_delivery_errors.rb
968
971
  - lib/tasks/lesson_notifications.rake
969
972
  - lib/tasks/seed.rake
970
973
  - lib/tasks/think_feel_do_engine_tasks.rake