noticed 1.6.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +122 -147
  3. data/app/jobs/noticed/application_job.rb +9 -0
  4. data/app/jobs/noticed/event_job.rb +19 -0
  5. data/app/models/concerns/noticed/deliverable.rb +115 -0
  6. data/app/models/concerns/noticed/notification_methods.rb +17 -0
  7. data/app/models/concerns/noticed/readable.rb +62 -0
  8. data/app/models/noticed/application_record.rb +6 -0
  9. data/app/models/noticed/deliverable/deliver_by.rb +43 -0
  10. data/app/models/noticed/event.rb +15 -0
  11. data/app/models/noticed/notification.rb +16 -0
  12. data/db/migrate/20231215190233_create_noticed_tables.rb +25 -0
  13. data/lib/generators/noticed/delivery_method_generator.rb +1 -1
  14. data/lib/generators/noticed/install_generator.rb +19 -0
  15. data/lib/generators/noticed/{notification_generator.rb → notifier_generator.rb} +2 -2
  16. data/lib/generators/noticed/templates/README +5 -4
  17. data/lib/generators/noticed/templates/notifier.rb.tt +24 -0
  18. data/lib/noticed/api_client.rb +44 -0
  19. data/lib/noticed/bulk_delivery_method.rb +46 -0
  20. data/lib/noticed/bulk_delivery_methods/discord.rb +11 -0
  21. data/lib/noticed/bulk_delivery_methods/slack.rb +17 -0
  22. data/lib/noticed/bulk_delivery_methods/webhook.rb +18 -0
  23. data/lib/noticed/coder.rb +2 -0
  24. data/lib/noticed/delivery_method.rb +50 -0
  25. data/lib/noticed/delivery_methods/action_cable.rb +7 -39
  26. data/lib/noticed/delivery_methods/discord.rb +11 -0
  27. data/lib/noticed/delivery_methods/email.rb +9 -45
  28. data/lib/noticed/delivery_methods/fcm.rb +23 -64
  29. data/lib/noticed/delivery_methods/ios.rb +25 -112
  30. data/lib/noticed/delivery_methods/microsoft_teams.rb +5 -22
  31. data/lib/noticed/delivery_methods/slack.rb +6 -16
  32. data/lib/noticed/delivery_methods/test.rb +2 -12
  33. data/lib/noticed/delivery_methods/twilio_messaging.rb +37 -0
  34. data/lib/noticed/delivery_methods/vonage_sms.rb +20 -0
  35. data/lib/noticed/delivery_methods/webhook.rb +17 -0
  36. data/lib/noticed/engine.rb +1 -9
  37. data/lib/noticed/required_options.rb +21 -0
  38. data/lib/noticed/translation.rb +7 -3
  39. data/lib/noticed/version.rb +1 -1
  40. data/lib/noticed.rb +30 -15
  41. metadata +29 -40
  42. data/lib/generators/noticed/model/base_generator.rb +0 -47
  43. data/lib/generators/noticed/model/mysql_generator.rb +0 -18
  44. data/lib/generators/noticed/model/postgresql_generator.rb +0 -18
  45. data/lib/generators/noticed/model/sqlite3_generator.rb +0 -18
  46. data/lib/generators/noticed/model_generator.rb +0 -63
  47. data/lib/generators/noticed/templates/notification.rb.tt +0 -27
  48. data/lib/noticed/base.rb +0 -160
  49. data/lib/noticed/delivery_methods/base.rb +0 -95
  50. data/lib/noticed/delivery_methods/database.rb +0 -34
  51. data/lib/noticed/delivery_methods/twilio.rb +0 -51
  52. data/lib/noticed/delivery_methods/vonage.rb +0 -40
  53. data/lib/noticed/has_notifications.rb +0 -49
  54. data/lib/noticed/model.rb +0 -85
  55. data/lib/noticed/notification_channel.rb +0 -15
  56. data/lib/noticed/text_coder.rb +0 -16
  57. data/lib/rails_6_polyfills/actioncable/test_adapter.rb +0 -70
  58. data/lib/rails_6_polyfills/actioncable/test_helper.rb +0 -143
  59. data/lib/rails_6_polyfills/activejob/serializers.rb +0 -240
  60. data/lib/rails_6_polyfills/base.rb +0 -18
  61. data/lib/tasks/noticed_tasks.rake +0 -4
@@ -2,26 +2,24 @@ require "apnotic"
2
2
 
3
3
  module Noticed
4
4
  module DeliveryMethods
5
- class Ios < Base
6
- cattr_accessor :connection_pool
5
+ class Ios < DeliveryMethod
6
+ cattr_accessor :development_connection_pool, :production_connection_pool
7
+
8
+ required_options :bundle_identifier, :key_id, :team_id, :apns_key, :device_tokens
7
9
 
8
10
  def deliver
9
- raise ArgumentError, "bundle_identifier is missing" if bundle_identifier.blank?
10
- raise ArgumentError, "key_id is missing" if key_id.blank?
11
- raise ArgumentError, "team_id is missing" if team_id.blank?
12
- raise ArgumentError, "Could not find APN cert at '#{cert_path}'" unless valid_cert_path?
11
+ evaluate_option(:device_tokens).each do |device_token|
12
+ apn = Apnotic::Notification.new(device_token)
13
+ format_notification(apn)
13
14
 
14
- device_tokens.each do |device_token|
15
+ connection_pool = (!!evaluate_option(:development)) ? development_pool : production_pool
15
16
  connection_pool.with do |connection|
16
- apn = Apnotic::Notification.new(device_token)
17
- format_notification(apn)
18
-
19
17
  response = connection.push(apn)
20
18
  raise "Timeout sending iOS push notification" unless response
21
19
 
22
- if bad_token?(response)
20
+ if bad_token?(response) && config[:invalid_token]
23
21
  # Allow notification to cleanup invalid iOS device tokens
24
- cleanup_invalid_token(device_token)
22
+ notification.instance_exec(device_token, &config[:invalid_token])
25
23
  elsif !response.ok?
26
24
  raise "Request failed #{response.body}"
27
25
  end
@@ -32,53 +30,37 @@ module Noticed
32
30
  private
33
31
 
34
32
  def format_notification(apn)
35
- apn.topic = bundle_identifier
33
+ apn.topic = evaluate_option(:bundle_identifier)
36
34
 
37
- if (method = options[:format])
38
- notification.send(method, apn)
39
- elsif params[:message].present?
40
- apn.alert = params[:message]
35
+ if (method = config[:format])
36
+ notification.instance_exec(apn, &method)
37
+ elsif notification.params.try(:has_key?, :message)
38
+ apn.alert = notification.params[:message]
41
39
  else
42
40
  raise ArgumentError, "No message for iOS delivery. Either include message in params or add the 'format' option in 'deliver_by :ios'."
43
41
  end
44
42
  end
45
43
 
46
- def device_tokens
47
- if notification.respond_to?(:ios_device_tokens)
48
- Array.wrap(notification.ios_device_tokens(recipient))
49
- else
50
- raise NoMethodError, <<~MESSAGE
51
- You must implement `ios_device_tokens` to send iOS notifications
52
-
53
- # This must return an Array of iOS device tokens
54
- def ios_device_tokens(recipient)
55
- recipient.ios_device_tokens.pluck(:token)
56
- end
57
- MESSAGE
58
- end
59
- end
60
-
61
44
  def bad_token?(response)
62
45
  response.status == "410" || (response.status == "400" && response.body["reason"] == "BadDeviceToken")
63
46
  end
64
47
 
65
- def cleanup_invalid_token(token)
66
- return unless notification.respond_to?(:cleanup_device_token)
67
- notification.send(:cleanup_device_token, token: token, platform: "iOS")
48
+ def development_pool
49
+ self.class.development_connection_pool ||= new_connection_pool(development: true)
68
50
  end
69
51
 
70
- def connection_pool
71
- self.class.connection_pool ||= new_connection_pool
52
+ def production_pool
53
+ self.class.production_connection_pool ||= new_connection_pool(development: false)
72
54
  end
73
55
 
74
- def new_connection_pool
56
+ def new_connection_pool(development:)
75
57
  handler = proc do |connection|
76
58
  connection.on(:error) do |exception|
77
59
  Rails.logger.info "Apnotic exception raised: #{exception}"
78
60
  end
79
61
  end
80
62
 
81
- if development?
63
+ if development
82
64
  Apnotic::ConnectionPool.development(connection_pool_options, pool_options, &handler)
83
65
  else
84
66
  Apnotic::ConnectionPool.new(connection_pool_options, pool_options, &handler)
@@ -88,83 +70,14 @@ module Noticed
88
70
  def connection_pool_options
89
71
  {
90
72
  auth_method: :token,
91
- cert_path: cert_path,
92
- key_id: key_id,
93
- team_id: team_id
73
+ cert_path: StringIO.new(config.fetch(:apns_key)),
74
+ key_id: config.fetch(:key_id),
75
+ team_id: config.fetch(:team_id)
94
76
  }
95
77
  end
96
78
 
97
- def bundle_identifier
98
- option = options[:bundle_identifier]
99
- case option
100
- when String
101
- option
102
- when Symbol
103
- notification.send(option)
104
- else
105
- Rails.application.credentials.dig(:ios, :bundle_identifier)
106
- end
107
- end
108
-
109
- def cert_path
110
- option = options[:cert_path]
111
- case option
112
- when String
113
- option
114
- when Symbol
115
- notification.send(option)
116
- else
117
- Rails.root.join("config/certs/ios/apns.p8")
118
- end
119
- end
120
-
121
- def key_id
122
- option = options[:key_id]
123
- case option
124
- when String
125
- option
126
- when Symbol
127
- notification.send(option)
128
- else
129
- Rails.application.credentials.dig(:ios, :key_id)
130
- end
131
- end
132
-
133
- def team_id
134
- option = options[:team_id]
135
- case option
136
- when String
137
- option
138
- when Symbol
139
- notification.send(option)
140
- else
141
- Rails.application.credentials.dig(:ios, :team_id)
142
- end
143
- end
144
-
145
- def development?
146
- option = options[:development]
147
- case option
148
- when Symbol
149
- !!notification.send(option)
150
- else
151
- !!option
152
- end
153
- end
154
-
155
- def valid_cert_path?
156
- case cert_path
157
- when File, StringIO
158
- cert_path.size > 0
159
- else
160
- File.exist?(cert_path)
161
- end
162
- end
163
-
164
79
  def pool_options
165
- {
166
- size: options.fetch(:pool_size, 5)
167
- }
80
+ {size: evaluate_option(:pool_size) || 5}
168
81
  end
169
82
  end
170
83
  end
@@ -1,31 +1,14 @@
1
1
  module Noticed
2
2
  module DeliveryMethods
3
- class MicrosoftTeams < Base
4
- def deliver
5
- post(url, json: format)
6
- end
3
+ class MicrosoftTeams < DeliveryMethod
4
+ required_options :json
7
5
 
8
- private
9
-
10
- def format
11
- if (method = options[:format])
12
- notification.send(method)
13
- else
14
- {
15
- title: notification.params[:title],
16
- text: notification.params[:text],
17
- sections: notification.params[:sections],
18
- potentialAction: notification.params[:notification_action]
19
- }
20
- end
6
+ def deliver
7
+ post_request url, headers: evaluate_option(:headers), json: evaluate_option(:json)
21
8
  end
22
9
 
23
10
  def url
24
- if (method = options[:url])
25
- notification.send(method)
26
- else
27
- Rails.application.credentials.microsoft_teams[:notification_url]
28
- end
11
+ evaluate_option(:url) || Rails.application.credentials.dig(:microsoft_teams, :notification_url)
29
12
  end
30
13
  end
31
14
  end
@@ -1,26 +1,16 @@
1
1
  module Noticed
2
2
  module DeliveryMethods
3
- class Slack < Base
4
- def deliver
5
- post(url, json: format)
6
- end
3
+ class Slack < DeliveryMethod
4
+ DEFAULT_URL = "https://slack.com/api/chat.postMessage"
7
5
 
8
- private
6
+ required_options :json
9
7
 
10
- def format
11
- if (method = options[:format])
12
- notification.send(method)
13
- else
14
- notification.params
15
- end
8
+ def deliver
9
+ post_request url, headers: evaluate_option(:headers), json: evaluate_option(:json)
16
10
  end
17
11
 
18
12
  def url
19
- if (method = options[:url])
20
- notification.send(method)
21
- else
22
- Rails.application.credentials.slack[:notification_url]
23
- end
13
+ evaluate_option(:url) || DEFAULT_URL
24
14
  end
25
15
  end
26
16
  end
@@ -1,20 +1,10 @@
1
1
  module Noticed
2
2
  module DeliveryMethods
3
- class Test < Base
3
+ class Test < DeliveryMethod
4
4
  class_attribute :delivered, default: []
5
- class_attribute :callbacks, default: []
6
-
7
- after_deliver do
8
- self.class.callbacks << :after
9
- end
10
-
11
- def self.clear!
12
- delivered.clear
13
- callbacks.clear
14
- end
15
5
 
16
6
  def deliver
17
- self.class.delivered << notification
7
+ delivered << notification
18
8
  end
19
9
  end
20
10
  end
@@ -0,0 +1,37 @@
1
+ module Noticed
2
+ module DeliveryMethods
3
+ class TwilioMessaging < DeliveryMethod
4
+ def deliver
5
+ post_request url, basic_auth: {user: account_sid, pass: auth_token}, form: json
6
+ end
7
+
8
+ def json
9
+ evaluate_option(:json) || {
10
+ From: phone_number,
11
+ To: recipient.phone_number,
12
+ Body: params.fetch(:message)
13
+ }
14
+ end
15
+
16
+ def url
17
+ evaluate_option(:url) || "https://api.twilio.com/2010-04-01/Accounts/#{account_sid}/Messages.json"
18
+ end
19
+
20
+ def account_sid
21
+ evaluate_option(:account_sid) || credentials.fetch(:account_sid)
22
+ end
23
+
24
+ def auth_token
25
+ evaluate_option(:auth_token) || credentials.fetch(:auth_token)
26
+ end
27
+
28
+ def phone_number
29
+ evaluate_option(:phone_number) || credentials.fetch(:phone_number)
30
+ end
31
+
32
+ def credentials
33
+ evaluate_option(:credentials) || Rails.application.credentials.twilio
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,20 @@
1
+ module Noticed
2
+ module DeliveryMethods
3
+ class VonageSms < DeliveryMethod
4
+ DEFAULT_URL = "https://rest.nexmo.com/sms/json"
5
+
6
+ required_options :json
7
+
8
+ def deliver
9
+ headers = evaluate_option(:headers)
10
+ json = evaluate_option(:json)
11
+ response = post_request url, headers: headers, json: json
12
+ raise ResponseUnsuccessful.new(response, url, headers: headers, json: json) if JSON.parse(response.body).dig("messages", 0, "status") != "0"
13
+ end
14
+
15
+ def url
16
+ evaluate_option(:url) || DEFAULT_URL
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module Noticed
2
+ module DeliveryMethods
3
+ class Webhook < DeliveryMethod
4
+ required_options :url
5
+
6
+ def deliver
7
+ post_request(
8
+ evaluate_option(:url),
9
+ basic_auth: evaluate_option(:basic_auth),
10
+ headers: evaluate_option(:headers),
11
+ json: evaluate_option(:json),
12
+ form: evaluate_option(:form)
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,13 +1,5 @@
1
1
  module Noticed
2
2
  class Engine < ::Rails::Engine
3
- initializer "noticed.has_notifications" do
4
- ActiveSupport.on_load(:active_record) do
5
- include Noticed::HasNotifications
6
- end
7
- end
8
-
9
- initializer "noticed.rails_5_2_support" do
10
- require "rails_6_polyfills/base" if Rails::VERSION::MAJOR < 6
11
- end
3
+ isolate_namespace Noticed
12
4
  end
13
5
  end
@@ -0,0 +1,21 @@
1
+ module Noticed
2
+ module RequiredOptions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ class_attribute :required_option_names, instance_writer: false, default: []
7
+ end
8
+
9
+ class_methods do
10
+ def inherited(base)
11
+ base.required_option_names = required_option_names.dup
12
+ super
13
+ end
14
+
15
+ def required_options(*names)
16
+ required_option_names.concat names
17
+ end
18
+ alias_method :required_option, :required_options
19
+ end
20
+ end
21
+ end
@@ -4,7 +4,7 @@ module Noticed
4
4
 
5
5
  # Returns the +i18n_scope+ for the class. Overwrite if you want custom lookup.
6
6
  def i18n_scope
7
- :notifications
7
+ :notifiers
8
8
  end
9
9
 
10
10
  def class_scope
@@ -12,13 +12,17 @@ module Noticed
12
12
  end
13
13
 
14
14
  def translate(key, **options)
15
- I18n.translate(scope_translation_key(key), **options)
15
+ if defined?(::ActiveSupport::HtmlSafeTranslation)
16
+ ActiveSupport::HtmlSafeTranslation.translate scope_translation_key(key), **options
17
+ else
18
+ I18n.translate scope_translation_key(key), **options
19
+ end
16
20
  end
17
21
  alias_method :t, :translate
18
22
 
19
23
  def scope_translation_key(key)
20
24
  if key.to_s.start_with?(".")
21
- "#{i18n_scope}.#{class_scope}#{key}"
25
+ [i18n_scope, class_scope].compact.join(".") + key
22
26
  else
23
27
  key
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module Noticed
2
- VERSION = "1.6.3"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/noticed.rb CHANGED
@@ -1,41 +1,56 @@
1
- require "active_job/arguments"
2
- require "http"
1
+ require "noticed/version"
3
2
  require "noticed/engine"
4
3
 
5
4
  module Noticed
6
- autoload :Base, "noticed/base"
5
+ include ActiveSupport::Deprecation::DeprecatedConstantAccessor
6
+
7
+ def self.deprecator # :nodoc:
8
+ @deprecator ||= ActiveSupport::Deprecation.new
9
+ end
10
+
11
+ deprecate_constant :Base, "Noticed::Event", deprecator: deprecator
12
+
13
+ autoload :ApiClient, "noticed/api_client"
14
+ autoload :BulkDeliveryMethod, "noticed/bulk_delivery_method"
7
15
  autoload :Coder, "noticed/coder"
8
- autoload :HasNotifications, "noticed/has_notifications"
9
- autoload :Model, "noticed/model"
10
- autoload :TextCoder, "noticed/text_coder"
16
+ autoload :DeliveryMethod, "noticed/delivery_method"
17
+ autoload :RequiredOptions, "noticed/required_options"
11
18
  autoload :Translation, "noticed/translation"
12
- autoload :NotificationChannel, "noticed/notification_channel"
19
+
20
+ module BulkDeliveryMethods
21
+ autoload :Discord, "noticed/bulk_delivery_methods/discord"
22
+ autoload :Slack, "noticed/bulk_delivery_methods/slack"
23
+ autoload :Webhook, "noticed/bulk_delivery_methods/webhook"
24
+ end
13
25
 
14
26
  module DeliveryMethods
27
+ include ActiveSupport::Deprecation::DeprecatedConstantAccessor
28
+ deprecate_constant :Base, "Noticed::DeliveryMethod", deprecator: Noticed.deprecator
29
+
15
30
  autoload :ActionCable, "noticed/delivery_methods/action_cable"
16
- autoload :Base, "noticed/delivery_methods/base"
17
- autoload :Database, "noticed/delivery_methods/database"
18
31
  autoload :Email, "noticed/delivery_methods/email"
19
32
  autoload :Fcm, "noticed/delivery_methods/fcm"
20
33
  autoload :Ios, "noticed/delivery_methods/ios"
21
34
  autoload :MicrosoftTeams, "noticed/delivery_methods/microsoft_teams"
22
35
  autoload :Slack, "noticed/delivery_methods/slack"
23
36
  autoload :Test, "noticed/delivery_methods/test"
24
- autoload :Twilio, "noticed/delivery_methods/twilio"
25
- autoload :Vonage, "noticed/delivery_methods/vonage"
37
+ autoload :TwilioMessaging, "noticed/delivery_methods/twilio_messaging"
38
+ autoload :VonageSms, "noticed/delivery_methods/vonage_sms"
39
+ autoload :Webhook, "noticed/delivery_methods/webhook"
26
40
  end
27
41
 
28
- mattr_accessor :parent_class
29
- @@parent_class = "ApplicationJob"
30
-
31
42
  class ValidationError < StandardError
32
43
  end
33
44
 
34
45
  class ResponseUnsuccessful < StandardError
35
46
  attr_reader :response
36
47
 
37
- def initialize(response)
48
+ def initialize(response, url, args)
38
49
  @response = response
50
+ @url = url
51
+ @args = args
52
+
53
+ super("POST request to #{url} returned #{response.code} response:\n#{response.body.inspect}")
39
54
  end
40
55
  end
41
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noticed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-11 00:00:00.000000000 Z
11
+ date: 2024-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
19
+ version: 6.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.0
27
- - !ruby/object:Gem::Dependency
28
- name: http
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 4.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 4.0.0
26
+ version: 6.1.0
41
27
  description: Database, browser, realtime ActionCable, Email, SMS, Slack notifications,
42
28
  and more for Rails apps
43
29
  email:
@@ -49,42 +35,45 @@ files:
49
35
  - MIT-LICENSE
50
36
  - README.md
51
37
  - Rakefile
38
+ - app/jobs/noticed/application_job.rb
39
+ - app/jobs/noticed/event_job.rb
40
+ - app/models/concerns/noticed/deliverable.rb
41
+ - app/models/concerns/noticed/notification_methods.rb
42
+ - app/models/concerns/noticed/readable.rb
43
+ - app/models/noticed/application_record.rb
44
+ - app/models/noticed/deliverable/deliver_by.rb
45
+ - app/models/noticed/event.rb
46
+ - app/models/noticed/notification.rb
47
+ - db/migrate/20231215190233_create_noticed_tables.rb
52
48
  - lib/generators/noticed/delivery_method_generator.rb
53
- - lib/generators/noticed/model/base_generator.rb
54
- - lib/generators/noticed/model/mysql_generator.rb
55
- - lib/generators/noticed/model/postgresql_generator.rb
56
- - lib/generators/noticed/model/sqlite3_generator.rb
57
- - lib/generators/noticed/model_generator.rb
58
- - lib/generators/noticed/notification_generator.rb
49
+ - lib/generators/noticed/install_generator.rb
50
+ - lib/generators/noticed/notifier_generator.rb
59
51
  - lib/generators/noticed/templates/README
60
52
  - lib/generators/noticed/templates/delivery_method.rb.tt
61
- - lib/generators/noticed/templates/notification.rb.tt
53
+ - lib/generators/noticed/templates/notifier.rb.tt
62
54
  - lib/noticed.rb
63
- - lib/noticed/base.rb
55
+ - lib/noticed/api_client.rb
56
+ - lib/noticed/bulk_delivery_method.rb
57
+ - lib/noticed/bulk_delivery_methods/discord.rb
58
+ - lib/noticed/bulk_delivery_methods/slack.rb
59
+ - lib/noticed/bulk_delivery_methods/webhook.rb
64
60
  - lib/noticed/coder.rb
61
+ - lib/noticed/delivery_method.rb
65
62
  - lib/noticed/delivery_methods/action_cable.rb
66
- - lib/noticed/delivery_methods/base.rb
67
- - lib/noticed/delivery_methods/database.rb
63
+ - lib/noticed/delivery_methods/discord.rb
68
64
  - lib/noticed/delivery_methods/email.rb
69
65
  - lib/noticed/delivery_methods/fcm.rb
70
66
  - lib/noticed/delivery_methods/ios.rb
71
67
  - lib/noticed/delivery_methods/microsoft_teams.rb
72
68
  - lib/noticed/delivery_methods/slack.rb
73
69
  - lib/noticed/delivery_methods/test.rb
74
- - lib/noticed/delivery_methods/twilio.rb
75
- - lib/noticed/delivery_methods/vonage.rb
70
+ - lib/noticed/delivery_methods/twilio_messaging.rb
71
+ - lib/noticed/delivery_methods/vonage_sms.rb
72
+ - lib/noticed/delivery_methods/webhook.rb
76
73
  - lib/noticed/engine.rb
77
- - lib/noticed/has_notifications.rb
78
- - lib/noticed/model.rb
79
- - lib/noticed/notification_channel.rb
80
- - lib/noticed/text_coder.rb
74
+ - lib/noticed/required_options.rb
81
75
  - lib/noticed/translation.rb
82
76
  - lib/noticed/version.rb
83
- - lib/rails_6_polyfills/actioncable/test_adapter.rb
84
- - lib/rails_6_polyfills/actioncable/test_helper.rb
85
- - lib/rails_6_polyfills/activejob/serializers.rb
86
- - lib/rails_6_polyfills/base.rb
87
- - lib/tasks/noticed_tasks.rake
88
77
  homepage: https://github.com/excid3/noticed
89
78
  licenses:
90
79
  - MIT
@@ -104,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
93
  - !ruby/object:Gem::Version
105
94
  version: '0'
106
95
  requirements: []
107
- rubygems_version: 3.4.12
96
+ rubygems_version: 3.5.3
108
97
  signing_key:
109
98
  specification_version: 4
110
99
  summary: Notifications for Ruby on Rails applications
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators/named_base"
4
-
5
- module Noticed
6
- module Generators
7
- module Model
8
- class BaseGenerator < Rails::Generators::NamedBase
9
- include Rails::Generators::ResourceHelpers
10
-
11
- source_root File.expand_path("../templates", __FILE__)
12
-
13
- desc "Generates a Notification model for storing notifications."
14
-
15
- argument :name, type: :string, default: "Notification", banner: "Notification"
16
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
17
-
18
- def generate_notification
19
- generate :model, name, "recipient:references{polymorphic}", "type", "params:#{json_column_type}", "read_at:datetime:index", *attributes
20
- end
21
-
22
- def add_noticed_model
23
- inject_into_class model_path, class_name, " include Noticed::Model\n"
24
- end
25
-
26
- def add_not_nullable
27
- migration_path = Dir.glob(Rails.root.join("db/migrate/*")).max_by { |f| File.mtime(f) }
28
-
29
- # Force is required because null: false already exists in the file and Thor isn't smart enough to tell the difference
30
- insert_into_file migration_path, after: "t.string :type", force: true do
31
- ", null: false"
32
- end
33
- end
34
-
35
- def done
36
- readme "README" if behavior == :invoke
37
- end
38
-
39
- private
40
-
41
- def model_path
42
- @model_path ||= File.join("app", "models", "#{file_path}.rb")
43
- end
44
- end
45
- end
46
- end
47
- end