refactor(email): remove pseudonymization, it will be done at dump-time
This commit is contained in:
parent
d911bc02c0
commit
d58e6a2f9c
4 changed files with 4 additions and 21 deletions
|
@ -23,7 +23,7 @@ class EmailEvent < ApplicationRecord
|
|||
|
||||
to.each do |recipient|
|
||||
EmailEvent.create!(
|
||||
to: pseudonymize_email(recipient),
|
||||
to: recipient,
|
||||
subject: message.subject,
|
||||
processed_at: message.date,
|
||||
method: ActionMailer::Base.delivery_methods.key(message.delivery_method.class),
|
||||
|
@ -33,17 +33,5 @@ class EmailEvent < ApplicationRecord
|
|||
Sentry.capture_exception(error, extra: { subject: message.subject, status: })
|
||||
end
|
||||
end
|
||||
|
||||
def pseudonymize_email(email)
|
||||
username, domain_name = email.split("@")
|
||||
|
||||
username_masked = if username.length > 3
|
||||
username[0..1] + "*" * (username.length - 3) + username[-1]
|
||||
else
|
||||
"*" * username.length
|
||||
end
|
||||
|
||||
"#{username_masked}@#{domain_name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to "Voir aussi les événements d'email", manager_email_events_path("search" => EmailEvent.pseudonymize_email(@user.email)) %>
|
||||
<%= link_to "Voir aussi les événements d'email", manager_email_events_path("search" => @user.email) %>
|
||||
|
||||
<h2 style="font-size: 1.3em; margin: 24px 0 8px 0">Problèmes potentiel</h2>
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ RSpec.describe ApplicationMailer, type: :mailer do
|
|||
|
||||
describe 'EmailDeliveryObserver is invoked' do
|
||||
let(:user1) { create(:user) }
|
||||
let(:user2) { create(:user, email: "thisisyour@email.com") }
|
||||
let(:user2) { create(:user, email: "your@email.com") }
|
||||
|
||||
it 'creates a new EmailEvent record with the correct information' do
|
||||
expect { UserMailer.ask_for_merge(user1, user2.email).deliver_now }.to change { EmailEvent.count }.by(1)
|
||||
event = EmailEvent.last
|
||||
|
||||
expect(event.to).to eq("th*******r@email.com")
|
||||
expect(event.to).to eq("your@email.com")
|
||||
expect(event.method).to eq("test")
|
||||
expect(event.subject).to eq('Fusion de compte')
|
||||
expect(event.processed_at).to be_within(1.second).of(Time.zone.now)
|
||||
|
|
|
@ -1,7 +1,2 @@
|
|||
RSpec.describe EmailEvent, type: :model do
|
||||
describe "#pseudonymize_email" do
|
||||
it { expect(EmailEvent.pseudonymize_email("example@rspec.com")).to eq("ex****e@rspec.com") }
|
||||
it { expect(EmailEvent.pseudonymize_email("exa@rspec.com")).to eq("***@rspec.com") }
|
||||
it { expect(EmailEvent.pseudonymize_email("e@rspec.com")).to eq("*@rspec.com") }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue