nuntius 1.3.21 → 1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d75772fb2b03f8972790cc21ccc4bbffdc514e92e5020c2cfd3c1015a61550da
4
- data.tar.gz: ee6a3397760d7f18ce525d40493894d0395b24861c3a6ca12f81f7c07cbb62ed
3
+ metadata.gz: 96231ee66f145c33c7c1fea7669be34a28d03c4c8f802cee010c984ad97f30c7
4
+ data.tar.gz: 98c827211fc8a8082710352838744ecb7b646ef4083493eb7078059b1627471b
5
5
  SHA512:
6
- metadata.gz: c17b0f252f59e5ed8da3d37db297b78f197b23cd5e349e168c2bab960b0e7bbc5563a9d2330e7802cba2945ce855e30f9cfead383f6c56541954f225b9ce7acb
7
- data.tar.gz: 5335902adaf5342c364c2e1219877c8855bdf5c00ebc83eaf41a282dd7b884cb94736029af0022fb8888619d4fba683546c47e7e33b80a0cd69a86e0e7c6ecd0
6
+ metadata.gz: d3c2ba2b4663c73fd4ac849b0a94878646b1f32c743be1c7f1db8f9529934920497abb54345f7d35b56f7cd682ecbc710944f3bd89c9a7444f7878b7967b79d4
7
+ data.tar.gz: d54a2dd92af1f92cc40886c4be3bdfea123bdcb9f451abca15b919258f010b2363bc404b3f6f0a7c1f78bf1fb417dc65f0328fca12d98e7c38e9f381a44c963d
data/README.md CHANGED
@@ -64,6 +64,7 @@ class CarMessenger < Nuntius::BaseMessenger
64
64
  pdf = ApplicationController.renderer.new(http_host: object.account.hostname, https: true).render(template: "commercial_invoice/show", formats: [:pdf], assigns: {order: object})
65
65
 
66
66
  attachments << {content: StringIO.new(pdf), content_type: "application/pdf", filename: "commercial_invoice.pdf"}
67
+ # Return false here if you don't want the message to be sent
67
68
  end
68
69
  end
69
70
  ```
@@ -9,7 +9,9 @@ module Nuntius
9
9
  messenger = Nuntius::BaseMessenger.messenger_for_obj(obj).new(obj, event, params)
10
10
  return unless messenger.is_a?(Nuntius::CustomMessenger) || messenger.respond_to?(event.to_sym)
11
11
 
12
- messenger.call
12
+ result = messenger.call
13
+ return if result == false
14
+
13
15
  templates = messenger.templates
14
16
  messenger.dispatch(templates) if templates.present?
15
17
  end
@@ -9,24 +9,24 @@ module Nuntius
9
9
 
10
10
  define_callbacks :action, terminator: ->(_target, result_lambda) { result_lambda.call == false }
11
11
 
12
- attr_reader :attachments, :headers, :event, :object, :params
13
- attr_accessor :templates, :smtp_envelope_from
12
+ attr_reader :attachments, :event, :object, :params
13
+ attr_accessor :templates
14
14
 
15
15
  def initialize(object, event, params = {})
16
16
  @object = object
17
17
  @event = event
18
18
  @params = params
19
19
  @attachments = params.fetch(:attachments, [])
20
- @headers = params.fetch(:headers, {})
21
- @smtp_envelope_from = params[:smtp_envelope_from]
22
20
  end
23
21
 
24
22
  # Calls the event method on the messenger
25
23
  def call
26
24
  select_templates
25
+ result = nil
27
26
  run_callbacks(:action) do
28
- send(@event.to_sym, @object, @params) if respond_to?(@event.to_sym)
27
+ result = send(@event.to_sym, @object, @params) if respond_to?(@event.to_sym)
29
28
  end
29
+ result
30
30
  end
31
31
 
32
32
  # Turns the templates in messages, and dispatches the messages to transports
@@ -37,7 +37,6 @@ module Nuntius
37
37
  @attachments.each do |attachment|
38
38
  msg.add_attachment(attachment)
39
39
  end
40
- apply_mail_overrides(msg)
41
40
 
42
41
  transport = Nuntius::BaseTransport.class_from_name(template.transport).new
43
42
  transport.deliver(msg) if msg.to.present?
@@ -53,12 +52,6 @@ module Nuntius
53
52
  @attachments << attachment
54
53
  end
55
54
 
56
- # Sets an extra header on the resulting message (currently applied by the
57
- # mail transport). Useful for things like "Auto-Submitted" or "Precedence".
58
- def header(key, value)
59
- @headers[key.to_s] = value
60
- end
61
-
62
55
  class << self
63
56
  #
64
57
  # Returns the variable name used in the liquid context
@@ -177,19 +170,6 @@ module Nuntius
177
170
 
178
171
  private
179
172
 
180
- # Persists any messenger-provided mail overrides (extra headers and/or a
181
- # custom SMTP envelope sender) onto the message so they survive the
182
- # transport delivery job and can be applied by the provider.
183
- def apply_mail_overrides(message)
184
- return if @headers.blank? && @smtp_envelope_from.nil?
185
-
186
- mail = {}
187
- mail["headers"] = @headers if @headers.present?
188
- mail["envelope_from"] = @smtp_envelope_from unless @smtp_envelope_from.nil?
189
-
190
- message.metadata = (message.metadata || {}).merge("mail" => mail)
191
- end
192
-
193
173
  # Returns the relevant templates for the object / event combination
194
174
  def select_templates
195
175
  return @templates if @templates
@@ -206,7 +186,7 @@ module Nuntius
206
186
 
207
187
  def liquid_context
208
188
  assigns = @params || {}
209
- instance_variables.reject { |i| %w[@params @object @locale @templates @template_scope @headers @smtp_envelope_from].include? i.to_s }.each do |i|
189
+ instance_variables.reject { |i| %w[@params @object @locale @templates @template_scope].include? i.to_s }.each do |i|
210
190
  assigns[i.to_s[1..]] = instance_variable_get(i)
211
191
  end
212
192
 
@@ -6,9 +6,6 @@ module Nuntius
6
6
  class SmtpMailProvider < BaseProvider
7
7
  transport :mail
8
8
 
9
- # RFC 5321 null reverse-path, used for auto-generated/bounce notifications.
10
- NULL_REVERSE_PATH = "<>"
11
-
12
9
  setting_reader :from_header, required: true, description: "From header (example: Nuntius Messenger <nuntius@entdec.com>)"
13
10
  setting_reader :host, required: true, description: "Host (example: smtp.soverin.net)"
14
11
  setting_reader :port, required: true, description: "Port (example: 578)"
@@ -27,14 +24,16 @@ module Nuntius
27
24
  Mail.new(from: from_header)
28
25
  end
29
26
 
30
- null_sender = apply_mail_overrides(mail)
31
-
32
27
  if Rails.env.test?
33
28
  mail.delivery_method :test
34
- elsif null_sender
35
- mail.delivery_method Nuntius::NullSenderSmtp, smtp_settings
36
29
  else
37
- mail.delivery_method :smtp, smtp_settings
30
+ mail.delivery_method :smtp,
31
+ address: host,
32
+ port: port,
33
+ user_name: username,
34
+ password: password,
35
+ return_response: true,
36
+ ssl: ssl
38
37
  end
39
38
 
40
39
  mail.to = message.to
@@ -84,45 +83,6 @@ module Nuntius
84
83
 
85
84
  private
86
85
 
87
- def smtp_settings
88
- {
89
- address: host,
90
- port: port,
91
- user_name: username,
92
- password: password,
93
- return_response: true,
94
- ssl: ssl
95
- }
96
- end
97
-
98
- # Applies any messenger-provided overrides stored on the message: extra
99
- # headers and/or a custom SMTP envelope sender. Returns true when a null
100
- # reverse-path (+MAIL FROM:<>+) was requested, so the caller can pick the
101
- # delivery method that can actually emit it.
102
- def apply_mail_overrides(mail)
103
- overrides = message.metadata&.dig("mail")
104
- return false if overrides.blank?
105
-
106
- (overrides["headers"] || {}).each do |key, value|
107
- mail.header[key] = value
108
- end
109
-
110
- return false unless overrides.key?("envelope_from")
111
-
112
- envelope_from = overrides["envelope_from"]
113
- if null_reverse_path?(envelope_from)
114
- mail.smtp_envelope_from = NULL_REVERSE_PATH
115
- true
116
- else
117
- mail.smtp_envelope_from = envelope_from
118
- false
119
- end
120
- end
121
-
122
- def null_reverse_path?(value)
123
- value.blank? || value == NULL_REVERSE_PATH
124
- end
125
-
126
86
  def message_url(message)
127
87
  Nuntius::Engine.routes.url_helpers.message_url(message.id, host: Nuntius.config.host(message))
128
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nuntius
4
- VERSION = "1.3.21"
4
+ VERSION = "1.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuntius
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.21
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-29 00:00:00.000000000 Z
11
+ date: 2025-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apnotic
@@ -497,7 +497,6 @@ files:
497
497
  - app/providers/nuntius/firebase_push_provider.rb
498
498
  - app/providers/nuntius/houston_push_provider.rb
499
499
  - app/providers/nuntius/message_bird_sms_provider.rb
500
- - app/providers/nuntius/null_sender_smtp.rb
501
500
  - app/providers/nuntius/slack_slack_provider.rb
502
501
  - app/providers/nuntius/smstools_sms_provider.rb
503
502
  - app/providers/nuntius/smtp_mail_provider.rb
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "mail"
4
-
5
- module Nuntius
6
- # A Mail::SMTP delivery method that sends with a null reverse-path
7
- # (+MAIL FROM:<>+).
8
- #
9
- # The stock Mail::SmtpEnvelope refuses to emit an empty reverse-path
10
- # (it raises on a blank From), and Net::SMTP wraps the address in angle
11
- # brackets, so setting +smtp_envelope_from+ to +"<>"+ would produce the
12
- # invalid +MAIL FROM:<<>>+. This delivery method bypasses Mail::SmtpEnvelope
13
- # and hands an empty reverse-path straight to Net::SMTP, yielding the
14
- # RFC 5321 null sender used by auto-generated/bounce notifications.
15
- class NullSenderSmtp < ::Mail::SMTP
16
- def deliver!(mail)
17
- response = start_smtp_session do |smtp|
18
- smtp.sendmail(mail.encoded, "", mail.smtp_envelope_to)
19
- end
20
-
21
- settings[:return_response] ? response : self
22
- end
23
- end
24
- end