rails_mail 0.9.2 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a5b082815997cb25d49acaec8336d565dd9c03a1a4a0d98d453fd16cf4eb515
4
- data.tar.gz: a1c6f9008760194eb79874ae695db11ffce158316fb14cac0ed6584889fa0bae
3
+ metadata.gz: 3b68a7af3f8450340634593140b18052ec4ca26d240c7779a639c80b5b03f3c9
4
+ data.tar.gz: 48c3cc14e90bc5948eae038b7be1b0ce0501efe81e46974a4d1d469a56acee54
5
5
  SHA512:
6
- metadata.gz: b48e6c395e19ba01bea9290bd66e1f006347868f8f327b80c5c2dca5002cd1b14de5d00cfea7d1f4bfb5b4be80e153967b26597ff16e105fde4903b4bdb57ded
7
- data.tar.gz: d8821e83718954273d9fe6d1211ae8ae4b6f88762cab0a05c4c7dc9a9e35efc1f5a62bc3424a9e80bf50e2c9739dec8404c267e8d05c69dfe79614fccd46c097
6
+ metadata.gz: 47a9c4410d756bb79a7475f0e7f207458d40aa5163007155dfc7bfa52bf9587526119a426f1c8e57829abf9b762470fccdf0639b8815858bcda8846f210fe061
7
+ data.tar.gz: 911f7d8d8cefe26660bc32a07c736d47a4d9d9c82cb38f4385aff2c349a9cee3a4ec50a4528d0844750d44658d9bf2979499ae7b77614010536d394d64786324
data/README.md CHANGED
@@ -15,8 +15,10 @@ RailsMail saves all outgoing emails to your database instead of actually sending
15
15
  * Clean, responsive UI for viewing email contents
16
16
  * Optional authentication support
17
17
  * Trimming emails older than a specified duration or a maximum number of emails
18
- * Ability to manually clear emails out and turn on/off that functionality based on environment (eg, so that in Staging, other stakeholders can't clear emails out, but in dev sometimes you want a clean slate)
18
+ * Ability to manually clear emails in bulk or individually. The bulk delete can be turned on/off based on environment (eg, so that in Staging, other stakeholders can't clear emails out, but in dev sometimes you want a clean slate)
19
19
  * Dynamic time ago in words using date-fns
20
+ * Ability to customize how the job that trims emails is enqueued
21
+ * Ability to customize the title in the top left of the page via a standard Rails view that overrides the engine's default view.
20
22
 
21
23
  ## Installation
22
24
 
@@ -78,7 +80,7 @@ To use RailsMail in your application:
78
80
  3. **Configure the initializer**
79
81
  See the [Configuration](#configuration) section for more details.
80
82
 
81
- 4. **Visit `/rails_mail` in your browser to view all captured emails.**
83
+ 4. **Visit `/rails_mail` (or where ever you mounted the engine) in your browser to view all captured emails.**
82
84
 
83
85
  ### Configuration
84
86
 
@@ -112,6 +114,13 @@ end
112
114
  - `trim_emails_max_count`: Keeps only the N most recent emails, deleting older ones.
113
115
  - `sync_via`: Controls whether the trimming job runs synchronously (:now) or asynchronously (:later)
114
116
 
117
+ ### Customize the title
118
+ Since this is a Rails engine, you can customize the title by creating a file at `app/views/layouts/rails_mail/_title.html.erb`.
119
+
120
+ ```erb
121
+ <h1 class="text-xl font-bold">My apps mails</h1>
122
+ ```
123
+
115
124
  ## Authentication
116
125
  Authentication is optional, but recommended and will depend on your application's authentication setup. This gem provides an `authentication_callback` that you can configure in the initializer which is helpful for Authlogic. If you are using Devise, you can simply wrap the mount point of the engine.
117
126
 
@@ -1,7 +1,9 @@
1
1
  module RailsMail
2
2
  class BaseController < ActionController::Base
3
3
  layout "rails_mail/application"
4
- helper TurboHelper if defined?(TurboHelper)
4
+ helper RailsMail::TurboHelper
5
+ include RailsMail::TurboHelper
6
+
5
7
  before_action :authenticate!
6
8
 
7
9
  private
@@ -17,6 +17,8 @@ module RailsMail
17
17
  def show
18
18
  @emails = Email.order(created_at: :desc)
19
19
  @email = Email.find(params[:id])
20
+ session[:current_email_id] = @email.id
21
+
20
22
  if request.headers["Turbo-Frame"]
21
23
  render partial: "rails_mail/emails/show", locals: { email: @email }
22
24
  else
@@ -24,16 +26,22 @@ module RailsMail
24
26
  end
25
27
  end
26
28
 
29
+ def destroy
30
+ @email = Email.find(params[:id])
31
+ @current_email_id = session[:current_email_id]
32
+ @email.destroy
33
+
34
+ respond_to do |format|
35
+ format.html { redirect_to emails_path }
36
+ format.turbo_stream
37
+ end
38
+ end
39
+
27
40
  def destroy_all
28
- # Email.destroy_all
41
+ Email.destroy_all
29
42
  respond_to do |format|
30
43
  format.html { redirect_to emails_path }
31
- format.turbo_stream {
32
- render turbo_stream: [
33
- turbo_stream.update("email-sidebar", ""),
34
- turbo_stream.update("email_content", partial: "empty_state")
35
- ]
36
- }
44
+ format.turbo_stream
37
45
  end
38
46
  end
39
47
  end
@@ -1,12 +1,14 @@
1
1
  import { Application } from "stimulus";
2
2
  import "turbo";
3
3
  import EmailHighlightController from "email_highlight_controller";
4
+ import RedirectController from "redirect_controller";
4
5
  import AutoSubmit from 'auto_submit'
5
6
  import Timeago from 'timeago'
6
7
 
7
8
  const application = Application.start();
8
9
 
9
10
  application.register("email-highlight", EmailHighlightController);
11
+ application.register("redirect", RedirectController);
10
12
  application.register('auto-submit', AutoSubmit)
11
13
  application.register('timeago', Timeago)
12
14
 
@@ -4,7 +4,7 @@ export default class extends Controller {
4
4
  static targets = ["link"]
5
5
 
6
6
  // Define the Tailwind class as a static property
7
- static activeClass = "bg-gray-100"
7
+ static activeClass = "bg-gray-300"
8
8
 
9
9
  connect() {
10
10
  console.log("EmailHighlightController connected")
@@ -19,14 +19,14 @@ export default class extends Controller {
19
19
 
20
20
  // Called when a link is clicked
21
21
  highlight(event) {
22
- // Remove active class from all links
22
+ // Remove active class from all email containers
23
23
  this.linkTargets.forEach(link => {
24
- link.classList.remove(this.constructor.activeClass)
24
+ link.closest(".group").classList.remove(this.constructor.activeClass)
25
25
  })
26
26
 
27
- // Add active class to clicked link
27
+ // Add active class to clicked email's container
28
28
  const clickedLink = event.currentTarget
29
- clickedLink.classList.add(this.constructor.activeClass)
29
+ clickedLink.closest(".group").classList.add(this.constructor.activeClass)
30
30
  }
31
31
 
32
32
  highlightCurrentEmail() {
@@ -35,12 +35,13 @@ export default class extends Controller {
35
35
  if (emailContent) {
36
36
  const currentEmailId = emailContent.dataset.emailId
37
37
 
38
- // Highlight the link with the matching email ID
38
+ // Highlight the container with the matching email ID
39
39
  this.linkTargets.forEach(link => {
40
+ const container = link.closest(".group")
40
41
  if (link.dataset.emailId === currentEmailId) {
41
- link.classList.add(this.constructor.activeClass)
42
+ container.classList.add(this.constructor.activeClass)
42
43
  } else {
43
- link.classList.remove(this.constructor.activeClass)
44
+ container.classList.remove(this.constructor.activeClass)
44
45
  }
45
46
  })
46
47
  }
@@ -0,0 +1,9 @@
1
+ import { Controller } from 'stimulus'
2
+
3
+ export default class extends Controller {
4
+ static values = { url: String }
5
+ connect () {
6
+ // window.location.href = this.urlValue
7
+ Turbo.visit(this.urlValue)
8
+ }
9
+ }
@@ -1,6 +1,6 @@
1
1
  module RailsMail
2
2
  module TurboHelper
3
- def turbo_frame_tag(name, src: nil, &block)
3
+ def rails_mail_turbo_frame_tag(name, src: nil, &block)
4
4
  tag.turbo_frame id: name, src: src do
5
5
  if block_given?
6
6
  yield
@@ -8,7 +8,7 @@ module RailsMail
8
8
  end
9
9
  end
10
10
 
11
- def turbo_stream_from(*streamables, **attributes)
11
+ def rails_mail_turbo_stream_from(*streamables, **attributes)
12
12
  return unless defined?(::ActionCable)
13
13
 
14
14
  raise ArgumentError, "streamables can't be blank" unless streamables.any?(&:present?)
@@ -18,7 +18,7 @@ module RailsMail
18
18
  tag.turbo_cable_stream_source(**attributes)
19
19
  end
20
20
 
21
- def turbo_stream
21
+ def rails_mail_turbo_stream
22
22
  TurboStreamBuilder.new
23
23
  end
24
24
 
@@ -31,6 +31,10 @@ module RailsMail
31
31
  build_stream("prepend", target, content)
32
32
  end
33
33
 
34
+ def update(target:, content:)
35
+ build_stream("update", target, content)
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def build_stream(action, target, content)
@@ -12,6 +12,8 @@ module RailsMail
12
12
  if RailsMail.configuration.trim_emails_max_count
13
13
  trim_by_count
14
14
  end
15
+ rescue StandardError => e
16
+ Rails.logger.error "RailsMail::TrimJob#perform Failed: #{e.message}"
15
17
  end
16
18
 
17
19
  private
@@ -6,7 +6,7 @@ module RailsMail
6
6
  validates :to, presence: true
7
7
 
8
8
  after_create_commit :broadcast_email
9
- after_create :schedule_trim_job
9
+ after_create_commit :enqueue_trim_job
10
10
 
11
11
  scope :search, ->(query) {
12
12
  where("CAST(data AS CHAR) LIKE :q", q: "%#{query}%")
@@ -19,6 +19,11 @@ module RailsMail
19
19
  def html?
20
20
  content_type&.include?("text/html")
21
21
  end
22
+
23
+ def next_email
24
+ RailsMail::Email.where("id < ?", id).last || RailsMail::Email.first
25
+ end
26
+
22
27
  private
23
28
 
24
29
  def broadcast_email
@@ -30,16 +35,14 @@ module RailsMail
30
35
  partial: "rails_mail/shared/email",
31
36
  locals: { email: self }
32
37
  )
33
- rescue NameError => e
34
- Rails.logger.debug "Skipping broadcast: #{e.message}"
38
+ rescue StandardError => e
39
+ Rails.logger.error "RailsMail::Email#broadcast_email failed: #{e.message}"
35
40
  end
36
41
 
37
- def schedule_trim_job
38
- if RailsMail.configuration.trim_via == :perform_now
39
- RailsMail::TrimEmailsJob.perform_now
40
- else
41
- RailsMail::TrimEmailsJob.perform_later
42
- end
42
+ def enqueue_trim_job
43
+ RailsMail.configuration.enqueue_trim_job.call(self)
44
+ rescue StandardError => e
45
+ Rails.logger.error "RailsMail::Email#enqueue_trim_job Failed: #{e.message}"
43
46
  end
44
47
  end
45
48
  end
@@ -0,0 +1 @@
1
+ <h1 class="text-xl font-bold">Rails Mail</h1>
@@ -17,18 +17,35 @@
17
17
  </head>
18
18
 
19
19
  <body class="bg-gray-100">
20
- <div class="flex h-screen">
20
+ <div class="flex h-screen relative">
21
+ <!-- Mobile menu checkbox (hidden) -->
22
+ <input type="checkbox" class="hidden peer" id="sidebar-toggle">
23
+
24
+ <!-- Collapsed menu button -->
25
+ <label for="sidebar-toggle" class="lg:hidden fixed top-4 left-4 z-20 p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 cursor-pointer peer-checked:hidden">
26
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
27
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
28
+ </svg>
29
+ </label>
30
+
21
31
  <!-- Sidebar -->
22
- <div class="w-80 bg-white border-r border-gray-200 flex flex-col">
32
+ <div class="fixed lg:static inset-y-0 left-0 transform -translate-x-full peer-checked:translate-x-0 lg:translate-x-0 transition duration-200 ease-in-out w-80 bg-white border-r border-gray-200 flex flex-col z-10">
23
33
  <div class="flex-none p-4">
24
- <div class="flex items-center justify-between">
25
- <div class="flex items-center">
26
- <%= link_to root_path, class: "text-gray-900" do %>
27
- <h1 class="text-xl font-bold">Rails Mail</h1>
28
- <% end %>
29
- </div>
34
+ <div class="flex items-center justify-between w-full">
35
+ <!-- Menu icon (visible only on mobile) -->
36
+ <label for="sidebar-toggle" class="lg:hidden p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 cursor-pointer">
37
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
38
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
39
+ </svg>
40
+ </label>
41
+
42
+ <!-- Title (centered) -->
43
+ <%= link_to root_path, class: "text-gray-900" do %>
44
+ <%= render "layouts/rails_mail/title" %>
45
+ <% end %>
30
46
 
31
- <% if instance_eval(&RailsMail.show_clear_button?) %>
47
+ <!-- Clear All button (or empty div for spacing when button is hidden) -->
48
+ <% if instance_eval(&RailsMail.show_clear_button?) %>
32
49
  <%= button_to destroy_all_emails_path,
33
50
  class: "text-sm text-gray-600 hover:text-gray-900",
34
51
  form: { data: { turbo_confirm: "Are you sure you want to clear all emails?" } },
@@ -40,6 +57,8 @@
40
57
  Clear All
41
58
  </div>
42
59
  <% end %>
60
+ <% else %>
61
+ <div class="w-[88px]"></div> <!-- Placeholder to maintain spacing when button is hidden -->
43
62
  <% end %>
44
63
  </div>
45
64
  </div>
@@ -60,8 +79,8 @@
60
79
  </div>
61
80
 
62
81
  <!-- Main content -->
63
- <div class="flex-1 overflow-y-auto">
64
- <div class="p-8">
82
+ <div class="flex-1 overflow-y-auto lg:ml-0">
83
+ <div class="p-8 lg:p-8 sm:p-4">
65
84
  <turbo-frame id="email_content">
66
85
  <%= yield %>
67
86
  </turbo-frame>
@@ -1,4 +1,4 @@
1
- <%= turbo_frame_tag "email_content" do %>
1
+ <%= rails_mail_turbo_frame_tag "email_content" do %>
2
2
  <div class="bg-white shadow rounded-lg" data-email-id="<%= email.id %>"
3
3
  data-email-highlight-current-id-value="<%= email.id %>">
4
4
  <div class="px-6 py-4 border-b border-gray-200">
@@ -0,0 +1,21 @@
1
+ <turbo-stream action="remove" target="<%= dom_id(@email) %>">
2
+ </turbo-stream>
3
+
4
+ <% if RailsMail::Email.count == 0 %>
5
+ <turbo-stream action="update" target="email_content">
6
+ <template>
7
+ <%= render(partial: "rails_mail/emails/empty_state", formats: [ :html ]) %>
8
+ </template>
9
+ </turbo-stream>
10
+ <% elsif @email.id == @current_email_id.to_i%>
11
+ <turbo-stream action="update" target="email_content">
12
+ <template>
13
+ <div class="" data-controller="redirect" data-redirect-url-value="<%= email_path(@email.next_email) %>">
14
+ <div class="flex justify-center items-center min-h-screen">
15
+ <div class="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900"></div>
16
+ </div>
17
+ </div>
18
+ </template>
19
+ </turbo-stream>
20
+
21
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <turbo-stream action="update" target="email-sidebar">
2
+ <template>
3
+ </template>
4
+ </turbo-stream>
5
+ <turbo-stream action="update" target="email_content">
6
+ <template>
7
+ <%= render(partial: "rails_mail/emails/empty_state", formats: [ :html ]) %>
8
+ </template>
9
+ </turbo-stream>
@@ -1,5 +1,5 @@
1
1
  <% if @email.present? %>
2
- <%= turbo_frame_tag "email_content", src: email_path(@email) do %>
2
+ <%= rails_mail_turbo_frame_tag "email_content", src: email_path(@email) do %>
3
3
  <div class="bg-white shadow rounded-lg">
4
4
  <div class="px-6 py-4">
5
5
  <div class="animate-pulse">
@@ -1,4 +1,4 @@
1
- <%= turbo_frame_tag "email_content" do %>
1
+ <%= rails_mail_turbo_frame_tag "email_content" do %>
2
2
  <div class="bg-white shadow rounded-lg">
3
3
  <div class="px-6 py-4 border-b border-gray-200">
4
4
  <h1 class="text-2xl font-semibold text-gray-900"><%= @email.subject %></h1>
@@ -1,25 +1,43 @@
1
1
  <%
2
2
  on_current_page = current_page?(RailsMail::Engine.routes.url_helpers.email_path(email))
3
- highlight_class = on_current_page ? 'bg-gray-100' : ''
3
+ highlight_class = on_current_page ? 'bg-gray-300' : ''
4
4
  %>
5
- <%= link_to RailsMail::Engine.routes.url_helpers.email_path(email),
6
- class: "block px-3 py-2 rounded-md hover:bg-gray-50 #{highlight_class} active:bg-gray-100 focus:bg-gray-100",
7
- data: {
8
- "turbo-frame": "email_content",
9
- "turbo-action": "advance",
10
- "turbo-prefetch": "false",
11
- "email-highlight-target": "link",
12
- "email-id": email.id,
13
- action: "click->email-highlight#highlight"
14
- } do %>
15
- <div class="text-sm font-medium text-gray-900 truncate"><%= email.subject %></div>
16
- <div class="text-xs text-gray-500">
17
- <span class="truncate"><%= email.from %></span>
18
- <time
19
- data-controller="timeago"
20
- data-timeago-datetime-value="<%= email.created_at.iso8601 %>"
21
- data-timeago-refresh-interval-value="1000"
22
- data-timeago-include-seconds-value="true"
23
- class="ml-2 text-gray-400"><%= time_ago_in_words(email.created_at) %> ago</time>
24
- </div>
5
+ <%= content_tag :div, id: dom_id(email), class: "group flex items-center px-3 py-2 hover:bg-gray-200 #{highlight_class} active:bg-gray-300 focus:bg-gray-300" do %>
6
+ <%= link_to RailsMail::Engine.routes.url_helpers.email_path(email),
7
+ class: "flex-1 min-w-0 rounded-md",
8
+ data: {
9
+ "turbo-frame": "email_content",
10
+ "turbo-action": "advance",
11
+ "turbo-prefetch": "false",
12
+ "email-highlight-target": "link",
13
+ "email-id": email.id,
14
+ action: "click->email-highlight#highlight"
15
+ } do %>
16
+ <div class="min-w-0">
17
+ <div class="text-sm font-medium text-gray-900 truncate"><%= email.subject %></div>
18
+ <div class="text-xs text-gray-500">
19
+ <span class="truncate"><%= email.from %></span>
20
+ <time
21
+ data-controller="timeago"
22
+ data-timeago-datetime-value="<%= email.created_at.iso8601 %>"
23
+ data-timeago-refresh-interval-value="1000"
24
+ data-timeago-include-seconds-value="true"
25
+ class="ml-2 text-gray-400"><%= time_ago_in_words(email.created_at) %> ago</time>
26
+ </div>
27
+ </div>
28
+ <% end %>
29
+
30
+ <%= button_to email_path(email, current_email_id: @email.id),
31
+ method: :delete,
32
+ class: "hidden group-hover:block p-1 hover:bg-gray-300 rounded",
33
+ form: {
34
+ data: {
35
+ turbo_confirm: "Are you sure you want to delete this email?",
36
+ turbo_frame: "_top"
37
+ }
38
+ } do %>
39
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-500 transition-colors" fill="none" viewBox="0 0 24 24" stroke="currentColor">
40
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
41
+ </svg>
42
+ <% end %>
25
43
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% if defined?(::ActionCable) %>
2
- <%= turbo_stream_from "rails_mail:emails", channel: "RailsMail::EmailsChannel" %>
2
+ <%= rails_mail_turbo_stream_from "rails_mail:emails", channel: "RailsMail::EmailsChannel" %>
3
3
  <% end %>
4
4
 
5
5
  <div id="email-sidebar" data-controller="email-highlight">
data/config/routes.rb CHANGED
@@ -4,7 +4,7 @@ RailsMail::Engine.routes.draw do
4
4
  get "static/:name", action: :static, as: :frontend_static, constraints: { format: %w[css js] }
5
5
  end
6
6
 
7
- resources :emails, only: [ :index, :show ] do
7
+ resources :emails, only: [ :index, :show, :destroy ] do
8
8
  collection do
9
9
  delete "emails/destroy_all", to: "emails#destroy_all", as: :destroy_all
10
10
  end
@@ -1,23 +1,38 @@
1
1
  # rubocop:disable Layout/CommentIndentation
2
2
 
3
- RailsMail.configure do |config|
4
- # Authentication setup
5
- # if left blank, authentication is skipped
6
- # config.authentication_callback do
7
- # Example implementation for Authlogic:
8
- # user_session = UserSession.find
9
- # msg = Rails.env.development? ? 'Forbidden - make sure you have the correct permission in config/initializers/rails_mail.rb' : 'Not Found'
10
- # raise ActionController::RoutingError.new(msg) unless user_session&.user&.admin?
11
- # end
3
+ Rails.configuration.to_prepare do
4
+ RailsMail.configure do |config|
5
+ # Authentication setup
6
+ # if left blank, authentication is skipped
7
+ # config.authentication_callback do
8
+ # Example implementation for Authlogic:
9
+ # user_session = UserSession.find
10
+ # msg = Rails.env.development? ? 'Forbidden - make sure you have the correct permission in config/initializers/rails_mail.rb' : 'Not Found'
11
+ # raise ActionController::RoutingError.new(msg) unless user_session&.user&.admin?
12
+ # end
12
13
 
13
- config.show_clear_button do
14
- # show clear button in development
15
- # and prefer to trim in non-development environments
16
- # to prevent accidental deletion of emails
17
- Rails.env.development?
18
- end
14
+ config.show_clear_button do
15
+ # show clear button in development
16
+ # and prefer to trim in non-development environments
17
+ # to prevent accidental deletion of emails
18
+ Rails.env.development?
19
+ end
20
+
21
+ config.trim_emails_older_than = 30.days
22
+ config.trim_emails_max_count = 1000
23
+
24
+ # Configure how trim jobs are enqueued
25
+ # You can use perform_now for immediate execution (default):
26
+ # config.enqueue_trim_job = ->(email) { RailsMail::TrimEmailsJob.perform_now }
19
27
 
20
- config.trim_emails_older_than = 30.days
21
- config.trim_emails_max_count = 1000
22
- config.trim_via = :perform_later
28
+ # Or create a custom job class:
29
+ # class CustomTrimEmailsJob < RailsMail::TrimEmailsJob
30
+ # def perform
31
+ # Rails.logger.debug "CustomTrimEmailsJob#perform"
32
+ # super
33
+ # end
34
+ # end
35
+
36
+ # config.enqueue_trim_job = ->(email) { CustomTrimEmailsJob.perform_later }
37
+ end
23
38
  end
@@ -1,21 +1,15 @@
1
1
  module RailsMail
2
2
  class Configuration
3
3
  attr_accessor :authentication_callback, :show_clear_button,
4
- :trim_emails_older_than, :trim_emails_max_count, :trim_via
4
+ :trim_emails_older_than, :trim_emails_max_count,
5
+ :enqueue_trim_job
5
6
 
6
7
  def initialize
7
8
  @authentication_callback = nil
8
9
  @show_clear_button = nil
9
10
  @trim_emails_older_than = nil
10
11
  @trim_emails_max_count = nil
11
- @trim_via = :perform_later
12
- end
13
-
14
- def trim_via=(value)
15
- unless [ :perform_now, :perform_later ].include?(value)
16
- raise ArgumentError, "trim_via must be :now or :later"
17
- end
18
- @trim_via = value
12
+ @enqueue_trim_job = ->(email) { RailsMail::TrimEmailsJob.perform_later }
19
13
  end
20
14
 
21
15
  def authentication_callback=(callback)
@@ -1,3 +1,3 @@
1
1
  module RailsMail
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_mail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Philips
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-30 00:00:00.000000000 Z
11
+ date: 2025-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -69,6 +69,7 @@ files:
69
69
  - app/frontend/rails_mail/modules/consumer.js
70
70
  - app/frontend/rails_mail/modules/email_highlight_controller.js
71
71
  - app/frontend/rails_mail/modules/emails_channel.js
72
+ - app/frontend/rails_mail/modules/redirect_controller.js
72
73
  - app/frontend/rails_mail/modules/timeago.js
73
74
  - app/frontend/rails_mail/style.css
74
75
  - app/frontend/rails_mail/vendor/action_cable.js
@@ -80,11 +81,14 @@ files:
80
81
  - app/helpers/rails_mail/turbo_helper.rb
81
82
  - app/jobs/rails_mail/trim_emails_job.rb
82
83
  - app/models/rails_mail/email.rb
84
+ - app/views/layouts/rails_mail/_title.html.erb
83
85
  - app/views/layouts/rails_mail/application.html.erb
84
86
  - app/views/rails_mail/emails/_email.html.erb
85
87
  - app/views/rails_mail/emails/_empty_state.html.erb
86
88
  - app/views/rails_mail/emails/_form.html.erb
87
89
  - app/views/rails_mail/emails/_show.html.erb
90
+ - app/views/rails_mail/emails/destroy.turbo_stream.erb
91
+ - app/views/rails_mail/emails/destroy_all.turbo_stream.erb
88
92
  - app/views/rails_mail/emails/edit.html.erb
89
93
  - app/views/rails_mail/emails/index.html.erb
90
94
  - app/views/rails_mail/emails/index.turbo_stream.erb