mailer-log 0.1.9 → 0.1.20
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2489638ab5e297c02635755811795cde996d467515668b69f7b815d78add11c6
|
|
4
|
+
data.tar.gz: 39d8f135491aa8a9dfc22e6de1ff35e985717d8ba53a5773a09380288725f652
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb39ea25f33078b0f64a86a55507e88ec65ce28ab702146637c370a7714a06078e6b74b81ecad33941760ea2681714edef71ba15cbc3d258ae775834a7628410
|
|
7
|
+
data.tar.gz: 36b23844e1e6d8a004cd5228fd3ef1bed1b583e23a7972c31dcaeb320e0376db33e201331231a1bef02a271d2a2e2653e86ae095ca4e2e946de45ed4e3ef5d98
|
|
@@ -2,24 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module MailerLog
|
|
4
4
|
class AdminController < ::AdminsController
|
|
5
|
-
prepend HasScope
|
|
6
|
-
|
|
7
|
-
# Expose main app routes to views for navbar/layout links
|
|
8
|
-
helper Rails.application.routes.url_helpers
|
|
9
|
-
|
|
10
5
|
before_action :authenticate_mailer_log!
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
helper_method :main_app
|
|
14
|
-
|
|
15
|
-
# Override url_options to prevent main app routes from being prefixed
|
|
16
|
-
# with the engine's mount path
|
|
17
|
-
def url_options
|
|
18
|
-
script_name = request.env['SCRIPT_NAME']
|
|
19
|
-
return super unless script_name&.include?('mailer_log') || script_name&.include?('mailer-log') || script_name&.include?('email_log')
|
|
20
|
-
|
|
21
|
-
super.merge(script_name: '')
|
|
22
|
-
end
|
|
7
|
+
rescue_from 'Pundit::NotAuthorizedError', with: :render_not_found
|
|
23
8
|
|
|
24
9
|
private
|
|
25
10
|
|
|
@@ -29,9 +14,8 @@ module MailerLog
|
|
|
29
14
|
MailerLog.configuration.authenticate_with_proc.call(self)
|
|
30
15
|
end
|
|
31
16
|
|
|
32
|
-
def
|
|
33
|
-
|
|
17
|
+
def render_not_found
|
|
18
|
+
raise ActionController::RoutingError, 'Not Found'
|
|
34
19
|
end
|
|
35
|
-
helper_method :mailer_log_engine
|
|
36
20
|
end
|
|
37
21
|
end
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
module MailerLog
|
|
4
4
|
module Api
|
|
5
5
|
class EmailsController < MailerLog::AdminController
|
|
6
|
+
BASE_EMAIL_ATTRIBUTES = %i[
|
|
7
|
+
id tracking_id message_id mailer_class mailer_action
|
|
8
|
+
from_address to_addresses cc_addresses bcc_addresses
|
|
9
|
+
subject domain status delivered_at opened_at clicked_at
|
|
10
|
+
bounced_at created_at updated_at
|
|
11
|
+
].freeze
|
|
12
|
+
BODY_ATTRIBUTES = %i[html_body text_body headers call_stack].freeze
|
|
13
|
+
EVENT_ATTRIBUTES = %i[id event_type occurred_at recipient ip_address user_agent].freeze
|
|
14
|
+
|
|
6
15
|
skip_before_action :verify_authenticity_token, only: [:index, :show]
|
|
7
16
|
|
|
8
17
|
def index
|
|
@@ -40,47 +49,9 @@ module MailerLog
|
|
|
40
49
|
end
|
|
41
50
|
|
|
42
51
|
def email_json(email, include_body: false, include_events: false)
|
|
43
|
-
data =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
message_id: email.message_id,
|
|
47
|
-
mailer_class: email.mailer_class,
|
|
48
|
-
mailer_action: email.mailer_action,
|
|
49
|
-
from_address: email.from_address,
|
|
50
|
-
to_addresses: email.to_addresses,
|
|
51
|
-
cc_addresses: email.cc_addresses,
|
|
52
|
-
bcc_addresses: email.bcc_addresses,
|
|
53
|
-
subject: email.subject,
|
|
54
|
-
domain: email.domain,
|
|
55
|
-
status: email.status,
|
|
56
|
-
delivered_at: email.delivered_at,
|
|
57
|
-
opened_at: email.opened_at,
|
|
58
|
-
clicked_at: email.clicked_at,
|
|
59
|
-
bounced_at: email.bounced_at,
|
|
60
|
-
created_at: email.created_at,
|
|
61
|
-
updated_at: email.updated_at
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if include_body
|
|
65
|
-
data[:html_body] = email.html_body
|
|
66
|
-
data[:text_body] = email.text_body
|
|
67
|
-
data[:headers] = email.headers
|
|
68
|
-
data[:call_stack] = email.call_stack
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
if include_events
|
|
72
|
-
data[:events] = email.events.recent.map do |event|
|
|
73
|
-
{
|
|
74
|
-
id: event.id,
|
|
75
|
-
event_type: event.event_type,
|
|
76
|
-
occurred_at: event.occurred_at,
|
|
77
|
-
recipient: event.recipient,
|
|
78
|
-
ip_address: event.ip_address,
|
|
79
|
-
user_agent: event.user_agent
|
|
80
|
-
}
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
52
|
+
data = email.slice(*BASE_EMAIL_ATTRIBUTES)
|
|
53
|
+
data.merge!(email.slice(*BODY_ATTRIBUTES)) if include_body
|
|
54
|
+
data[:events] = email.events.recent.map { _1.slice(*EVENT_ATTRIBUTES) } if include_events
|
|
84
55
|
data
|
|
85
56
|
end
|
|
86
57
|
end
|
data/lib/mailer_log/version.rb
CHANGED