mail-notify 1.2.0 → 2.1.0

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.
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mail
4
- module Notify
5
- module MailersController
6
- def preview
7
- @email_action = File.basename(params[:path])
8
- return super unless @preview.email_exists?(@email_action)
9
-
10
- @email = @preview.call(@email_action, params)
11
-
12
- return super unless notify?
13
-
14
- return render_part if params[:part]
15
-
16
- render_preview_wrapper
17
- end
18
-
19
- private
20
-
21
- def render_part
22
- # Add the current directory to the view path so that Rails can find
23
- # the `govuk_notify_layout` layout
24
- append_view_path(__dir__)
25
-
26
- response.content_type = "text/html"
27
- render html: @email.preview.html.html_safe, layout: "govuk_notify_layout"
28
- end
29
-
30
- def render_preview_wrapper
31
- @part = @email
32
- render action: "email", layout: false, formats: %i[html]
33
- end
34
-
35
- def notify?
36
- @email.delivery_method.instance_of?(Mail::Notify::DeliveryMethod)
37
- end
38
- end
39
- end
40
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mail
4
- module Notify
5
- class Personalisation
6
- BLANK = Object.new
7
-
8
- def initialize(mail)
9
- @body = mail.body.raw_source
10
- @subject = mail.subject
11
- @personalisation = mail[:personalisation]&.unparsed_value || {}
12
- end
13
-
14
- def to_h
15
- merged_options
16
- .reject { |_k, v| v.blank? }
17
- .transform_values { |value| (value == BLANK) ? "" : value }
18
- end
19
-
20
- private
21
-
22
- def merged_options
23
- {
24
- body: @body,
25
- subject: @subject
26
- }.merge(@personalisation)
27
- end
28
- end
29
- end
30
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/mailers_controller"
4
-
5
- module Mail
6
- module Notify
7
- class Railtie < Rails::Railtie
8
- initializer "mail-notify.add_delivery_method", before: "action_mailer.set_configs" do
9
- ActionMailer::Base.add_delivery_method(:notify, Mail::Notify::DeliveryMethod)
10
- end
11
-
12
- initializer "mail-notify.action_controller" do
13
- ActiveSupport.on_load(:action_controller, run_once: true) do
14
- Rails::MailersController.prepend(Mail::Notify::MailersController)
15
- end
16
- end
17
- end
18
- end
19
- end