Redmine - 停止通知 - 阴暗模式不起作用

问题描述

我在服务器上安装了 redmine,我已经安装了 3.4 版本的 shady mode 插件并且它可以工作,但现在我已经更新到 4.1 并且无法工作。这个插件允许我启用阴暗模式并停止发送通知

我发现了插件代码的问题,我发现了两个文件,其中两个文件都通过检索用户属性来检查模式是否处于活动状态,在一个文件中,检查实际上有效并且条件返回正确值,在另一个文件(决定是否实际发送电子邮件文件)中,此设置始终为 false(或 null)。

我猜用新版本的redmine,那段代码中的插件找不到变量。

这是有效的文件hook.rb

module RedmineShady 
  module Hook
    class ViewListener < Redmine::Hook::ViewListener
      # necessary for using content_tag in Listener
      attr_accessor :output_buffer
      # If shady,show message on the top
      def view_layouts_base_html_head(context = {})
        session = context[:controller].session
 
        if User.current.pref[:shady]
          style = 'margin: 0; padding: 10px; border-width: 0 0 2px; background-image: none'
 
          content_tag :div,id: 'shady-bar',class: 'flash error',style: style do
            concat link_to l(:button_cancel),{ controller: 'shady',action: 'destroy' },method: :delete,style: 'float: right'
            concat l(:notice_shady_mode)
          end
        end
      end
    end 
  end 
end

这是不起作用的文件mail_interceptor.rb

module RedmineShady
  class MailInterceptor
    def self.delivering_email(message)
 
      message.perform_deliveries = false if User.current.pref[:shady]
    end
  end
end

为什么 User.current.pref[:shady]hook.rb 中有效,而在 mail_interceptor.rb 中无效?

解决方法

在 Redmine 3.4 和 Redmine 4.1 之间,电子邮件通知的发送方式有 changed significantly

具体来说,Redmine 现在在后台呈现和发送通知邮件,而不是在更新请求中等待。此外,现在为每个收件人呈现唯一的邮件。在呈现邮件时,User.current 将设置为相应的收件人(而不是 Redmine 3.4 中的发送用户)。

因此,该插件需要针对 Redmine 4.1 进行更新,并且可能由于 Redmine 的这些更改而需要进行重大的重新架构。