From f9e7d5536b59b7d88f9be3d044aef3cc20d5b782 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 22 Feb 2024 14:53:49 +0100 Subject: [PATCH] chore: remove mailjet support --- Gemfile | 1 - Gemfile.lock | 17 ---------- app/controllers/manager/users_controller.rb | 1 - app/lib/mailjet/api.rb | 37 --------------------- app/mailers/instructeur_mailer.rb | 1 - app/views/manager/users/emails.html.erb | 8 ++--- config/env.example | 4 --- config/environments/production.rb | 3 +- config/initializers/mailjet.rb | 9 ----- config/secrets.yml | 3 -- 10 files changed, 3 insertions(+), 81 deletions(-) delete mode 100644 app/lib/mailjet/api.rb delete mode 100644 config/initializers/mailjet.rb diff --git a/Gemfile b/Gemfile index 1de871e2b..9838d6719 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,6 @@ gem 'kredis' gem 'listen' # Required by ActiveSupport::EventedFileUpdateChecker gem 'lograge' gem 'logstash-event' -gem 'mailjet', require: false gem 'maintenance_tasks' gem 'matrix' # needed by prawn and not default in ruby 3.1 gem 'mini_magick' diff --git a/Gemfile.lock b/Gemfile.lock index f76380cc8..a06fdd86b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -210,7 +210,6 @@ GEM diff-lcs (1.5.1) discard (1.3.0) activerecord (>= 4.2, < 8) - domain_name (0.6.20240107) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) @@ -305,9 +304,6 @@ GEM hashie (5.0.0) highline (3.0.1) htmlentities (4.3.4) - http-accept (1.7.0) - http-cookie (1.0.5) - domain_name (~> 0.5) http_accept_language (2.1.1) httpclient (2.8.3) i18n (1.14.1) @@ -395,11 +391,6 @@ GEM net-imap net-pop net-smtp - mailjet (1.7.8) - activesupport (>= 5.0.0) - rack (>= 1.4.0) - rest-client (>= 2.1.0) - yajl-ruby maintenance_tasks (2.6.0) actionpack (>= 6.0) activejob (>= 6.0) @@ -433,7 +424,6 @@ GEM timeout net-smtp (0.4.0.1) net-protocol - netrc (0.11.0) nio4r (2.7.0) nokogiri (1.16.2) mini_portile2 (~> 2.8.2) @@ -566,11 +556,6 @@ GEM responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rest-client (2.1.0) - http-accept (>= 1.7.0, < 2.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 4.0) - netrc (~> 0.8) rexml (3.2.6) rodf (1.2.0) builder (>= 3.0) @@ -798,7 +783,6 @@ GEM nokogiri (~> 1.11) xpath (3.2.0) nokogiri (~> 1.8) - yajl-ruby (1.4.3) zeitwerk (2.6.13) zip_tricks (5.6.0) zipline (1.5.0) @@ -878,7 +862,6 @@ DEPENDENCIES listen lograge logstash-event - mailjet maintenance_tasks matrix memory_profiler diff --git a/app/controllers/manager/users_controller.rb b/app/controllers/manager/users_controller.rb index 04535f7e0..effa7043c 100644 --- a/app/controllers/manager/users_controller.rb +++ b/app/controllers/manager/users_controller.rb @@ -68,7 +68,6 @@ module Manager @user = User.find(params[:id]) email_services = [ - Mailjet::API.new, Sendinblue::API.new, Dolist::API.new ] diff --git a/app/lib/mailjet/api.rb b/app/lib/mailjet/api.rb deleted file mode 100644 index 92e135160..000000000 --- a/app/lib/mailjet/api.rb +++ /dev/null @@ -1,37 +0,0 @@ -class Mailjet::API - def properly_configured? - Mailjet.respond_to?(:config) && [Mailjet.config.api_key, Mailjet.config.secret_key].all?(&:present?) - end - - # Get messages sent to a user through SendInBlue. - # - # Returns an array of SentMail objects. - def sent_mails(email_address) - contact = Mailjet::Contact.find(email_address) - if contact.nil? - Rails.logger.info "Mailjet::API: no contact found for email address '#{email_address}'" - return [] - end - - messages = Mailjet::Message.all( - contact: contact.attributes['id'], - from_ts: 30.days.ago.to_datetime.rfc3339, - show_subject: true - ) - - messages.map do |message| - SentMail.new( - from: nil, - to: email_address, - subject: message.attributes['subject'], - delivered_at: message.attributes['arrived_at'], - status: message.attributes['status'], - service_name: 'Mailjet', - external_url: 'https://app.mailjet.com/contacts/subscribers/contact_list' - ) - end - rescue Mailjet::ApiError => e - Rails.logger.error e.message - [] - end -end diff --git a/app/mailers/instructeur_mailer.rb b/app/mailers/instructeur_mailer.rb index 0a2584850..c51452b18 100644 --- a/app/mailers/instructeur_mailer.rb +++ b/app/mailers/instructeur_mailer.rb @@ -17,7 +17,6 @@ class InstructeurMailer < ApplicationMailer @overview = instructeur.last_week_overview if @overview.present? - headers['X-mailjet-campaign'] = 'last_week_overview' mail(to: email, subject: @subject) end end diff --git a/app/views/manager/users/emails.html.erb b/app/views/manager/users/emails.html.erb index d4bdb05ff..7d3737919 100644 --- a/app/views/manager/users/emails.html.erb +++ b/app/views/manager/users/emails.html.erb @@ -22,9 +22,7 @@

Cet historique contient les 30 derniers jours. Pour un recherche plus fine, il faut fouiller les - logs de SendInblue - ou - de Mailjet. + logs de SendInblue.

@@ -71,9 +69,7 @@ <% else %>

Historique indisponible. Cette adresse email n’existe pas chez nos prestataires d’envoi, ou nous n’avons pas réussi à en charger des données. Vous pouvez éventuellement fouiller les - logs de SendInBlue - ou - de Mailjet. + logs de SendInBlue.

<% end %> diff --git a/config/env.example b/config/env.example index e58dbc372..fb73329e1 100644 --- a/config/env.example +++ b/config/env.example @@ -78,10 +78,6 @@ MATOMO_DOMAIN="*.www.demarches-simplifiees.fr" MATOMO_ID="" MATOMO_HOST="matomo.example.org" -# Default SMTP Provider: Mailjet -MAILJET_API_KEY="" -MAILJET_SECRET_KEY="" - # Alternate SMTP Provider: SendInBlue/DoList SENDINBLUE_CLIENT_KEY="" SENDINBLUE_SMTP_KEY="" diff --git a/config/environments/production.rb b/config/environments/production.rb index 5bc067cb7..64ed28732 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -113,8 +113,7 @@ Rails.application.configure do ActionMailer::Base.add_delivery_method :balancer, BalancerDeliveryMethod config.action_mailer.balancer_settings = { sendinblue: sendinblue_weigth, - dolist_api: dolist_api_weight, - mailjet: 100 - (sendinblue_weigth + dolist_api_weight) + dolist_api: dolist_api_weight } config.action_mailer.delivery_method = :balancer end diff --git a/config/initializers/mailjet.rb b/config/initializers/mailjet.rb deleted file mode 100644 index a8789815b..000000000 --- a/config/initializers/mailjet.rb +++ /dev/null @@ -1,9 +0,0 @@ -ActiveSupport.on_load(:action_mailer) do - require 'mailjet' - - Mailjet.configure do |config| - config.api_key = Rails.application.secrets.mailjet[:api_key] - config.secret_key = Rails.application.secrets.mailjet[:secret_key] - config.default_from = CONTACT_EMAIL - end -end diff --git a/config/secrets.yml b/config/secrets.yml index 866fa6159..f3c3e50b8 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -35,9 +35,6 @@ defaults: &defaults token_endpoint: <%= ENV['AGENT_CONNECT_BASE_URL'] %>/api/v2/token userinfo_endpoint: <%= ENV['AGENT_CONNECT_BASE_URL'] %>/api/v2/userinfo logout_endpoint: <%= ENV['AGENT_CONNECT_BASE_URL'] %>/api/v2/session/end - mailjet: - api_key: <%= ENV['MAILJET_API_KEY'] %> - secret_key: <%= ENV['MAILJET_SECRET_KEY'] %> dolist: username: <%= ENV['DOLIST_USERNAME'] %> password: <%= ENV['DOLIST_PASSWORD'] %>