From f3644a5d49039c6b3397ef80b436b0d2e6a38b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 21 Nov 2023 17:18:12 +0100 Subject: [PATCH] Mail sending from custom workflows #328 --- .../patches/models/mailer_patch.rb | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 lib/redmine_custom_workflows/patches/models/mailer_patch.rb diff --git a/lib/redmine_custom_workflows/patches/models/mailer_patch.rb b/lib/redmine_custom_workflows/patches/models/mailer_patch.rb deleted file mode 100644 index 8570e2c..0000000 --- a/lib/redmine_custom_workflows/patches/models/mailer_patch.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -# Redmine plugin for Custom Workflows -# -# Copyright © 2015-19 Anton Argirov -# Copyright © 2019-23 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -module RedmineCustomWorkflows - module Patches - module Models - # Mailer model patch - module MailerPatch - def self.deliver_custom_email(headers = {}) - user = headers.delete :user - headers[:to] = user.mail if user - text_body = headers.delete :text_body - html_body = headers.delete :html_body - template_name = headers.delete :template_name - template_params = headers.delete(:template_params) || {} - if text_body || html_body - mail headers do |format| - format.text { render text: text_body } if text_body - format.html { render text: html_body } if html_body - end - elsif template_name - template_params.each { |k, v| instance_variable_set("@#{k}", v) } - mail headers do |format| - format.text { render template_name } - format.html { render template_name } unless Setting.plain_text_mail? - end - else - raise StandardError, 'Not :text_body, :html_body or :template_name specified' - end - end - end - end - end -end - -# Apply the patch -if Redmine::Plugin.installed?('easy_extensions') - RedmineExtensions::PatchManager.register_model_patch 'Mailer', 'RedmineCustomWorkflows::Patches::Models::MailerPatch' -else - Mailer.prepend RedmineCustomWorkflows::Patches::Models::MailerPatch -end