Skip to content

Commit

Permalink
refactor: use a different Base64 encoder before sending mail via SES (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen authored Dec 5, 2024
1 parent 2b00d12 commit 040b0bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/feedback/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Feedback.Mailer do
require Logger

alias Feedback.Message
alias Mail.Renderers.RFC2822
alias Mail.{Encoders.Base64, Renderers.RFC2822}

@aws_client Application.compile_env(:dotcom, :aws_client)

Expand Down Expand Up @@ -77,7 +77,7 @@ defmodule Feedback.Mailer do

message
|> RFC2822.render()
|> Base.encode64()
|> Base64.encode()
|> then(&%{"RawMessage" => %{"Data" => &1}})
|> send_email_fn.()
end
Expand Down
2 changes: 1 addition & 1 deletion lib/feedback/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Feedback.Test do
end

def send_email(%{"RawMessage" => %{"Data" => raw_message}}) do
parsed_message = raw_message |> Base.decode64!() |> RFC2822.parse()
parsed_message = raw_message |> Mail.Encoders.Base64.decode() |> RFC2822.parse()

attachments =
if parsed_message.multipart do
Expand Down
4 changes: 3 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ defmodule DotCom.Mixfile do
{:inflex, "2.1.0"},
{:jason, "1.4.4", override: true},
{:logster, "1.1.1"},
{:mail, "0.4.1"},
# Mail kept at 0.3.1 as we experienced inconsistent photo attachment and
# email encoding success with later version
{:mail, "0.3.1"},
{:mbta_metro, "0.0.58"},
{:mock, "0.3.8", [only: :test]},
{:mox, "1.2.0", [only: :test]},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"jsx": {:hex, :jsx, "3.1.0", "d12516baa0bb23a59bb35dccaf02a1bd08243fcbb9efe24f2d9d056ccff71268", [:rebar3], [], "hexpm", "0c5cc8fdc11b53cc25cf65ac6705ad39e54ecc56d1c22e4adb8f5a53fb9427f3"},
"logster": {:hex, :logster, "1.1.1", "d6fddac540dd46adde0c894024500867fe63b0043713f842c62da5815e21db10", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "d18e852c430812ad1c9756998ebe46ec814c724e6eb551a512d7e3f8dee24cef"},
"mail": {:hex, :mail, "0.4.1", "f3928edeeafbc833319879811fc9337c453acb039f68119cc6732775aa0dea04", [:mix], [], "hexpm", "d9e69b60431084b8c88603f0d899736b46356a6ca12397b63034133d9382b92d"},
"mail": {:hex, :mail, "0.3.1", "cb0a14e4ed8904e4e5a08214e686ccf6f9099346885db17d8c309381f865cc5c", [:mix], [], "hexpm", "1db701e89865c1d5fa296b2b57b1cd587587cca8d8a1a22892b35ef5a8e352a6"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_eex": {:hex, :makeup_eex, "0.1.2", "93a5ef3d28ed753215dba2d59cb40408b37cccb4a8205e53ef9b5319a992b700", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.16 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_html, "~> 0.1.0 or ~> 1.0", [hex: :makeup_html, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "6140eafb28215ad7182282fd21d9aa6dcffbfbe0eb876283bc6b768a6c57b0c3"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.0", "74bb8348c9b3a51d5c589bf5aebb0466a84b33274150e3b6ece1da45584afc82", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49159b7d7d999e836bedaf09dcf35ca18b312230cf901b725a64f3f42e407983"},
Expand Down

0 comments on commit 040b0bb

Please sign in to comment.