From 6221b36b278c02cdbf5b6d1c0753654b506b44fd Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 6 Apr 2022 20:58:12 +0200 Subject: Remove sign-in token authentication, instead send e-mail about new sign-in (#17970) --- app/mailers/user_mailer.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'app/mailers/user_mailer.rb') diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 1a823328c..ce36dd6f5 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -167,9 +167,7 @@ class UserMailer < Devise::Mailer @statuses = @warning.statuses.includes(:account, :preloadable_poll, :media_attachments, active_mentions: [:account]) I18n.with_locale(@resource.locale || I18n.default_locale) do - mail to: @resource.email, - subject: I18n.t("user_mailer.warning.subject.#{@warning.action}", acct: "@#{user.account.local_username_and_domain}"), - reply_to: ENV['SMTP_REPLY_TO'] + mail to: @resource.email, subject: I18n.t("user_mailer.warning.subject.#{@warning.action}", acct: "@#{user.account.local_username_and_domain}") end end @@ -193,7 +191,7 @@ class UserMailer < Devise::Mailer end end - def sign_in_token(user, remote_ip, user_agent, timestamp) + def suspicious_sign_in(user, remote_ip, user_agent, timestamp) @resource = user @instance = Rails.configuration.x.local_domain @remote_ip = remote_ip @@ -201,12 +199,8 @@ class UserMailer < Devise::Mailer @detection = Browser.new(user_agent) @timestamp = timestamp.to_time.utc - return unless @resource.active_for_authentication? - I18n.with_locale(@resource.locale || I18n.default_locale) do - mail to: @resource.email, - subject: I18n.t('user_mailer.sign_in_token.subject'), - reply_to: ENV['SMTP_REPLY_TO'] + mail to: @resource.email, subject: I18n.t('user_mailer.suspicious_sign_in.subject') end end end -- cgit From ce9dcbea32e7212dc19d83bbb7a21afe8756ced0 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 7 Apr 2022 14:47:30 +0200 Subject: Fix failure when sending warning emails with custom text (#17983) * Add tests * Fix failure when sending warning emails with custom text --- app/mailers/user_mailer.rb | 1 + spec/mailers/user_mailer_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'app/mailers/user_mailer.rb') diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index ce36dd6f5..e47bedec6 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -7,6 +7,7 @@ class UserMailer < Devise::Mailer helper :application helper :instance helper :statuses + helper :formatting helper RoutingHelper diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 9c866788f..2ed33c1e4 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -83,4 +83,15 @@ describe UserMailer, type: :mailer do include_examples 'localized subject', 'devise.mailer.email_changed.subject' end + + describe 'warning' do + let(:strike) { Fabricate(:account_warning, target_account: receiver.account, text: 'dont worry its just the testsuite', action: 'suspend') } + let(:mail) { UserMailer.warning(receiver, strike) } + + it 'renders warning notification' do + receiver.update!(locale: nil) + expect(mail.body.encoded).to include I18n.t("user_mailer.warning.title.suspend", acct: receiver.account.acct) + expect(mail.body.encoded).to include strike.text + end + end end -- cgit