Merge pull request #6729 from artoscinote/ma_SCI_9608

Fix notification mailer [SCI-9608]
This commit is contained in:
Martin Artnik 2023-11-29 11:43:10 +01:00 committed by GitHub
commit a35481adec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 20 deletions

View file

@ -22,4 +22,16 @@ class AppMailer < Devise::Mailer
}.merge(opts)
mail(headers)
end
def general_notification(opts = {})
@user = params[:recipient]
@notification = params[:record].to_notification
mail(
{
to: @user.email,
subject: I18n.t('notifications.email_title')
}.merge(opts)
)
end
end

View file

@ -1,19 +0,0 @@
# frozen_string_literal: true
class NotificationMailer < Devise::Mailer
helper :application, :mailer, :input_sanitize
include Devise::Controllers::UrlHelpers
default template_path: 'users/mailer'
default from: ENV.fetch('MAIL_FROM')
default reply: ENV.fetch('MAIL_REPLYTO')
def general_notification
@user = params[:recipient]
@notification = params[:record].to_notification
mail(
to: @user.email,
subject: I18n.t('notifications.email_title')
)
end
end

View file

@ -2,7 +2,7 @@
class BaseNotification < Noticed::Base
deliver_by :database, if: :database_notification?
deliver_by :email, mailer: 'NotificationMailer', method: :general_notification, if: :email_notification?
deliver_by :email, mailer: 'AppMailer', method: :general_notification, if: :email_notification?
def self.send_notifications(params, later: false)
recipients_class =