diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 5afb8b1..eb7baf2 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -30,7 +30,7 @@ if @role.save if registered deliver_if(recipients: user, key: 'users.added_as_coowner') do |r| - UserMailer.sharing_notification(@role, r).deliver_now + UserMailer.sharing_notification(@role, r, current_user).deliver_now end end flash[:notice] = message diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 1a88646..ce50687 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -11,13 +11,14 @@ end end - def sharing_notification(role, user) + def sharing_notification(role, user, current_user) @role = role @user = user + @current_user = current_user FastGettext.with_locale FastGettext.default_locale do mail(to: @role.user.email, subject: d_('dmpopidor', '%{user_name} has shared a Data Management Plan with you in %{tool_name}') %{ - :user_name => @user.invited_by ? @user.invited_by.name(false) : "A collegue", + :user_name => current_user.name(false), :tool_name => Rails.configuration.branding[:application][:name] }) end diff --git a/app/views/user_mailer/sharing_notification.html.erb b/app/views/user_mailer/sharing_notification.html.erb index fe1667b..fbec00f 100644 --- a/app/views/user_mailer/sharing_notification.html.erb +++ b/app/views/user_mailer/sharing_notification.html.erb @@ -1,6 +1,6 @@ <% tool_name = Rails.configuration.branding[:application][:name] - sender_name = @user.invited_by ? @user.invited_by.name(false) : "A collegue" + sender_name = @current_user.name(false) user_email = @user.name(false) link = url_for(action: 'show', controller: 'plans', id: @role.plan.id) %>