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: d4126d246df4b031556df419f2fc9c2ea85b2ff1290947e6d832121ff9684672
4
- data.tar.gz: 4b6e0c00f59e2210324d7d9d2e3d6ccb74210984d31c54b702428cd6e801b231
3
+ metadata.gz: 2489638ab5e297c02635755811795cde996d467515668b69f7b815d78add11c6
4
+ data.tar.gz: 39d8f135491aa8a9dfc22e6de1ff35e985717d8ba53a5773a09380288725f652
5
5
  SHA512:
6
- metadata.gz: f95a160a50060fec7b7a67f1eeca4f62e5bfe3b15d43d5630113e08bc3497329c8fd674e185567ba8a5ab4f15eb8feb5090f021b4ce3ac0c4261c66ba75728a1
7
- data.tar.gz: 804f2fbeb927c8f963a08dee20a12bbc8cc3d977343a3195443c93999b324bea60258f641d5d51b6aaab0874a896e2cec75ef5320e7f1a0d14c2ded5a7ec7d08
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
- # Make main_app proxy available in views
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 mailer_log_engine
33
- MailerLog::Engine.routes.url_helpers
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
- id: email.id,
45
- tracking_id: email.tracking_id,
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MailerLog
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.20'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailer-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrafficRunners