15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/models/foreman_tasks/concerns/user_extensions.rb', line 15
def attach_task_mail_notifications
return if ::ForemanSeeder.is_seeding
org_admin_role = Role.find_by(name: 'Organization admin')
admin_by_role = org_admin_role &&
(roles.map(&:id) & ([org_admin_role.id] + org_admin_role.cloned_role_ids)).any?
return unless admin || admin_by_role
notification = MailNotification.find_by(name: 'long_running_tasks')
return if notification.nil?
if user_mail_notifications.none? { |n| n.mail_notification_id == notification.id }
user_mail_notifications.build(mail_notification_id: notification.id, interval: 'Subscribe')
end
end
|