Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract mailadress to .env file #460

Merged
merged 13 commits into from
Nov 21, 2024
2 changes: 1 addition & 1 deletion app/jobs/user_archive_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def create_global_archive_user

User.create!(id: ARCHIVE_USER_ID,
username: 'archived.user',
email: '[email protected]',
email: Rails.application.config.x.ict_email,
first_name: 'Gearchiveerde',
last_name: 'Gebruiker',
address: 'Onbekend',
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
default from: Rails.application.config.x.noreply_email
layout 'mailer'
end
4 changes: 2 additions & 2 deletions app/mailers/mail_smtp_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def enabled_email(mail_alias, password)
# since we do not want to send the password to mail management
def notify_management_enable_email(mail_alias)
@mail_alias = mail_alias
mail to: '[email protected]',
mail to: Rails.application.config.x.mailbeheer_email,
subject: "SMTP account voor #{mail_alias.email} aangemaakt"
end

# Mail to notify the user and mail management that their SMTP is removed
def disabled_email(mail_alias)
@mail_alias = mail_alias
mail to: '[email protected]', bcc: mail_alias.mail_addresses,
mail to: Rails.application.config.x.mailbeheer_email, bcc: mail_alias.mail_addresses,
subject: "SMTP account voor #{mail_alias.email} opgeheven"
end
end
2 changes: 1 addition & 1 deletion app/mailers/user_cleanup_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ def cleanup_email(will_archive_users, archived_users)
' staan op het punt gearchiveerd te worden'
subject = 'Er zijn gebruikers gearchiveerd!' if @will_archive_users.empty?

mail to: '[email protected];[email protected]', subject:
mail to: Rails.application.config.x.privacy_email, subject:
DrumsnChocolate marked this conversation as resolved.
Show resolved Hide resolved
end
end
3 changes: 2 additions & 1 deletion app/mailers/user_export_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def privacy_notification_email(exporting_user, group, fields, description)
@group = group
@fields = fields
@description = description
mail to: '[email protected]', subject: '[Privacy] Er is een database-export gemaakt' # rubocop:disable Rails/I18nLocaleTexts
mail to: Rails.application.config.x.privacy_email,
subject: '[Privacy] Er is een database-export gemaakt' # rubocop:disable Rails/I18nLocaleTexts
end
end
2 changes: 1 addition & 1 deletion app/views/mail_bounce_mailer/address_unknown.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
U heeft geprobeerd een mail te versturen naar een @csvalpha.nl mailadres. Deze kan helaas niet bezorgd worden. Het gebruikte mailadres <b><%= @to %></b> is namelijk niet in gebruik. Controleer het mailadres nogmaals.
<br/><br/>

Mocht u zeker zijn dat het mailadres klopt of niet weten welk mailadres u moet gebruiken kunt u mailen naar [email protected]
Mocht u zeker zijn dat het mailadres klopt of niet weten welk mailadres u moet gebruiken kunt u mailen naar <a href="mailto:<%= Rails.application.config.x.ict_email %>" style="color: #adb5bd"><%= Rails.application.config.x.ict_email %></a>
3 changes: 2 additions & 1 deletion app/views/mail_bounce_mailer/mail_bounced.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Uw bericht met als onderwerp "<%= @subject %>" aan "<%= @to %>" is helaas niet succesvol afgeleverd.<br/>
De reden hiervoor is: <b><%= @reason %></b>. Mocht dit een bericht aan een mailgroep zijn kan het ook zijn dat het bericht maar bij één ontvanger niet is aangekomen.<br/><br/>

Voor meer vragen kunt u mailen naar [email protected]
Voor meer vragen kunt u mailen naar <a href="mailto:<%= Rails.application.config.x.ict_email %>" style="color: #adb5bd"><%= Rails.application.config.x.ict_email %></a>

2 changes: 1 addition & 1 deletion app/views/user_cleanup_mailer/cleanup_email.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- <%= user.full_name %>
<% end %><br/><br/>

Vergeet niet de lidmaatschapsformulieren van deze leden te vernietigd. Als dit gebeurd is zouden we dan op de hoogte kunnen worden gebracht door middel van een mailtje naar [email protected].
Vergeet niet de lidmaatschapsformulieren van deze leden te vernietigd. Als dit gebeurd is zouden we dan op de hoogte kunnen worden gebracht door middel van een mailtje naar <%= Rails.application.config.x.privacy_email %>.

<% end %>
<br/>
Expand Down
5 changes: 5 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,10 @@ class Application < Rails::Application
config.x.google_api_key = credentials.dig(Rails.env.to_sym, :google_api_key)

config.x.healthcheck_ids = credentials.dig(Rails.env.to_sym, :healthcheck_ids)

config.x.noreply_email = ENV.fetch('NOREPLY_EMAIL', '[email protected]')
config.x.ict_email = ENV.fetch('ICT_EMAIL', '[email protected]')
config.x.privacy_email = ENV.fetch('PRIVACY_EMAIL', '[email protected]')
config.x.mailbeheer_email = ENV.fetch('PRIVACY_EMAIL', '[email protected]')
DrumsnChocolate marked this conversation as resolved.
Show resolved Hide resolved
end
end
4 changes: 2 additions & 2 deletions spec/jobs/smtp_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it { expect(mail.bcc).to eq mail_alias.mail_addresses }
it { expect(mail.subject).to eq "Je kunt nu mail versturen vanaf #{mail_alias.email}!" }

it { expect(management_mail.to).to eq ['[email protected]'] }
it { expect(management_mail.to).to eq [Rails.application.config.x.mailbeheer_email] }

it {
expect(management_mail.subject).to eq "SMTP account voor #{mail_alias.email} aangemaakt"
Expand All @@ -47,7 +47,7 @@

it { expect(client).to have_received(:delete_smtp) }
it { expect(mail.bcc).to eq mail_alias.mail_addresses }
it { expect(mail.to).to eq ['[email protected]'] }
it { expect(mail.to).to eq [Rails.application.config.x.mailbeheer_email] }
it { expect(mail.subject).to eq "SMTP account voor #{mail_alias.email} opgeheven" }
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/jobs/user_cleanup_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@

context 'when with will archive and archived users' do
it { expect(ActionMailer::Base.deliveries.count).to eq 1 }
it { expect(email.to).to include '[email protected]' }
it { expect(email.to).to include '[email protected]' }
it { expect(email.to).to include Rails.application.config.x.privacy_email }
DrumsnChocolate marked this conversation as resolved.
Show resolved Hide resolved
it { expect(email.body.to_s).to include(almost_archive_user.full_name) }
it { expect(email.body.to_s).not_to include(user.full_name) }
it { expect(email.body.to_s).to include('Er is 1 gebruiker gearchiveerd.') }
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/user_export_mailer_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
end

it { expect(ActionMailer::Base.deliveries.count).to eq 1 }
it { expect(privacy_notification_email.to.first).to eq '[email protected]' }
it { expect(privacy_notification_email.to).to eq [Rails.application.config.x.privacy_email] }
it { expect(privacy_notification_email.body.to_s).to include(exporting_user.full_name) }
it { expect(privacy_notification_email.body.to_s).to include(group.name) }
it { expect(privacy_notification_email.body.to_s).to include(fields.join(', ')) }
Expand Down
Loading