3605: Do .to_i on total_cpu_cores, total_ram_mb, and total_scratch_mb in Node#ping.
[arvados.git] / services / api / app / mailers / admin_notifier.rb
index 871c9019467061bf4a6383ffe491a1ddd4ea8c18..36798bebe94a2f50e4bc2d142e17f5446f152b16 100644 (file)
@@ -1,13 +1,22 @@
 class AdminNotifier < ActionMailer::Base
+  include AbstractController::Callbacks
+
   default from: Rails.configuration.admin_notifier_email_from
+  before_filter :load_variables
 
   def new_user(user)
     @user = user
     if not Rails.configuration.new_user_notification_recipients.empty? then
       @recipients = Rails.configuration.new_user_notification_recipients
       logger.info "Sending mail to #{@recipients} about new user #{@user.uuid} (#{@user.full_name} <#{@user.email}>)"
+
+      add_to_subject = ''
+      if Rails.configuration.auto_setup_new_users
+        add_to_subject = @user.is_invited ? ' and setup' : ', but not setup'
+      end
+
       mail(to: @recipients,
-           subject: "#{Rails.configuration.email_subject_prefix}New user notification"
+           subject: "#{Rails.configuration.email_subject_prefix}New user created#{add_to_subject} notification"
           )
     end
   end
@@ -23,4 +32,15 @@ class AdminNotifier < ActionMailer::Base
     end
   end
 
+private
+  def load_variables
+    if Rails.configuration.respond_to?('workbench_address') and
+       not Rails.configuration.workbench_address.nil? and
+       not Rails.configuration.workbench_address.empty? then
+      @wb_address = Rails.configuration.workbench_address.sub(/\/$/,'') + '/users'
+    else
+      @wb_address = ''
+    end
+  end
+
 end