Skip to content

Commit 9420f66

Browse files
committed
add link to img
1 parent 335dcdf commit 9420f66

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

lib/algora/mailer.ex

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,26 @@ defmodule Algora.Mailer do
5555

5656
def text_template(template_params) do
5757
"""
58-
5958
==============================
6059
6160
#{text_sections(template_params)}
6261
63-
Algora - https://algora.io/
64-
6562
==============================
6663
"""
6764
end
6865

6966
defp text_sections(template_params) do
7067
template_params
71-
|> Keyword.values()
72-
|> Enum.join("\n\n")
68+
|> Enum.map(fn {type, value} -> text_section(type, value) end)
69+
|> Enum.intersperse("\n\n")
70+
end
71+
72+
defp text_section(:cta, %{href: href}) do
73+
~s|#{href}|
74+
end
75+
76+
defp text_section(_, value) do
77+
value
7378
end
7479

7580
defp html_sections(template_params) do
@@ -96,13 +101,19 @@ defmodule Algora.Mailer do
96101
html_section_by_type(type, value) <> ~s|</p>|
97102
end
98103

104+
defp html_section_by_type(:cta, %{href: href, src: src}) do
105+
~s|<a href="#{href}" style="word-break: break-all; word-wrap: break-word;">| <>
106+
~s|<img src="#{src}" style="width: 100%; height: auto;">| <>
107+
~s|</a>|
108+
end
109+
99110
defp html_section_by_type(:url, value) do
100-
~s|<a href="#{value}" style="word-break: break-all; word-wrap: break-word; color: #727cf5;">| <>
111+
~s|<a href="#{value}" style="word-break: break-all; word-wrap: break-word;">| <>
101112
value <> ~s|</a>|
102113
end
103114

104115
defp html_section_by_type(:img, value) do
105-
~s|<img src="cid:#{value}" style="width: 100%; height: auto;">|
116+
~s|<img src="#{value}" style="width: 100%; height: auto;">|
106117
end
107118

108119
defp html_section_by_type(_, text) do

lib/algora_web/live/admin/campaign_live.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,13 @@ defmodule AlgoraWeb.Admin.CampaignLive do
218218
Repo.transact(fn _ ->
219219
recipients
220220
|> Enum.map(fn recipient ->
221-
template_params = [markdown: render_preview(template, recipient), img: "#{recipient["repo_owner"]}.png"]
221+
template_params = [
222+
markdown: render_preview(template, recipient),
223+
cta: %{
224+
href: "#{AlgoraWeb.Endpoint.url()}/go/#{recipient["repo_owner"]}/#{recipient["repo_name"]}",
225+
src: "cid:#{recipient["repo_owner"]}.png"
226+
}
227+
]
222228

223229
%{
224230
id: "2025-04-oss",

0 commit comments

Comments
 (0)