effective_messaging 0.7.5 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/admin/effective_notification_logs_datatable.rb +1 -1
- data/app/models/effective/chat_message.rb +7 -1
- data/app/models/effective/notification.rb +23 -15
- data/app/models/effective/notification_log.rb +1 -1
- data/app/views/admin/chat_messages/_form.html.haml +9 -0
- data/app/views/admin/chats/_form.html.haml +3 -0
- data/config/routes.rb +1 -1
- data/lib/effective_messaging/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d1af8fb6d222cf7dc1f2ad5c9baaf139607cef5f724879fd3bc037107d56b4d
|
4
|
+
data.tar.gz: f6315751785d8760aee7adb5593826f6b4ed80639ec1d0f54d1ee95f85462828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 657cc27116ca125f8102c2bc4ee1331d9359e673e7b9dc4647509541c217f4ad79c2a11e4dd4014ec0aff7f0b8fab9be45de9a104a8738f2a87d3d16d73dcf64
|
7
|
+
data.tar.gz: 5c0de10cdbbf454298c7033f39ed5ca08cfffb51c1f54cd6ee65f5d23872b08fd93267e1f5281eecbc6205493d99e48d04b9c3f47109c4cf178c6d1d6e75723d
|
@@ -35,7 +35,13 @@ module Effective
|
|
35
35
|
validates :body, presence: true
|
36
36
|
|
37
37
|
def to_s
|
38
|
-
body.presence || 'New Chat Message'
|
38
|
+
truncate(body.presence || 'New Chat Message')
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def truncate(value)
|
44
|
+
value.length > 100 ? (value.first(100) + '...') : value
|
39
45
|
end
|
40
46
|
|
41
47
|
end
|
@@ -134,7 +134,7 @@ module Effective
|
|
134
134
|
validates :report, presence: true
|
135
135
|
|
136
136
|
validate(if: -> { report.present? }) do
|
137
|
-
errors.add(:report, 'must include an email or
|
137
|
+
errors.add(:report, 'must include an email, user, organization or owner column') unless report.email_report_column || report.emailable_report_column
|
138
138
|
end
|
139
139
|
|
140
140
|
validate(if: -> { report.present? && subject.present? }) do
|
@@ -347,7 +347,7 @@ module Effective
|
|
347
347
|
end
|
348
348
|
|
349
349
|
def already_notified_today?(resource)
|
350
|
-
email =
|
350
|
+
email = resource_emails_to_s(resource)
|
351
351
|
raise("expected an email for #{report} #{report&.id} and #{resource} #{resource&.id}") unless email.present?
|
352
352
|
|
353
353
|
logs = notification_logs.select { |log| log.email == email }
|
@@ -362,7 +362,7 @@ module Effective
|
|
362
362
|
def notifiable_immediate?(resource:, date: nil)
|
363
363
|
raise('expected an immediate? notification') unless immediate?
|
364
364
|
|
365
|
-
email =
|
365
|
+
email = resource_emails_to_s(resource)
|
366
366
|
raise("expected an email for #{report} #{report&.id} and #{resource} #{resource&.id}") unless email.present?
|
367
367
|
|
368
368
|
logs = notification_logs.select { |log| log.email == email }
|
@@ -394,12 +394,7 @@ module Effective
|
|
394
394
|
def render_email(resource = nil)
|
395
395
|
raise('expected an acts_as_reportable resource') if resource.present? && !resource.class.try(:acts_as_reportable?)
|
396
396
|
|
397
|
-
to =
|
398
|
-
audience_emails.presence
|
399
|
-
elsif audience == 'report'
|
400
|
-
resource_email(resource) || resource_user(resource).try(:email)
|
401
|
-
end
|
402
|
-
|
397
|
+
to = (audience == 'emails' ? audience_emails.presence : resource_emails_to_s(resource))
|
403
398
|
raise('expected a to email address') unless to.present?
|
404
399
|
|
405
400
|
assigns = assigns_for(resource)
|
@@ -437,12 +432,12 @@ module Effective
|
|
437
432
|
end
|
438
433
|
|
439
434
|
def build_notification_log(resource: nil, skipped: false)
|
440
|
-
|
435
|
+
emailable = resource_emailable(resource)
|
441
436
|
|
442
|
-
email =
|
437
|
+
email = resource_emails_to_s(resource)
|
443
438
|
email ||= audience_emails_to_s if scheduled_email?
|
444
439
|
|
445
|
-
notification_logs.build(email: email, report: report, resource: resource, user:
|
440
|
+
notification_logs.build(email: email, report: report, resource: resource, user: emailable, skipped: skipped)
|
446
441
|
end
|
447
442
|
|
448
443
|
private
|
@@ -456,18 +451,31 @@ module Effective
|
|
456
451
|
end
|
457
452
|
|
458
453
|
def audience_emails_to_s
|
459
|
-
audience_emails.presence&.join(',')
|
454
|
+
audience_emails.presence&.join(', ')
|
455
|
+
end
|
456
|
+
|
457
|
+
# All emails for this emailable resource
|
458
|
+
def resource_emails_to_s(resource)
|
459
|
+
emails = Array(resource_email(resource)).map(&:presence).compact
|
460
|
+
|
461
|
+
if emails.blank? && (emailable = resource_emailable(resource)).present?
|
462
|
+
emails = Array(emailable.try(:reportable_emails) || emailable.try(:email)).map(&:presence).compact
|
463
|
+
end
|
464
|
+
|
465
|
+
emails.presence&.join(', ')
|
460
466
|
end
|
461
467
|
|
462
|
-
|
468
|
+
# A user, owner, or organization column
|
469
|
+
def resource_emailable(resource)
|
463
470
|
return unless resource.present?
|
464
471
|
|
465
|
-
column = report&.
|
472
|
+
column = report&.emailable_report_column
|
466
473
|
return unless column.present?
|
467
474
|
|
468
475
|
resource.public_send(column.name) || (resource if resource.respond_to?(:email))
|
469
476
|
end
|
470
477
|
|
478
|
+
# An email column
|
471
479
|
def resource_email(resource)
|
472
480
|
return unless resource.present?
|
473
481
|
|
@@ -3,6 +3,9 @@
|
|
3
3
|
= render 'admin/chats/form_chat', chat: chat
|
4
4
|
|
5
5
|
- if chat.persisted?
|
6
|
+
= tab(chat.chat_messages) do
|
7
|
+
= render_inline_datatable(Admin::EffectiveChatMessagesDatatable.new(chat: chat))
|
8
|
+
|
6
9
|
- if chat.respond_to?(:logs_datatable)
|
7
10
|
= tab "Logs" do
|
8
11
|
= render_inline_datatable(chat.logs_datatable)
|
data/config/routes.rb
CHANGED
@@ -12,7 +12,7 @@ EffectiveMessaging::Engine.routes.draw do
|
|
12
12
|
|
13
13
|
namespace :admin do
|
14
14
|
resources :chats
|
15
|
-
resources :chat_messages,
|
15
|
+
resources :chat_messages, except: [:new, :create]
|
16
16
|
|
17
17
|
resources :notifications do
|
18
18
|
post :enable, on: :member
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- app/models/effective/notification.rb
|
230
230
|
- app/models/effective/notification_log.rb
|
231
231
|
- app/views/admin/chat_messages/_chat_message.html.haml
|
232
|
+
- app/views/admin/chat_messages/_form.html.haml
|
232
233
|
- app/views/admin/chats/_chat.html.haml
|
233
234
|
- app/views/admin/chats/_form.html.haml
|
234
235
|
- app/views/admin/chats/_form_chat.html.haml
|