~afontaine/home

c559bfe2596ee24d53d3406b540efd27f155a89a — Andrew Fontaine 7 months ago d8b7601
Fix some formatting of the parsing of the message

The author is returned in the form of `{name, address}`, so let's
explicity turn that into `"<name address>"`.

Also tags should _always_ be a list.
1 files changed, 5 insertions(+), 4 deletions(-)

M apps/blog/lib/blog/mail/post.ex
M apps/blog/lib/blog/mail/post.ex => apps/blog/lib/blog/mail/post.ex +5 -4
@@ 41,9 41,10 @@ defmodule Blog.Mail.Post do
  defp put_body(changeset), do: changeset

  defp put_author(%Ecto.Changeset{valid?: true, changes: %{envelope: envelope}} = changeset) do
    author = Mail.get_from(envelope)

    put_change(changeset, :author, author)
    case Mail.get_from(envelope) do
      {name, addr} -> put_change(changeset, :author, "<#{name} #{addr}>")
      author -> put_change(changeset, :author, author)
    end
  end

  defp put_author(changeset), do: changeset


@@ 57,7 58,7 @@ defmodule Blog.Mail.Post do
          [head, parse_tags(tags)]

        _ ->
          ["", ""]
          ["", []]
      end

    changeset