tolliver 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e7ab72e7ba150c2828de6e3f3defebf06f50bbf09495b9f3bafcc32d4858cf0
4
- data.tar.gz: 4dd7b0a65c105f2f11fcf336675a515d41cac6cc278580fd24951891073b60dc
3
+ metadata.gz: 1c0fa6672c057ce36fec360bddd1f1a7360dcdecb6198678838a6150978a8b12
4
+ data.tar.gz: 13ddc4dba78f936159bc825f4cee588d66941a9ff296d5fe0abd70b6ae02cbf0
5
5
  SHA512:
6
- metadata.gz: 4c538087c0161c0968e4f2f4fa31c8ce6ad1a54ea1ee0b924b851f81aa537ed631c839cadb0e258b86a5ba24dee3affa2b5b6dc46983c1f5d16960b91cf562a4
7
- data.tar.gz: 05fa597679610a2694f6397992040c4463b9bb9d9458e7f1193431e302c7e2446c67c096838273b5c4fcc42e714f0d53a61d0612abc3a114e6f1ab1b6af06eab
6
+ metadata.gz: 4e2ddef5141f52daf5bdfb4d648c2420dad063f2ba1fd06d2753eca7f8e56e66184bfa72a60124ab7203e0821119796a398508df86a555d9fa2d7f77ac289736
7
+ data.tar.gz: 23a5b86b0b8daac5a8f334e3d2bf53fb42b380fda433550c4742216d7631cd408920436467d85224d07c872b8fb3cb80f7db62d2d1403338e99456d6f4d73372
data/README.md CHANGED
@@ -7,7 +7,7 @@ send it in a batch with different delivery methods:
7
7
  - SMS with Plivo provider
8
8
  - Whatever custom delivery method
9
9
 
10
- ## Installation
10
+ ## 1. Installation
11
11
 
12
12
  Add gem to your Gemfile:
13
13
 
@@ -20,7 +20,7 @@ Add database migrations to you application (you can modify DB structure accordin
20
20
  $ rake tolliver:install:migrations
21
21
  $ rake db:migrate
22
22
 
23
- ### Plivo support
23
+ ### 1.1. Plivo support
24
24
 
25
25
  Add gem to your Gemfile:
26
26
 
@@ -28,7 +28,7 @@ Add gem to your Gemfile:
28
28
  gem 'plivo'
29
29
  ```
30
30
 
31
- ### Mailgun support
31
+ ### 1.2. Mailgun support
32
32
 
33
33
  Add gem to your Gemfile:
34
34
 
@@ -36,7 +36,7 @@ Add gem to your Gemfile:
36
36
  gem 'mailgun-ruby'
37
37
  ```
38
38
 
39
- ## Configuration
39
+ ## 2. Configuration
40
40
 
41
41
  You can configure module through `config/initializers/tolliver.rb` file:
42
42
 
@@ -65,7 +65,7 @@ Available options:
65
65
  - sms_provider_params
66
66
  - delivery_methods
67
67
 
68
- ### Plivo support
68
+ ### 2.1. Plivo support
69
69
 
70
70
  Set Plivo as SMS provider and add Plivo auth ID and token into Tolliver configuration file:
71
71
 
@@ -80,7 +80,7 @@ Tolliver.setup do |config|
80
80
  end
81
81
  ```
82
82
 
83
- ### Mailgun support
83
+ ### 2.2. Mailgun support
84
84
 
85
85
  Set Mailgun as e-mail provider and add Mailgun API key and domain into Tolliver configuration file:
86
86
 
@@ -95,7 +95,7 @@ Tolliver.setup do |config|
95
95
  end
96
96
  ```
97
97
 
98
- ## Usage
98
+ ## 3. Usage
99
99
 
100
100
  To enter new notification into the system, just call `notify` method:
101
101
 
@@ -107,8 +107,8 @@ Tolliver.notify(
107
107
  {key: :key_2, value: :value_2}
108
108
  ],
109
109
  receivers: [
110
- {ref: :receiver_1, contact: "receiver_1@domain.tld"},
111
- {ref: :receiver_2, contact: "receiver_2@domain.tld"},
110
+ {ref: :receiver_1, email: "receiver_1@domain.tld"},
111
+ {ref: :receiver_2, email: "receiver_2@domain.tld"},
112
112
  ]
113
113
  )
114
114
  ```
@@ -0,0 +1,6 @@
1
+ class AddNotificationAttachmentsUrl < ActiveRecord::Migration[6.0]
2
+ def change
3
+ change_column :notification_attachments, :attachment, :text
4
+ add_column :notification_attachments, :url, :string
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ class AddShortMessageAndPhone < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :notification_templates, :short_message, :string
4
+ add_column :notifications, :short_message, :string
5
+
6
+ rename_column :notification_deliveries, :sender_contact, :sender_email
7
+ add_column :notification_deliveries, :sender_phone, :string
8
+
9
+ rename_column :notification_receivers, :receiver_contact, :receiver_email
10
+ add_column :notification_receivers, :receiver_phone, :string
11
+ end
12
+ end
data/lib/tolliver.rb CHANGED
@@ -20,8 +20,8 @@ require "tolliver/models/notification_receiver"
20
20
  require "tolliver/models/notification_template"
21
21
 
22
22
  # Services
23
- require "tolliver/services/notification"
24
- require "tolliver/services/delivery"
23
+ require "tolliver/services/notification_service"
24
+ require "tolliver/services/delivery_service"
25
25
  require "tolliver/services/policies/batch"
26
26
  require "tolliver/services/policies/instantly"
27
27
  require "tolliver/services/methods/email"
@@ -30,6 +30,10 @@ require "tolliver/services/methods/email/mailgun"
30
30
  require "tolliver/services/methods/sms"
31
31
  require "tolliver/services/methods/sms/plivo"
32
32
 
33
+ # Jobs
34
+ require "tolliver/jobs/delivery_job"
35
+ require "tolliver/jobs/batch_policy_job"
36
+
33
37
  # Mailers
34
38
  require "tolliver/mailers/notification_mailer"
35
39
 
@@ -52,19 +56,19 @@ module Tolliver
52
56
  # *************************************************************************
53
57
 
54
58
  def self.notify(options)
55
- Tolliver::Services::Notification.instance.notify(options)
59
+ Tolliver::Services::NotificationService.instance.notify(options)
56
60
  end
57
61
 
58
62
  def self.deliver(notification)
59
- Tolliver::Services::Delivery.instance.deliver(notification)
63
+ Tolliver::Services::DeliveryService.instance.deliver(notification)
60
64
  end
61
65
 
62
66
  def self.enqueue_for_delivery(notification)
63
- Tolliver::Services::Delivery.instance.enqueue_for_delivery(notification)
67
+ Tolliver::Services::DeliveryService.instance.enqueue_for_delivery(notification)
64
68
  end
65
69
 
66
70
  def self.reset_delivery(notification)
67
- Tolliver::Services::Delivery.instance.reset_delivery(notification)
71
+ Tolliver::Services::DeliveryService.instance.reset_delivery(notification)
68
72
  end
69
73
 
70
74
  # *************************************************************************
@@ -0,0 +1,19 @@
1
+ module Tolliver
2
+ module Jobs
3
+ class BatchPolicyJob < ActiveJob::Base
4
+ queue_as :default
5
+
6
+ def perform(notification_delivery_id, batch_size)
7
+
8
+ # Instantiate notification delivery object
9
+ notification_delivery = Tolliver.notification_delivery_model.find_by_id(notification_delivery_id)
10
+ return nil if notification_delivery.nil? || notification_delivery.policy != :batch
11
+
12
+ # Call policy logic
13
+ policy_service = Tolliver::Services::Policies::Batch.new
14
+ policy_service.deliver_batch_and_enqueue(notification_delivery, batch_size)
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module Tolliver
2
+ module Jobs
3
+ class DeliveryJob < ActiveJob::Base
4
+ queue_as :default
5
+
6
+ def perform(notification_id)
7
+
8
+ # Instantiate notification object
9
+ notification = Tolliver.notification_model.find_by_id(notification_id)
10
+ return nil if notification.nil?
11
+
12
+ # Call standard API
13
+ Tolliver::Services::DeliveryService.instance.deliver(notification)
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -29,11 +29,11 @@ module Tolliver
29
29
 
30
30
  # Attachments
31
31
  notification.notification_attachments.each do |notification_attachment|
32
- attachments[notification_attachment.name] = notification_attachment.attachment
32
+ attachments[notification_attachment.name] = notification_attachment.read if notification_attachment.read
33
33
  end
34
34
 
35
35
  # Mail
36
- mail(from: @sender_email, to: @notification_receiver.receiver_contact.to_s, subject: @notification.subject)
36
+ mail(from: @sender_email, to: @notification_receiver.receiver_email.to_s, subject: @notification.subject)
37
37
  end
38
38
 
39
39
  end
@@ -52,15 +52,15 @@ module Tolliver
52
52
  # ***********************************************************************
53
53
 
54
54
  def deliver
55
- Tolliver::Services::Delivery.instance.deliver(self)
55
+ Tolliver::Services::DeliveryService.instance.deliver(self)
56
56
  end
57
57
 
58
58
  def enqueue_for_delivery
59
- Tolliver::Services::Delivery.instance.enqueue_for_delivery(self)
59
+ Tolliver::Services::DeliveryService.instance.enqueue_for_delivery(self)
60
60
  end
61
61
 
62
62
  def reset_delivery
63
- Tolliver::Services::Delivery.instance.reset_delivery(self)
63
+ Tolliver::Services::DeliveryService.instance.reset_delivery(self)
64
64
  end
65
65
 
66
66
  end
@@ -30,6 +30,18 @@ module Tolliver
30
30
 
31
31
  end
32
32
 
33
+ def read
34
+ if @data.nil?
35
+ unless self.attachment.blank?
36
+ @data = Base64.strict_decode64(self.attachment) rescue nil
37
+ end
38
+ unless self.url.blank?
39
+ @data = open(self.url) { |f| f.read }
40
+ end
41
+ end
42
+ @data
43
+ end
44
+
33
45
  end
34
46
  end
35
47
  end
@@ -26,7 +26,7 @@ module Tolliver
26
26
  # Validators
27
27
  # *********************************************************************
28
28
 
29
- validates_presence_of :notification_delivery_id, :receiver_ref, :receiver_contact
29
+ validates_presence_of :notification_delivery_id, :receiver_ref
30
30
 
31
31
  # *********************************************************************
32
32
  # State
@@ -13,23 +13,12 @@ require 'singleton'
13
13
 
14
14
  module Tolliver
15
15
  module Services
16
- class Delivery
16
+ class DeliveryService
17
17
  include Singleton
18
18
 
19
19
  def enqueue_for_delivery(notification)
20
20
  return nil if notification.nil?
21
- QC.enqueue("#{self.class.to_s}.deliver", notification.id)
22
- end
23
-
24
- # Entry point for QC
25
- def self.deliver(notification_id)
26
-
27
- # Instantiate notification object
28
- notification = Tolliver.notification_model.find_by_id(notification_id)
29
- return nil if notification.nil?
30
-
31
- # Call standard API
32
- self.instance.deliver(notification)
21
+ Tolliver::Jobs::DeliveryJob.perform_later(notification.id)
33
22
  end
34
23
 
35
24
  # Deliver notification to receivers by all configured methods
@@ -14,6 +14,23 @@ module Tolliver
14
14
  module Methods
15
15
  class Email
16
16
 
17
+ def is_notification_valid?(notification)
18
+ return false if notification.subject.blank?
19
+ return false if notification.message.blank?
20
+ true
21
+ end
22
+
23
+ def is_notification_delivery_valid?(notification_delivery)
24
+ return false if !notification_delivery.sender_email.blank? && !(notification_delivery.sender_email =~ URI::MailTo::EMAIL_REGEXP)
25
+ true
26
+ end
27
+
28
+ def is_notification_receiver_valid?(notification_receiver)
29
+ return false if notification_receiver.receiver_email.blank?
30
+ return false unless notification_receiver.receiver_email =~ URI::MailTo::EMAIL_REGEXP
31
+ true
32
+ end
33
+
17
34
  def deliver(notification_receiver)
18
35
  return false if provider.nil?
19
36
 
@@ -29,17 +29,19 @@ module Tolliver
29
29
  # Sender
30
30
  raise Tolliver::Errors::StandardError.new("Please specify e-mail sender.") if Tolliver.email_sender.nil?
31
31
 
32
- # Message builder
32
+ # Build message
33
33
  message = ::Mailgun::MessageBuilder.new
34
34
  message.from(Tolliver.email_sender, {'full_name' => Tolliver.email_sender_name})
35
- message.add_recipient(:to, notification_receiver.receiver_contact.to_s)
36
- message.reply_to(notification_receiver.notification_delivery.sender_contact.to_s) unless notification_receiver.notification_delivery.sender_contact.blank?
35
+ message.add_recipient(:to, notification_receiver.receiver_email.to_s)
36
+ message.reply_to(notification_receiver.notification_delivery.sender_email.to_s) unless notification_receiver.notification_delivery.sender_email.blank?
37
37
  message.subject(notification.subject)
38
38
  message.body_text(ActionController::Base.helpers.strip_tags(notification.message.to_s))
39
39
  message.body_html(notification.message)
40
40
  notification.notification_attachments.each do |notification_attachment|
41
- message.add_attachment(StringIO.new(notification_attachment.attachment), notification_attachment.name)
41
+ message.add_attachment(StringIO.new(notification_attachment.read), notification_attachment.name) if notification_attachment.read
42
42
  end
43
+
44
+ # Request API
43
45
  response = @client.send_message(@domain, message)
44
46
  if response.code != 200
45
47
  raise Tolliver::Errors::StandardError.new(response.body)
@@ -14,6 +14,20 @@ module Tolliver
14
14
  module Methods
15
15
  class Sms
16
16
 
17
+ def is_notification_valid?(notification)
18
+ return false if notification.short_message.blank?
19
+ true
20
+ end
21
+
22
+ def is_notification_delivery_valid?(_)
23
+ true
24
+ end
25
+
26
+ def is_notification_receiver_valid?(notification_receiver)
27
+ return false if notification_receiver.receiver_phone.blank?
28
+ true
29
+ end
30
+
17
31
  def deliver(notification_receiver)
18
32
  return false if provider.nil?
19
33
 
@@ -22,23 +22,18 @@ module Tolliver
22
22
  end
23
23
  @auth_id = params[:auth_id]
24
24
  @auth_token = params[:auth_token]
25
- @api = ::Plivo::RestAPI.new(@auth_id, @auth_token)
25
+ @client = ::Plivo::RestClient.new(@auth_id, @auth_token)
26
26
  end
27
27
 
28
28
  def deliver(notification, notification_receiver)
29
29
 
30
- # Check message length.
31
- if message.bytesize > 200
32
- raise 'Message too long.'
33
- end
30
+ # Sender
31
+ raise Tolliver::Errors::StandardError.new("Please specify SMS sender.") if Tolliver.sms_sender.nil?
34
32
 
35
33
  # Request API
36
- response = @api.send_message({
37
- 'src' => Tolliver.sms_sender, # TODO: This should be improved to take sender from number pool and remember number / message mapping
38
- 'dst' => notification_receiver.receiver_contact.to_s,
39
- 'text' => ActionController::Base.helpers.strip_tags(notification.message.to_s),
40
- 'method' => 'POST'
41
- })
34
+ @client.message.create(Tolliver.sms_sender, # TODO: This should be improved to take sender from number pool and remember number / message mapping
35
+ [notification_receiver.receiver_phone.to_s],
36
+ ActionController::Base.helpers.strip_tags(notification.short_message.to_s))
42
37
 
43
38
  true
44
39
  end
@@ -13,7 +13,7 @@ require 'singleton'
13
13
 
14
14
  module Tolliver
15
15
  module Services
16
- class Notification
16
+ class NotificationService
17
17
  include Singleton
18
18
 
19
19
  def notify(options)
@@ -29,17 +29,23 @@ module Tolliver
29
29
  raise Tolliver::Errors::BadRequest.new('Missing template.') if template.blank?
30
30
  notification_template = Tolliver.notification_template_model.where(ref: template).first
31
31
  notification_template = Tolliver.notification_template_model.where(id: template).first if notification_template.nil?
32
+ if notification_template.nil? && template.to_s == 'common'
33
+ notification_template = Tolliver.notification_template_model.new(subject: '%{subject}',
34
+ message: '%{message}', short_message: '%{message}',
35
+ is_disabled: false, is_dry: false)
36
+ end
32
37
  raise Tolliver::Errors::NotFound.new("Template #{template.to_s} not found.") if notification_template.nil?
33
38
 
34
- if !notification_template.is_disabled && !notification_template.message.blank?
39
+ if !notification_template.is_disabled
35
40
 
36
41
  # Interpret params and store it in DB
37
42
  params = map_params(options[:params] || {})
38
- notification.message = interpret_named_params(notification_template.message, params)
39
- notification.subject = interpret_named_params(notification_template.subject, params)
43
+ notification.subject = eval_expressions(interpret_named_params(notification_template.subject.to_s, params))
44
+ notification.message = eval_expressions(interpret_named_params(notification_template.message.to_s, params))
45
+ notification.short_message = eval_expressions(interpret_named_params(notification_template.short_message.to_s, params))
40
46
 
41
47
  # Notification template
42
- notification.notification_template = notification_template
48
+ notification.notification_template = notification_template unless notification_template.new_record?
43
49
 
44
50
  # Signature
45
51
  unless options[:signature].blank?
@@ -55,8 +61,10 @@ module Tolliver
55
61
  attachments = [attachments] unless attachments.is_a?(Array)
56
62
  attachments.each do |attachment|
57
63
  raise Tolliver::Errors::BadRequest.new('Missing attachment name.') if attachment[:name].blank?
58
- raise Tolliver::Errors::BadRequest.new('Missing attachment data.') if attachment[:attachment].blank?
59
- notification.notification_attachments.create(name: attachment[:name], attachment: attachment[:attachment])
64
+ if attachment[:attachment].blank? && attachment[:url].blank?
65
+ raise Tolliver::Errors::BadRequest.new('Missing attachment data or URL.')
66
+ end
67
+ notification.notification_attachments.create(name: attachment[:name], attachment: attachment[:attachment], url: attachment[:url])
60
68
  end
61
69
  end
62
70
 
@@ -75,7 +83,10 @@ module Tolliver
75
83
  methods.each do |method|
76
84
 
77
85
  # Delivery object
78
- notification_delivery = notification.notification_deliveries.create(method: method)
86
+ notification_delivery = notification.notification_deliveries.build(method: method)
87
+
88
+ # Validate notification suitability for the selected method
89
+ next unless notification_delivery.method_service.is_notification_valid?(notification)
79
90
 
80
91
  # Is postponed
81
92
  if options[:is_postponed]
@@ -84,26 +95,38 @@ module Tolliver
84
95
 
85
96
  # Sender
86
97
  unless options[:sender].blank?
87
- raise Tolliver::Errors::BadRequest.new('Missing sender ref.') if options[:sender][:ref].blank?
88
- raise Tolliver::Errors::BadRequest.new('Missing sender contact.') if options[:sender][:contact].blank?
89
98
  notification_delivery.sender_ref = options[:sender][:ref]
90
- notification_delivery.sender_contact = options[:sender][:contact]
99
+ notification_delivery.sender_email = options[:sender][:email]
100
+ notification_delivery.sender_phone = options[:sender][:phone]
101
+ raise Tolliver::Errors::BadRequest.new('Missing sender ref.') if notification_delivery.sender_ref.blank?
102
+ unless notification_delivery.method_service.is_notification_delivery_valid?(notification_delivery) # throw exception if sender not valid
103
+ raise Tolliver::Errors::BadRequest.new('Sender contact not valid.')
104
+ end
91
105
  end
92
106
 
107
+ # Must be persisted in DB before receiver created
108
+ notification_delivery.save
109
+
93
110
  # Receivers
94
111
  receivers = options[:receivers] || []
95
112
  raise Tolliver::Errors::BadRequest.new('Missing receivers.') if receivers.blank? || receivers.empty?
96
113
  receivers = [receivers] unless receivers.is_a?(Array)
97
- filtered_receivers = receivers.dup # TODO contact validation based on method and filter
98
114
 
99
- # Save to DB
100
- filtered_receivers.each do |receiver|
101
- raise Tolliver::Errors::BadRequest.new('Missing sender ref.') if receiver[:ref].blank?
102
- raise Tolliver::Errors::BadRequest.new('Missing sender contact.') if receiver[:contact].blank?
103
- notification_delivery.notification_receivers.create(receiver_ref: receiver[:ref], receiver_contact: receiver[:contact])
115
+ # Save to DB if valid for the selected method
116
+ receivers_count = 0
117
+ receivers.each do |receiver|
118
+ notification_receiver = notification_delivery.notification_receivers.build
119
+ notification_receiver.receiver_ref = receiver[:ref]
120
+ notification_receiver.receiver_email = receiver[:email]
121
+ notification_receiver.receiver_phone = receiver[:phone]
122
+ raise Tolliver::Errors::BadRequest.new('Missing receiver ref.') if notification_receiver.receiver_ref.blank?
123
+ if notification_delivery.method_service.is_notification_receiver_valid?(notification_receiver) # ignore receiver if not valid
124
+ notification_receiver.save
125
+ receivers_count += 1
126
+ end
104
127
  end
105
128
  notification_delivery.sent_count = 0
106
- notification_delivery.receivers_count = filtered_receivers.size
129
+ notification_delivery.receivers_count = receivers_count
107
130
  notification_delivery.save
108
131
 
109
132
  end
@@ -111,7 +134,7 @@ module Tolliver
111
134
  end
112
135
 
113
136
  else
114
- notification = nil # Do not create notification with empty message
137
+ notification = nil # Do not create disabled notification
115
138
  end
116
139
 
117
140
  end
@@ -147,7 +170,19 @@ module Tolliver
147
170
  end
148
171
  end
149
172
 
150
- def interpret_positional_params(text, params)
173
+ def eval_expressions(text)
174
+ text.gsub(/%{[^{}]+}/) do |match|
175
+ template_to_eval = match[2..-2].to_s.strip
176
+ begin
177
+ evaluated_match = eval(template_to_eval) # evaluate match
178
+ rescue
179
+ evaluated_match = ""
180
+ end
181
+ evaluated_match
182
+ end
183
+ end
184
+
185
+ def interpret_positional_params_and_eval_expressions(text, params)
151
186
  text.gsub(/%{[^{}]+}/) do |match|
152
187
  template_to_eval = match[2..-2].gsub(/%([0-9]+)/, "params[\\1]") # substitute all %1, %2, %3, ... to a form which can be evaluated
153
188
  begin
@@ -19,26 +19,15 @@ module Tolliver
19
19
  # Input validation
20
20
  return nil if notification_delivery.nil? || notification_delivery.policy != :batch
21
21
 
22
- # Enqueue in QC
23
- QC.enqueue("#{self.class.to_s}.deliver", notification_delivery.id, batch_size)
22
+ # Enqueue
23
+ Tolliver::Jobs::BatchPolicyJob.perform_later(notification_delivery.id, batch_size)
24
24
  end
25
25
 
26
- # Entry point for QC
27
- def self.deliver(notification_delivery_id, batch_size = 10)
26
+ def deliver_batch_and_enqueue(notification_delivery, batch_size = 10)
28
27
 
29
- # Instantiate notification delivery object
30
- notification_delivery = Tolliver.notification_delivery_model.find_by_id(notification_delivery_id)
28
+ # Input validation
31
29
  return nil if notification_delivery.nil? || notification_delivery.policy != :batch
32
30
 
33
- # Call internal logic
34
- policy_service = self.new
35
- policy_service.send(:deliver_batch_and_enqueue, notification_delivery, batch_size)
36
- end
37
-
38
- protected
39
-
40
- def deliver_batch_and_enqueue(notification_delivery, batch_size = 10)
41
-
42
31
  # Send single batch
43
32
  remaining = deliver_batch(notification_delivery, batch_size)
44
33
 
@@ -59,6 +48,9 @@ module Tolliver
59
48
 
60
49
  def deliver_batch(notification_delivery, batch_size = 10)
61
50
 
51
+ # Input validation
52
+ return nil if notification_delivery.nil? || notification_delivery.policy != :batch
53
+
62
54
  # Nothing to do
63
55
  return 0 if notification_delivery.sent_count == notification_delivery.receivers_count
64
56
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tolliver
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matěj Outlý
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2021-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -50,24 +50,28 @@ files:
50
50
  - db/migrate/20160509144238_create_notification_templates.rb
51
51
  - db/migrate/20170630190600_create_notification_deliveries.rb
52
52
  - db/migrate/20201027150000_create_notification_attachments.rb
53
+ - db/migrate/20210415120000_add_notification_attachments_url.rb
54
+ - db/migrate/20210528120000_add_short_message_and_phone.rb
53
55
  - lib/tolliver.rb
54
56
  - lib/tolliver/engine.rb
55
57
  - lib/tolliver/errors/bad_request.rb
56
58
  - lib/tolliver/errors/not_found.rb
57
59
  - lib/tolliver/errors/standard_error.rb
60
+ - lib/tolliver/jobs/batch_policy_job.rb
61
+ - lib/tolliver/jobs/delivery_job.rb
58
62
  - lib/tolliver/mailers/notification_mailer.rb
59
63
  - lib/tolliver/models/notification.rb
60
64
  - lib/tolliver/models/notification_attachment.rb
61
65
  - lib/tolliver/models/notification_delivery.rb
62
66
  - lib/tolliver/models/notification_receiver.rb
63
67
  - lib/tolliver/models/notification_template.rb
64
- - lib/tolliver/services/delivery.rb
68
+ - lib/tolliver/services/delivery_service.rb
65
69
  - lib/tolliver/services/methods/email.rb
66
70
  - lib/tolliver/services/methods/email/mailgun.rb
67
71
  - lib/tolliver/services/methods/email/smtp.rb
68
72
  - lib/tolliver/services/methods/sms.rb
69
73
  - lib/tolliver/services/methods/sms/plivo.rb
70
- - lib/tolliver/services/notification.rb
74
+ - lib/tolliver/services/notification_service.rb
71
75
  - lib/tolliver/services/policies/batch.rb
72
76
  - lib/tolliver/services/policies/instantly.rb
73
77
  - lib/tolliver/utils/enum.rb