sunabamail 0.1.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 856ebc548796776b7b192691b54668c2e81c9c2cfceb62b2057ab9358071270c
4
- data.tar.gz: fa2b1dcb6033d4f6ad9a2af74937d07c03b2b8bdbfb2e91d2a9b11c9dd012d2e
3
+ metadata.gz: 86fa2cbd66cd2b674fc60d64b7f357924a398da46e3173d1a676b1738162692b
4
+ data.tar.gz: e2f9a4c6068f887976d9829a559e2e82e5297b122574423fb009bc51e22afb3a
5
5
  SHA512:
6
- metadata.gz: fa0b4dc118595c7eb59f2d368c719925ba0e90cdb4bc6b661d9d46083306fcb706c1e8396dbabc9cd4fa22507e12cd7fab8df76eff91bd9ba829b0f1610c37dd
7
- data.tar.gz: ec79d435cba4ddfaf3bc7dae08b8abc5a2bf8ed2655172242fe7406f495baf387f1bd5cb35ac786b49bc4a2ed6f0ac1fc9be6459bbbe69391aa9a4ed398c05fe
6
+ metadata.gz: 97ba1d5662b8233af2c239e5e499a9ba5f288f31de768815f7a010d0b650ca8b4b5191a72cd90b4d18ebbdbf8eaeaaf38137f130cc77201031f548217def5bf1
7
+ data.tar.gz: 579a729a89976eef5c1a8f2852bcd1562442592b536e5999c721316b6fa643747e0c023c4d5b71b7565ca4e94f765c472e0b8524c0ff60f77ee3f2fdfed87674
@@ -15,7 +15,6 @@ jobs:
15
15
  matrix:
16
16
  ruby: ['3.1', '3.2', '3.3', '3.4', '4.0']
17
17
  rails:
18
- - '~> 7.0.0'
19
18
  - '~> 7.1.0'
20
19
  - '~> 7.2.0'
21
20
  - '~> 8.0.0'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2026-05-07
4
+
5
+ - fix Rails 7.x does't work.
6
+ - Changed the lower version to 7.1 due to several issues, including differences in the DB schema.
7
+
3
8
  ## [0.1.0] - 2026-05-06
4
9
 
5
10
  - Initial release
@@ -1,4 +1,2 @@
1
1
  class Sunabamail::ApplicationController < ActionController::Base
2
- # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3
- allow_browser versions: :modern
4
2
  end
@@ -4,6 +4,6 @@ class Sunabamail::Messages::ApplicationController < Sunabamail::ApplicationContr
4
4
  private
5
5
 
6
6
  def set_message
7
- @message = Sunabamail::Message.find(params.expect(:message_id))
7
+ @message = Sunabamail::Message.find(params[:message_id])
8
8
  end
9
9
  end
@@ -8,6 +8,6 @@ class Sunabamail::Messages::AttachmentsController < Sunabamail::Messages::Applic
8
8
  private
9
9
 
10
10
  def set_attachment
11
- @attachment = @message.mail.attachments[params.expect(:id).to_i]
11
+ @attachment = @message.mail.attachments[params[:id].to_i]
12
12
  end
13
13
  end
@@ -1,6 +1,6 @@
1
1
  class Sunabamail::Messages::HtmlsController < Sunabamail::Messages::ApplicationController
2
2
  def show
3
- html = @message.mail.html_part.body.to_s.force_encoding(@message.mail.charset)
3
+ html = @message.mail.html_body
4
4
  doc = Nokogiri::HTML.fragment(html)
5
5
  doc.css("a").each do |a|
6
6
  a["target"] = "_blank"
@@ -1,7 +1,7 @@
1
1
  class Sunabamail::Messages::SourcesController < Sunabamail::Messages::ApplicationController
2
2
  def show
3
- send_data @message.mail.html_part.body.to_s.force_encoding(@message.mail.charset),
4
- type: "text/plain",
5
- disposition: "inline"
3
+ html = @message.mail.html_body
4
+
5
+ send_data html, type: "text/plain", disposition: "inline"
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  class Sunabamail::Messages::TextsController < Sunabamail::Messages::ApplicationController
2
2
  def show
3
- send_data @message.mail.text_part.body.to_s.force_encoding(@message.mail.charset),
4
- type: "text/plain",
5
- disposition: "inline"
3
+ text = @message.mail.text_body
4
+
5
+ send_data text, type: "text/plain", disposition: "inline"
6
6
  end
7
7
  end
@@ -17,6 +17,6 @@ class Sunabamail::MessagesController < Sunabamail::ApplicationController
17
17
  private
18
18
 
19
19
  def set_message
20
- @message = Sunabamail::Message.find(params.expect(:id))
20
+ @message = Sunabamail::Message.find(params[:id])
21
21
  end
22
22
  end
@@ -0,0 +1,49 @@
1
+ class Sunabamail::Mail
2
+ def initialize(raw)
3
+ @mail_message = Mail::Message.new(raw.encoded)
4
+ end
5
+
6
+ def has_text?
7
+ return true if text_part.present?
8
+
9
+ "text/plain" == content_type
10
+ end
11
+
12
+ def has_html?
13
+ return true if html_part.present?
14
+
15
+ "text/html" == content_type
16
+ end
17
+
18
+ def text_body
19
+ if multipart?
20
+ part = text_part
21
+ body = part.body
22
+ body.to_s.force_encoding(part.charset)
23
+ elsif "text/plain" == content_type
24
+ body.to_s.force_encoding(mail_message.charset)
25
+ end
26
+ end
27
+
28
+ def html_body
29
+ if multipart?
30
+ part = html_part
31
+ body = part.body
32
+ body.to_s.force_encoding(part.charset)
33
+ elsif "text/html" == content_type
34
+ body.to_s.force_encoding(mail_message.charset)
35
+ end
36
+ end
37
+
38
+ def attachments = mail_message.attachments
39
+
40
+ private
41
+
42
+ attr_reader :mail_message
43
+
44
+ delegate :content_type, :multipart?, :html_part, :text_part, to: :mail_message, private: true
45
+
46
+ def content_type
47
+ mail_message.content_type.to_s.chomp.downcase
48
+ end
49
+ end
@@ -48,23 +48,20 @@
48
48
  </div>
49
49
  <% end %>
50
50
 
51
- <% has_html = mail.html_part.present? %>
52
- <% has_text = mail.text_part.present? %>
53
-
54
51
  <div class="message-views-tabs-container">
55
52
  <div class="message-views-tabs">
56
- <% if has_html %>
53
+ <% if mail.has_html? %>
57
54
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="html">Html</button>
58
55
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="source">Html Source</button>
59
56
  <% end %>
60
- <% if has_text %>
57
+ <% if mail.has_text? %>
61
58
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="text">Text</button>
62
59
  <% end %>
63
60
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="raw">Raw</button>
64
61
  </div>
65
62
  </div>
66
63
 
67
- <% if has_html %>
64
+ <% if mail.has_html? %>
68
65
  <div class="message-view-item" data-mail-view="html">
69
66
  <%= tag.iframe sealmess: "sealmess", data: { src: message_html_path(object) } %>
70
67
  </div>
@@ -72,7 +69,7 @@
72
69
  <%= tag.iframe sealmess: "sealmess", data: { src: message_source_path(object) } %>
73
70
  </div>
74
71
  <% end %>
75
- <% if has_text %>
72
+ <% if mail.has_text? %>
76
73
  <div class="message-view-item" data-mail-view="text">
77
74
  <%= tag.iframe sealmess: "sealmess", data: { src: message_text_path(object) } %>
78
75
  </div>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sunabamail
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunabamail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hamajyotan
@@ -15,42 +15,42 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '7.0'
18
+ version: '7.1'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '7.0'
25
+ version: '7.1'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activerecord
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '7.0'
32
+ version: '7.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '7.0'
39
+ version: '7.1'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: railties
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '7.0'
46
+ version: '7.1'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '7.0'
53
+ version: '7.1'
54
54
  description: Provides a custom Action Mailer delivery method that stores outgoing
55
55
  emails in the database instead of sending them. Stored emails can be viewed through
56
56
  a dedicated interface, making it useful for development and staging environments.
@@ -75,6 +75,7 @@ files:
75
75
  - app/controllers/sunabamail/messages/sources_controller.rb
76
76
  - app/controllers/sunabamail/messages/texts_controller.rb
77
77
  - app/controllers/sunabamail/messages_controller.rb
78
+ - app/models/sunabamail/mail.rb
78
79
  - app/models/sunabamail/message.rb
79
80
  - app/models/sunabamail/message_raw.rb
80
81
  - app/models/sunabamail/record.rb
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
117
  requirements: []
117
- rubygems_version: 4.0.3
118
+ rubygems_version: 4.0.5
118
119
  specification_version: 4
119
120
  summary: A drop-in Action Mailer delivery method that stores emails in the database
120
121
  instead of sending them.