web47core 3.2.3.31 → 3.2.3.32
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 +4 -4
- data/app/helpers/core_helper.rb +5 -1
- data/app/helpers/svg_icon_helper.rb +2 -2
- data/app/views/system_configurations/edit.html.haml +4 -4
- data/app/views/system_configurations/show.html.haml +2 -2
- data/lib/app/controllers/concerns/core_controller.rb +6 -0
- data/lib/app/controllers/concerns/core_system_configuration_controller.rb +5 -12
- data/lib/app/controllers/concerns/restful_controller.rb +1 -1
- data/lib/app/jobs/application_job.rb +4 -0
- data/lib/app/jobs/cron/job.rb +1 -1
- data/lib/app/jobs/cron/restart_orphaned_delayed_jobs.rb +1 -1
- data/lib/app/jobs/cron/switchboard_sync_configuration.rb +6 -7
- data/lib/app/jobs/cron/trim_collection.rb +1 -1
- data/lib/app/models/concerns/cdn_url.rb +1 -1
- data/lib/app/models/concerns/email_able.rb +4 -4
- data/lib/app/models/concerns/standard_model.rb +4 -0
- data/lib/app/models/concerns/switchboard_able.rb +6 -6
- data/lib/app/models/concerns/time_zone_able.rb +3 -3
- data/lib/app/models/delayed/jobs/metric.rb +2 -2
- data/lib/app/models/email_notification.rb +5 -5
- data/lib/app/models/notification.rb +8 -8
- data/lib/app/models/slack_notification.rb +3 -3
- data/lib/app/models/sms_notification.rb +5 -6
- data/lib/web47core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 802701ca7fd3618efc7bcf10c8c9f9299a9d75cead03284879539b931fd0d2ee
|
|
4
|
+
data.tar.gz: 1c2df41fec8fa2391ad64399dc481bb3789b9657893be8d7ba29189aa20c4719
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51977b350f0894bcff77230015b88303f0e0a035ab39dde554728369dd027b308cbe959cd4863219daa26306460ef2965229c9619514babad59634973f05a7b2
|
|
7
|
+
data.tar.gz: ad4e22759a3bc3c7fce76670af44c7e715c46c4b5d527e7b45daa16b29a91cfc5d9798d76b66e40424710059cc8844c740f29b2b039a396238f9eba816dfb22f
|
data/app/helpers/core_helper.rb
CHANGED
|
@@ -49,7 +49,7 @@ module CoreHelper
|
|
|
49
49
|
%w[password token secret access_key api_key].each do |mask|
|
|
50
50
|
should_mask |= field.include?(mask)
|
|
51
51
|
end
|
|
52
|
-
value =
|
|
52
|
+
value = sys_config.send(field)
|
|
53
53
|
should_mask ? mask_value(value, default: 'Not Set') : value
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -92,4 +92,8 @@ module CoreHelper
|
|
|
92
92
|
def edit_model_path(model)
|
|
93
93
|
model_action_path(model, :edit)
|
|
94
94
|
end
|
|
95
|
+
|
|
96
|
+
def sys_config
|
|
97
|
+
@sys_config ||= SystemConfiguration.configuration
|
|
98
|
+
end
|
|
95
99
|
end
|
|
@@ -6,7 +6,7 @@ module SvgIconHelper
|
|
|
6
6
|
return if name.blank?
|
|
7
7
|
|
|
8
8
|
key = ['svg_icon', name, size.to_s, type.to_s, classes.to_s, color, stroke_width.to_s].join(':')
|
|
9
|
-
Rails.cache.fetch(key, expires_in:
|
|
9
|
+
Rails.cache.fetch(key, expires_in: 15.minutes) do
|
|
10
10
|
fetch_svg_icon(name, size: size, type: type, classes: classes, color: color, stroke_width: stroke_width)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
@@ -16,7 +16,7 @@ module SvgIconHelper
|
|
|
16
16
|
|
|
17
17
|
classes = classes.compact.flatten.join(' ')
|
|
18
18
|
key = "icon_partial_path:#{name}:#{type}"
|
|
19
|
-
(partial, stroke) = Rails.cache.fetch(key, expires_in:
|
|
19
|
+
(partial, stroke) = Rails.cache.fetch(key, expires_in: 15.minutes) do
|
|
20
20
|
preferred_path = I18n.exists?("nav.icons.#{name}") ? 'icons/' + I18n.t("nav.icons.#{name}") : "icons/#{type}/#{name}"
|
|
21
21
|
outline_path = "icons/outline/#{name}"
|
|
22
22
|
filled_path = "icons/filled/#{name}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
- title 'Edit'
|
|
2
2
|
- content_for :breadcrumbs do
|
|
3
|
-
=breadcrumb_step(system_configurations_path,
|
|
3
|
+
=breadcrumb_step(system_configurations_path, sys_config.environment.titleize)
|
|
4
4
|
%form{action: system_configurations_path, method: :post}
|
|
5
5
|
%input{type: :hidden, value: form_authenticity_token, name: :authenticity_token}
|
|
6
6
|
%input{type: :hidden, name: '_method', value: :put}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
.card-body
|
|
9
9
|
.container
|
|
10
10
|
.row
|
|
11
|
-
= html5_text_field(@
|
|
12
|
-
= html5_text_field(@
|
|
13
|
-
= html5_password(@
|
|
11
|
+
= html5_text_field(@system_config, :switchboard_base_url, classes: %w[col-sm-12 col-lg-4] )
|
|
12
|
+
= html5_text_field(@system_config, :switchboard_stack_id, classes: %w[col-sm-12 col-lg-4])
|
|
13
|
+
= html5_password(@system_config, :switchboard_stack_api_token, classes: %w[col-sm-12 col-lg-4])
|
|
14
14
|
.card-footer= render 'common/form_actions', form_cancel_path: system_configurations_path
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
- title
|
|
1
|
+
- title sys_config.environment.titleize
|
|
2
2
|
.card
|
|
3
3
|
.card-header.d-flex.justify-content-between
|
|
4
4
|
.card-title System Configuration
|
|
5
5
|
= card_nav_items(SystemConfiguration) do |nav|
|
|
6
6
|
=nav.edit_link(edit_system_configurations_path)
|
|
7
|
-
- if
|
|
7
|
+
- if sys_config.switchboard_configured?
|
|
8
8
|
=nav.synchronize_link(sync_system_configurations_path)
|
|
9
9
|
|
|
10
10
|
.card-body
|
|
@@ -10,12 +10,12 @@ module CoreSystemConfigurationsController
|
|
|
10
10
|
# Edit the system configuration
|
|
11
11
|
#
|
|
12
12
|
def edit
|
|
13
|
-
|
|
13
|
+
system_config
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# @abstract Cause the system configuration to be synced with the switchboard server
|
|
17
17
|
def sync
|
|
18
|
-
raise 'System Configuration not configured to sync' unless
|
|
18
|
+
raise 'System Configuration not configured to sync' unless system_config.switchboard_configured?
|
|
19
19
|
|
|
20
20
|
Cron::SwitchboardSyncConfiguration.perform_later
|
|
21
21
|
flash[:info] = 'System Configuration Refreshing in the Background'
|
|
@@ -29,8 +29,8 @@ module CoreSystemConfigurationsController
|
|
|
29
29
|
# Update and log the system configuration changes
|
|
30
30
|
#
|
|
31
31
|
def update
|
|
32
|
-
|
|
33
|
-
if
|
|
32
|
+
system_config.update! system_configuration_params
|
|
33
|
+
if system_config.switchboard_configured?
|
|
34
34
|
flash[:info] = 'System Configuration Updated, sync job running in the background'
|
|
35
35
|
Cron::SwitchboardSyncConfiguration.perform_later
|
|
36
36
|
else
|
|
@@ -39,7 +39,7 @@ module CoreSystemConfigurationsController
|
|
|
39
39
|
redirect_to index_path
|
|
40
40
|
rescue StandardError => error
|
|
41
41
|
log_controller_error error
|
|
42
|
-
|
|
42
|
+
system_config
|
|
43
43
|
render :edit
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -51,11 +51,4 @@ module CoreSystemConfigurationsController
|
|
|
51
51
|
def system_configuration_params
|
|
52
52
|
params[:system_configuration].permit(%i[switchboard_base_url switchboard_stack_id switchboard_stack_api_token])
|
|
53
53
|
end
|
|
54
|
-
|
|
55
|
-
#
|
|
56
|
-
# Load the current system configuration
|
|
57
|
-
#
|
|
58
|
-
def system_configuration
|
|
59
|
-
@system_configuration = SystemConfiguration.configuration
|
|
60
|
-
end
|
|
61
54
|
end
|
data/lib/app/jobs/cron/job.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Cron
|
|
|
36
36
|
event: event,
|
|
37
37
|
error_message: error.message,
|
|
38
38
|
stack_trace: error.backtrace }
|
|
39
|
-
SlackNotification.say message, to:
|
|
39
|
+
SlackNotification.say message, to: system_config.slack_support_channel, template: :job_failure
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
|
@@ -13,7 +13,7 @@ module Cron
|
|
|
13
13
|
#
|
|
14
14
|
def self.valid_environment?
|
|
15
15
|
Delayed::Worker.plugins.include?(Delayed::Plugins::TimeKeeper) &&
|
|
16
|
-
|
|
16
|
+
system_config.delayed_job_restart_orphaned? &&
|
|
17
17
|
Delayed::Backend::Mongoid::Job.count.positive?
|
|
18
18
|
rescue StandardError
|
|
19
19
|
false
|
|
@@ -22,15 +22,14 @@ module Cron
|
|
|
22
22
|
#
|
|
23
23
|
def execute
|
|
24
24
|
RestClient.get(switchboard_url,
|
|
25
|
-
ACCESS_TOKEN:
|
|
25
|
+
ACCESS_TOKEN: sys_config.switchboard_stack_api_token,
|
|
26
26
|
content_type: 'application/json') do |response, _request, _result, &block|
|
|
27
27
|
case response.code
|
|
28
28
|
when 200
|
|
29
29
|
json = JSON.parse(response.body)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
config.save!
|
|
30
|
+
json['results'].each { |key, value| update_config(sys_config, key, value) }
|
|
31
|
+
sys_config.switchboard_last_sync_at = Time.now.utc
|
|
32
|
+
sys_config.save!
|
|
34
33
|
else
|
|
35
34
|
App47Logger.log_error "Unable to fetch switchboard config, #{response.inspect}"
|
|
36
35
|
response.return!(&block)
|
|
@@ -59,9 +58,9 @@ module Cron
|
|
|
59
58
|
# Generate the switchboard URL
|
|
60
59
|
#
|
|
61
60
|
def switchboard_url
|
|
62
|
-
[
|
|
61
|
+
[sys_config.switchboard_base_url,
|
|
63
62
|
'stacks',
|
|
64
|
-
|
|
63
|
+
sys_config.switchboard_stack_id,
|
|
65
64
|
'items.json'].join('/')
|
|
66
65
|
end
|
|
67
66
|
end
|
|
@@ -48,7 +48,7 @@ module Cron
|
|
|
48
48
|
# Try to get a TTL from System configuration, otherwise return the default
|
|
49
49
|
#
|
|
50
50
|
def allowed_time_for_item(item)
|
|
51
|
-
|
|
51
|
+
sys_config.send("#{item.class.to_s.underscore}_ttl").days.ago
|
|
52
52
|
rescue StandardError
|
|
53
53
|
allowed_time
|
|
54
54
|
end
|
|
@@ -28,7 +28,7 @@ module CdnUrl
|
|
|
28
28
|
send method.to_s.sub(/^cdn_/, '').to_sym, *args
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
cdn_url =
|
|
31
|
+
cdn_url = sys_config.cdn_url
|
|
32
32
|
if [cdn_url.present?, url.present?].all?
|
|
33
33
|
model_name = "#{self.class.to_s.underscore}s"
|
|
34
34
|
if url.include? "/#{model_name}/"
|
|
@@ -56,10 +56,10 @@ module EmailAble
|
|
|
56
56
|
# Reset the bounced email
|
|
57
57
|
#
|
|
58
58
|
def reset_bounce_status(current_member = nil)
|
|
59
|
-
return unless
|
|
59
|
+
return unless sys_config.mail_gun_configured? && email_bounced?
|
|
60
60
|
|
|
61
|
-
reset_url = "https://api.mailgun.net/v3/#{
|
|
62
|
-
RestClient.delete(reset_url, user: 'api', password:
|
|
61
|
+
reset_url = "https://api.mailgun.net/v3/#{sys_config.smtp_domain}/bounces/#{CGI.escape(email)}"
|
|
62
|
+
RestClient.delete(reset_url, user: 'api', password: sys_config.mailgun_api_key)
|
|
63
63
|
rescue RestClient::Exception => error
|
|
64
64
|
log_error "Unable to reset email bounce status: #{inspect}", error
|
|
65
65
|
ensure
|
|
@@ -75,7 +75,7 @@ module EmailAble
|
|
|
75
75
|
#
|
|
76
76
|
def gravatar_url(size = '32', default = 'mm')
|
|
77
77
|
self.email ||= 'noone@abc.com'
|
|
78
|
-
if
|
|
78
|
+
if sys_config.fips_mode?
|
|
79
79
|
"https://www.gravatar.com/avatar/#{Digest::SHA2.hexdigest(email)}?s=#{size}&d=#{default}"
|
|
80
80
|
else
|
|
81
81
|
"https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email)}?s=#{size}&d=#{default}"
|
|
@@ -52,7 +52,7 @@ module SwitchboardAble
|
|
|
52
52
|
# Delete the object from switchboard
|
|
53
53
|
#
|
|
54
54
|
def switchboard_delete
|
|
55
|
-
return unless
|
|
55
|
+
return unless sys_config.switchboard_configured? && switchboard_id.present?
|
|
56
56
|
|
|
57
57
|
RestClient.delete(switchboard_url, ACCESS_TOKEN: sw_api_token) do |response, _request, _result|
|
|
58
58
|
case response.code
|
|
@@ -68,7 +68,7 @@ module SwitchboardAble
|
|
|
68
68
|
# Update the object in switchboard
|
|
69
69
|
#
|
|
70
70
|
def switchboard_update
|
|
71
|
-
return unless
|
|
71
|
+
return unless sys_config.switchboard_configured? && switchboard_id.present?
|
|
72
72
|
|
|
73
73
|
RestClient.put(switchboard_url,
|
|
74
74
|
switchboard_payload.to_json,
|
|
@@ -90,7 +90,7 @@ module SwitchboardAble
|
|
|
90
90
|
# Insert the object into switchboard
|
|
91
91
|
#
|
|
92
92
|
def switchboard_insert
|
|
93
|
-
return unless
|
|
93
|
+
return unless sys_config.switchboard_configured?
|
|
94
94
|
|
|
95
95
|
RestClient.post(switchboard_url,
|
|
96
96
|
switchboard_payload.to_json,
|
|
@@ -111,9 +111,9 @@ module SwitchboardAble
|
|
|
111
111
|
# The URL for this switchboard item
|
|
112
112
|
#
|
|
113
113
|
def switchboard_url
|
|
114
|
-
components = [
|
|
114
|
+
components = [sys_config.switchboard_base_url,
|
|
115
115
|
'stacks',
|
|
116
|
-
|
|
116
|
+
sys_config.switchboard_stack_id,
|
|
117
117
|
switchboard_name]
|
|
118
118
|
components << switchboard_id if switchboard_id.present?
|
|
119
119
|
components.join('/') + '.json'
|
|
@@ -123,6 +123,6 @@ module SwitchboardAble
|
|
|
123
123
|
# Return the api token
|
|
124
124
|
#
|
|
125
125
|
def sw_api_token
|
|
126
|
-
@sw_api_token ||=
|
|
126
|
+
@sw_api_token ||= sys_config.switchboard_stack_api_token
|
|
127
127
|
end
|
|
128
128
|
end
|
|
@@ -33,7 +33,7 @@ module TimeZoneAble
|
|
|
33
33
|
def local_date(date, format = :medium, default = 'N/A')
|
|
34
34
|
case date
|
|
35
35
|
when Time
|
|
36
|
-
tz = TZInfo::Timezone.get(time_zone.presence ||
|
|
36
|
+
tz = TZInfo::Timezone.get(time_zone.presence || sys_config.default_time_zone)
|
|
37
37
|
date.present? ? I18n.l(date.in_time_zone(tz).to_date, format: format) : default
|
|
38
38
|
when Date
|
|
39
39
|
I18n.l(date, format: format)
|
|
@@ -48,7 +48,7 @@ module TimeZoneAble
|
|
|
48
48
|
# Return the given time in the localized time for this object
|
|
49
49
|
#
|
|
50
50
|
def local_time(time, format = :medium, default = 'N/A')
|
|
51
|
-
tz = TZInfo::Timezone.get(time_zone.presence ||
|
|
51
|
+
tz = TZInfo::Timezone.get(time_zone.presence || sys_config.default_time_zone)
|
|
52
52
|
time.present? ? I18n.l(time.in_time_zone(tz), format: format) : default
|
|
53
53
|
rescue StandardError
|
|
54
54
|
default
|
|
@@ -65,6 +65,6 @@ module TimeZoneAble
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def default_time_zone
|
|
68
|
-
self.time_zone ||=
|
|
68
|
+
self.time_zone ||= sys_config.default_time_zone
|
|
69
69
|
end
|
|
70
70
|
end
|
|
@@ -47,14 +47,14 @@ module Delayed
|
|
|
47
47
|
# Pull the method from system configuration to evalutate max allowed time
|
|
48
48
|
#
|
|
49
49
|
def max_allowed_method
|
|
50
|
-
@max_allowed_method ||=
|
|
50
|
+
@max_allowed_method ||= sys_config.delayed_job_max_allowed_method
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
#
|
|
54
54
|
# Pull the factor for max allowed when evaluating allowed time
|
|
55
55
|
#
|
|
56
56
|
def max_allowed_factor
|
|
57
|
-
@max_allowed_factor ||=
|
|
57
|
+
@max_allowed_factor ||= sys_config.delayed_job_max_allowed_factor
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
end
|
|
@@ -111,7 +111,7 @@ class EmailNotification < Notification
|
|
|
111
111
|
mail.delivery_method :smtp, smtp_configuration
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
mail.header['X-Mailgun-Native-Send'] = 'yes' if
|
|
114
|
+
mail.header['X-Mailgun-Native-Send'] = 'yes' if sys_config.mail_gun_configured?
|
|
115
115
|
# Deliver it
|
|
116
116
|
mail.deliver
|
|
117
117
|
rescue StandardError => error
|
|
@@ -140,7 +140,7 @@ class EmailNotification < Notification
|
|
|
140
140
|
# sender address
|
|
141
141
|
#
|
|
142
142
|
def sender_address
|
|
143
|
-
address =
|
|
143
|
+
address = sys_config.support_email
|
|
144
144
|
if account.present?
|
|
145
145
|
account_smtp = account.fetch_smtp_configuration
|
|
146
146
|
address = account_smtp.username if account_smtp.use?
|
|
@@ -154,7 +154,7 @@ class EmailNotification < Notification
|
|
|
154
154
|
def from_address
|
|
155
155
|
return from if from.present?
|
|
156
156
|
|
|
157
|
-
address =
|
|
157
|
+
address = sys_config.default_email
|
|
158
158
|
if account.present?
|
|
159
159
|
account_smtp = account.fetch_smtp_configuration
|
|
160
160
|
address = account_smtp.email_address if account_smtp.use?
|
|
@@ -214,7 +214,7 @@ class EmailNotification < Notification
|
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
def add_notification_tracker(html_message)
|
|
217
|
-
tracker_url = "#{
|
|
217
|
+
tracker_url = "#{sys_config.base_url}/notifications/#{id}/img"
|
|
218
218
|
return html_message if html_message.include?(tracker_url)
|
|
219
219
|
|
|
220
220
|
image_tag = "<img style='height:0;width:0;border:none;display:none;' src='#{tracker_url}' alt=''/></body>"
|
|
@@ -222,7 +222,7 @@ class EmailNotification < Notification
|
|
|
222
222
|
end
|
|
223
223
|
|
|
224
224
|
def subject_from_haml_text(haml_text, locals)
|
|
225
|
-
locals[:base_url] =
|
|
225
|
+
locals[:base_url] = sys_config.base_url
|
|
226
226
|
haml_engine = Haml::Engine.new(haml_text)
|
|
227
227
|
self.subject = haml_engine.render(Object.new, stringify_all(locals))
|
|
228
228
|
end
|
|
@@ -151,7 +151,7 @@ class Notification
|
|
|
151
151
|
handle_asynchronously :deliver_message, priority: 100
|
|
152
152
|
|
|
153
153
|
def from_template(template_name, locals = {})
|
|
154
|
-
locals[:base_url] =
|
|
154
|
+
locals[:base_url] = sys_config.base_url
|
|
155
155
|
self.message = message_from_template(template_name, locals)
|
|
156
156
|
end
|
|
157
157
|
|
|
@@ -194,7 +194,7 @@ class Notification
|
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
def message_from_haml_text(haml_text, locals)
|
|
197
|
-
locals[:base_url] =
|
|
197
|
+
locals[:base_url] = sys_config.base_url
|
|
198
198
|
|
|
199
199
|
template = Haml::Template.new { haml_text }
|
|
200
200
|
self.message = template.render(Object.new, locals)
|
|
@@ -212,7 +212,7 @@ class Notification
|
|
|
212
212
|
# Render the given liquid text
|
|
213
213
|
#
|
|
214
214
|
def render_liquid_text(liquid_text, locals = {})
|
|
215
|
-
locals[:base_url] =
|
|
215
|
+
locals[:base_url] = sys_config.base_url
|
|
216
216
|
Liquid::Template.parse(liquid_text).render(stringify_all(locals))
|
|
217
217
|
end
|
|
218
218
|
|
|
@@ -263,19 +263,19 @@ class Notification
|
|
|
263
263
|
def notify_failure(error)
|
|
264
264
|
if account.nil? || !account.fetch_smtp_configuration.use?
|
|
265
265
|
error_email = EmailNotification.new
|
|
266
|
-
params = { company_name:
|
|
266
|
+
params = { company_name: sys_config.company_name,
|
|
267
267
|
error_message: error.message,
|
|
268
|
-
notification_url: "#{
|
|
268
|
+
notification_url: "#{sys_config.base_url}/stack/notifications/#{id}" }
|
|
269
269
|
error_email.from_template(AccountEmailTemplate::EMAIL_NOTIFICATION_FAILED, params)
|
|
270
|
-
error_email.to =
|
|
270
|
+
error_email.to = sys_config.support_email
|
|
271
271
|
error_email.save!
|
|
272
272
|
error_email.deliver
|
|
273
273
|
else
|
|
274
274
|
account.smtp_admins.each do |admin|
|
|
275
275
|
error_email = EmailNotification.new
|
|
276
|
-
params = { company_name:
|
|
276
|
+
params = { company_name: sys_config.company_name,
|
|
277
277
|
error_message: error.message,
|
|
278
|
-
notification_url: "#{
|
|
278
|
+
notification_url: "#{sys_config.base_url}/notifications/#{id}" }
|
|
279
279
|
error_email.from_template(AccountEmailTemplate::EMAIL_NOTIFICATION_FAILED, params)
|
|
280
280
|
error_email.to = admin.email
|
|
281
281
|
error_email.save!
|
|
@@ -32,14 +32,14 @@ class SlackNotification < Notification
|
|
|
32
32
|
field :from, type: String
|
|
33
33
|
|
|
34
34
|
def deliver_message
|
|
35
|
-
if
|
|
35
|
+
if sys_config.slack_configured?
|
|
36
36
|
start_processing
|
|
37
37
|
payload = { text: message }
|
|
38
|
-
payload[:channel] = to.presence ||
|
|
38
|
+
payload[:channel] = to.presence || sys_config.slack_support_channel
|
|
39
39
|
# Use the environment as the default, otherwise set it as the from
|
|
40
40
|
payload[:username] = from.presence || Rails.env
|
|
41
41
|
# Setup the delivery method for this message only.
|
|
42
|
-
RestClient.post(
|
|
42
|
+
RestClient.post(sys_config.slack_api_url, payload.to_json)
|
|
43
43
|
finish_processing
|
|
44
44
|
else
|
|
45
45
|
finish_processing 'Slack is not configured'
|
|
@@ -29,20 +29,19 @@ class SmsNotification < Notification
|
|
|
29
29
|
validates :to, presence: true, format: { with: /\A\+[1-9]{1}[0-9]{3,14}\z/ }
|
|
30
30
|
|
|
31
31
|
def deliver_message!
|
|
32
|
-
return unless
|
|
32
|
+
return unless sys_config.twilio_configured?
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
auth_token = config.twilio_auth_token
|
|
34
|
+
account_sid = sys_config.twilio_account_id
|
|
35
|
+
auth_token = sys_config.twilio_auth_token
|
|
37
36
|
client = Twilio::REST::Client.new account_sid, auth_token
|
|
38
37
|
twilio_message = if client.respond_to?(:account)
|
|
39
38
|
client.account.messages.create(body: message,
|
|
40
39
|
to: to,
|
|
41
|
-
from:
|
|
40
|
+
from: sys_config.twilio_phone_number)
|
|
42
41
|
else
|
|
43
42
|
client.messages.create(body: message,
|
|
44
43
|
to: to,
|
|
45
|
-
from:
|
|
44
|
+
from: sys_config.twilio_phone_number)
|
|
46
45
|
end
|
|
47
46
|
# We are saved in the calling class, no reason to save again
|
|
48
47
|
set sid: twilio_message.sid
|
data/lib/web47core/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: web47core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.3.
|
|
4
|
+
version: 3.2.3.32
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Schroeder
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-02-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|