Add managers and sub_managers emails to email_address.

This commit is contained in:
BoHung Chiu 2022-03-16 18:40:47 +08:00
parent fbb84c54f2
commit ae1cb17bfc
1 changed files with 16 additions and 2 deletions

View File

@ -29,9 +29,23 @@ class AskQuestion
def email
mail = Email.find(self.email_id) rescue nil
end
def email_address
email_address = AskAdmin.all.collect{|a| a.email} rescue []
email_address = AskAdmin.pluck(:email).select{|s| s.present?}.uniq rescue []
authorizes = Authorization.where(:module_app_id=>ModuleApp.where(:key=>'ask').first.id).to_a rescue []
authorizes.each do |a|
if a.category_id
next if a.category_id != self.category_id
end
if a.user_id
u = a.user
email_address << u.email if u && u.email
elsif a.role_id
email_address = email_address + MemberProfile.where(:role_ids=>a.role_id).pluck(:email).select{|s| s.present?}.uniq
else
a.destroy
end
end
email_address.uniq!
# email_address = email_address +[self.mail] if !self.mail.blank?
email_address.flatten
end