undefined method 'name' for #<Array>

This commit is contained in:
Karel Pičman 2023-03-14 10:27:55 +01:00
parent c142af56ab
commit e40966955f
3 changed files with 13 additions and 7 deletions

View File

@ -663,7 +663,7 @@ class DmsfController < ApplicationController
recipients = DmsfMailer.deliver_files_deleted(@project, deleted_files)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
if recipients.any?
to = recipients.collect{ |r| r.name }.first(Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to = recipients.collect{ |user, _| user.name }.first(Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to << ((recipients.count > Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, to: to)
end

View File

@ -184,8 +184,10 @@ class DmsfFilesController < ApplicationController
recipients = DmsfMailer.deliver_files_updated(@project, [@file])
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
if recipients.any?
to = recipients.collect{ |r| r.name }.first(Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to << ((recipients.count > Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i) ? ',...' : '.')
to = recipients.collect{ |user, _| user.name }.first(
Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to << ((recipients.count > Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i) ?
',...' : '.')
end
end
rescue => e
@ -229,8 +231,10 @@ class DmsfFilesController < ApplicationController
recipients = DmsfMailer.deliver_files_deleted(@project, [@file])
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
if recipients.any?
to = recipients.collect{ |r| r.name }.first(Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to << ((recipients.count > Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i) ? ',...' : '.')
to = recipients.collect{ |user, _| user.name }.first(
Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to << ((recipients.count > Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i) ?
',...' : '.')
flash[:warning] = l(:warning_email_notifications, to: to)
end
end

View File

@ -133,8 +133,10 @@ module DmsfUploadHelper
recipients = DmsfMailer.deliver_files_updated(project, files)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to << ((recipients.count > Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i) ? ',...' : '.')
to = recipients.collect{ |user, _| user.name }.first(
Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i).join(', ')
to << ((recipients.count > Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i) ?
',...' : '.')
controller.flash[:warning] = l(:warning_email_notifications, to: to) if controller
end
end