Merge branch 'master' into 5493-getting-started-modal
[arvados.git] / services / api / app / mailers / admin_notifier.rb
1 class AdminNotifier < ActionMailer::Base
2   include AbstractController::Callbacks
3
4   default from: Rails.configuration.admin_notifier_email_from
5
6   def new_user(user)
7     @user = user
8     if not Rails.configuration.new_user_notification_recipients.empty? then
9       @recipients = Rails.configuration.new_user_notification_recipients
10       logger.info "Sending mail to #{@recipients} about new user #{@user.uuid} (#{@user.full_name} <#{@user.email}>)"
11
12       add_to_subject = ''
13       if Rails.configuration.auto_setup_new_users
14         add_to_subject = @user.is_invited ? ' and setup' : ', but not setup'
15       end
16
17       mail(to: @recipients,
18            subject: "#{Rails.configuration.email_subject_prefix}New user created#{add_to_subject} notification"
19           )
20     end
21   end
22
23   def new_inactive_user(user)
24     @user = user
25     if not Rails.configuration.new_inactive_user_notification_recipients.empty? then
26       @recipients = Rails.configuration.new_inactive_user_notification_recipients
27       logger.info "Sending mail to #{@recipients} about new user #{@user.uuid} (#{@user.full_name} <#{@user.email}>)"
28       mail(to: @recipients,
29            subject: "#{Rails.configuration.email_subject_prefix}New inactive user notification"
30           )
31     end
32   end
33
34 end