sincerely 1.1.0 → 1.1.1
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/sincerely/delivery_systems/email_aws_ses.rb +51 -17
- data/lib/sincerely/mixins/notification_model.rb +4 -2
- data/lib/sincerely/version.rb +1 -1
- data/lib/sincerely.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f610f193406b8467ea490b86eafc27b4d9ca87915f12e6fd82d876ed666b8ce
|
|
4
|
+
data.tar.gz: f2a565ef5d052b9c5f3c79afe89e229b364e5c8878cddd22e5f2646d82192948
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 878d3418223faee85c3468f2c751a17fca6765c038c460b1fa5404b392dfc8ee0399c2c1c7869e0eb38f667d73a5f8171f298b59026d1d062a1d4e1a8cdfecfb
|
|
7
|
+
data.tar.gz: 84e458ed67358f5318c03000f8667697ee72d74193184ded28d67e429694f5fbc1efd42186378be708541986b2e023f1284f3b0d47fa1c8663180ba99d922710
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.1.1] - 2026-08-28
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Email delivery now sends a raw MIME message with images embedded inline (via `cid:`) instead of linking to an externally hosted URL, when attachments are provided. Removes the dependency on a publicly reachable host to render images in emails.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `mail` gem dependency, used to build the raw MIME message for inline attachments
|
|
12
|
+
- `Notification#render_content` accepts extra template variables, used to inject the generated `cid:` references before rendering
|
|
13
|
+
|
|
5
14
|
## [1.1.0] - 2026-08-28
|
|
6
15
|
|
|
7
16
|
### Added
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'aws-sdk-sesv2'
|
|
4
|
+
require 'mail'
|
|
4
5
|
|
|
5
6
|
module Sincerely
|
|
6
7
|
module DeliverySystems
|
|
@@ -34,28 +35,61 @@ module Sincerely
|
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def email_options
|
|
37
|
-
opts = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
html: {
|
|
45
|
-
data: notification.render_content(:html)
|
|
46
|
-
},
|
|
47
|
-
text: {
|
|
48
|
-
data: notification.render_content(:text)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
38
|
+
opts = { destination: { to_addresses: [notification.recipient] } }
|
|
39
|
+
if attachments.present?
|
|
40
|
+
opts[:content] = { raw: { data: raw_message } }
|
|
41
|
+
else
|
|
42
|
+
opts[:from_email_address] = template.sender
|
|
43
|
+
opts[:content] = { simple: simple_content }
|
|
44
|
+
end
|
|
54
45
|
config_set = options[:configuration_set_name]
|
|
55
46
|
opts = opts.merge(configuration_set_name: config_set) if config_set.present?
|
|
56
47
|
opts
|
|
57
48
|
end
|
|
58
49
|
|
|
50
|
+
def simple_content
|
|
51
|
+
{
|
|
52
|
+
subject: { data: subject },
|
|
53
|
+
body: {
|
|
54
|
+
html: { data: notification.render_content(:html) },
|
|
55
|
+
text: { data: notification.render_content(:text) }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def attachments
|
|
61
|
+
notification.delivery_options_hash.fetch('attachments', [])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def raw_message
|
|
65
|
+
message = Mail.new
|
|
66
|
+
message.from = template.sender
|
|
67
|
+
message.to = notification.recipient
|
|
68
|
+
message.subject = subject
|
|
69
|
+
|
|
70
|
+
cid_by_variable = attach_inline_images(message)
|
|
71
|
+
text_body = notification.render_content(:text, cid_by_variable)
|
|
72
|
+
html_body = notification.render_content(:html, cid_by_variable)
|
|
73
|
+
|
|
74
|
+
message.text_part = Mail::Part.new { body text_body }
|
|
75
|
+
message.html_part = Mail::Part.new do
|
|
76
|
+
content_type 'text/html; charset=UTF-8'
|
|
77
|
+
body html_body
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
message.to_s
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def attach_inline_images(message)
|
|
84
|
+
attachments.each_with_object({}) do |attachment, cid_by_variable|
|
|
85
|
+
message.attachments.inline[attachment['filename']] = {
|
|
86
|
+
mime_type: attachment['mime_type'],
|
|
87
|
+
content: attachment['content']
|
|
88
|
+
}
|
|
89
|
+
cid_by_variable[attachment['variable']] = message.attachments[attachment['filename']].url
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
59
93
|
def subject
|
|
60
94
|
raw_subject = notification.delivery_options_hash.fetch('subject', nil) || template.subject || ''
|
|
61
95
|
template.renderer.render(raw_subject, notification.delivery_options_hash)
|
|
@@ -67,8 +67,10 @@ module Sincerely
|
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
def render_content(content_type)
|
|
71
|
-
|
|
70
|
+
def render_content(content_type, extra_template_data = {})
|
|
71
|
+
options = delivery_options_hash
|
|
72
|
+
merged_template_data = (options['template_data'] || {}).merge(extra_template_data.stringify_keys)
|
|
73
|
+
template.render(content_type, options.merge('template_data' => merged_template_data))
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
def delivery_options_hash
|
data/lib/sincerely/version.rb
CHANGED
data/lib/sincerely.rb
CHANGED
|
@@ -17,4 +17,4 @@ require_relative 'sincerely/services/events/aws_ses_complaint_event'
|
|
|
17
17
|
require_relative 'sincerely/services/events/aws_ses_open_event'
|
|
18
18
|
require_relative 'sincerely/templates/email_liquid_template'
|
|
19
19
|
require_relative 'sincerely/version'
|
|
20
|
-
require_relative 'sincerely/engine' if defined?(Rails)
|
|
20
|
+
require_relative 'sincerely/engine' if defined?(Rails::Engine)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sincerely
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 100 Starlings
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '5.5'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: mail
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2.7'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2.7'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: railties
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|