Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0180887

Browse files
committedNov 24, 2024·
Add Mailings.sender_from_line/1
1 parent d909a88 commit 0180887

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed
 

‎lib/keila/mailings/mailings.ex

+22
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ defmodule Keila.Mailings do
6464
end)
6565
end
6666

67+
@doc """
68+
Returns the Sender from line in the form of `"Name <test@example.com>"`
69+
If the Sender uses a Send with Keila proxy address, the Reply-to email is printed instead.
70+
"""
71+
@spec sender_from_line(Sender.t()) :: String.t()
72+
def sender_from_line(sender) do
73+
email =
74+
if String.ends_with?(sender.from_email, "@mailings.keilausercontent.com") do
75+
sender.reply_to_email
76+
else
77+
sender.from_email
78+
end
79+
80+
name = sender.from_name || sender.reply_to_name
81+
82+
if name do
83+
"name <#{email}>"
84+
else
85+
email
86+
end
87+
end
88+
6789
@doc """
6890
Updates an existing Sender with given params.
6991
"""

‎lib/keila_web/templates/campaign/_settings_dialog.html.heex

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
do: [{gettext("Please select a sender"), nil}],
5050
else: []
5151
) ++
52-
Enum.map(@senders, &{"#{&1.name} (#{&1.from_name} <#{&1.from_email}>)", &1.id}),
52+
Enum.map(
53+
@senders,
54+
&{"#{&1.name} (#{Keila.Mailings.sender_from_line(&1)})", &1.id}
55+
),
5356
class: "text-black w-full"
5457
) %>
5558
<% end %>

‎lib/keila_web/templates/sender/index.html.heex

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<%= sender.name %>
2424
</h2>
2525
<p>
26-
<%= sender.from_name %> &lt;<%= sender.from_email %>&gt;
26+
<%= Keila.Mailings.sender_from_line(sender) %>
2727
</p>
2828
<br />
2929
<a

0 commit comments

Comments
 (0)
Please sign in to comment.