Skip to content

Commit d043748

Browse files
authored
feat: reminder for teams with missing payment (#101)
1 parent 7189ca5 commit d043748

File tree

5 files changed

+263
-1
lines changed

5 files changed

+263
-1
lines changed

lib/ares/accounts.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,13 @@ defmodule Ares.Accounts do
456456
UserNotifier.deliver_team_reminder(attendee)
457457
end)
458458
end
459+
460+
def notify_team_with_no_payment do
461+
teams =
462+
Ares.Teams.list_teams_pending_payment()
463+
464+
Enum.each(teams, fn team ->
465+
UserNotifier.deliver_team_payment_reminder(team)
466+
end)
467+
end
459468
end

lib/ares/accounts/user_notifier.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule Ares.Accounts.UserNotifier do
66

77
alias Ares.Accounts.User
88
alias Ares.Mailer
9+
alias Ares.Teams.Team
910

1011
use Phoenix.Swoosh, view: AresWeb.EmailView
1112

@@ -89,4 +90,16 @@ defmodule Ares.Accounts.UserNotifier do
8990
{:error, reason} -> {:error, reason}
9091
end
9192
end
93+
94+
def deliver_team_payment_reminder(%Team{} = team) do
95+
email =
96+
base_html_email(team.leader.email, "Payment Reminder")
97+
|> assign(:user_name, team.leader.name)
98+
|> render_body("payment_reminder_email.html")
99+
100+
case Mailer.deliver(email) do
101+
{:ok, _metadata} -> {:ok, email}
102+
{:error, reason} -> {:error, reason}
103+
end
104+
end
92105
end

lib/ares/teams.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ defmodule Ares.Teams do
5858
|> Repo.all()
5959
end
6060

61+
def list_teams_pending_payment do
62+
Team
63+
|> where([t], t.payment_status in [:none, :started])
64+
|> preload(:leader)
65+
|> Repo.all()
66+
end
67+
6168
@doc """
6269
Returns the count of team members
6370
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html dir="ltr" lang="en">
3+
<head>
4+
<link
5+
rel="preload"
6+
as="image"
7+
href=<%= "#{@phx_host}/images/email/bugsbyte-logo.png" %>
8+
/>
9+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
10+
<meta name="x-apple-disable-message-reformatting" />
11+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
12+
<meta name="x-apple-disable-message-reformatting" />
13+
<!--$-->
14+
<style>
15+
u + .body .gmail-blend-screen { background:#000; mix-blend-mode:screen; }
16+
u + .body .gmail-blend-difference { background:#000; mix-blend-mode:difference; }
17+
</style>
18+
</head>
19+
<div
20+
style="display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0"
21+
>
22+
Payment required - Don&#x27;t lose your team&#x27;s spot!
23+
<div>
24+
 ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏
25+
</div>
26+
</div>
27+
<body
28+
style='background-color:#ffffff;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif'
29+
>
30+
<head></head>
31+
<table
32+
align="center"
33+
width="100%"
34+
border="0"
35+
cellpadding="0"
36+
cellspacing="0"
37+
role="presentation"
38+
style="max-width:37.5em;background-color:#ffffff;margin:0 auto;padding:0 0 48px"
39+
>
40+
<tbody>
41+
<tr style="width:100%">
42+
<td>
43+
<div
44+
style="padding-top:1.25rem;padding-bottom:1.25rem;background-color:#000000;background-image:linear-gradient(#000000, #000000)"
45+
>
46+
<div class="gmail-blend-difference">
47+
<div
48+
class="gmail-blend-screen"
49+
style="padding-left:2.5rem;padding-right:2.5rem"
50+
>
51+
<img
52+
alt="BugsByte Logo"
53+
src=<%= "#{@phx_host}/images/email/bugsbyte-logo.png" %>
54+
style="margin-left:auto;margin-right:auto;width:100%;display:block;outline:none;border:none;text-decoration:none;filter:invert(0%)"
55+
/>
56+
</div>
57+
</div>
58+
</div>
59+
<p
60+
style="font-size:1.25rem;line-height:1.75rem;font-weight:700;text-align:center;margin:16px 0"
61+
>
62+
O tempo está a esgotar-se,
63+
<%= @user_name %>!
64+
</p>
65+
<p
66+
style="font-size:16px;line-height:26px;margin:16px 0;padding:0 16px"
67+
>
68+
A tua equipa está inscrita, mas ainda falta algo crucial:
69+
<b>o pagamento</b>. Neste momento, a inscrição da tua equipa não
70+
está confirmada e, se não efetuares o pagamento em breve, a tua
71+
equipa vai perder o lugar na BugsByte.<!-- -->
72+
</p>
73+
<p
74+
style="font-size:16px;line-height:26px;margin:16px 0;padding:0 16px"
75+
>
76+
Queremos a tua equipa lá! Efetua o pagamento agora antes que seja
77+
tarde demais.
78+
</p>
79+
<table
80+
align="center"
81+
width="100%"
82+
border="0"
83+
cellpadding="0"
84+
cellspacing="0"
85+
role="presentation"
86+
style="margin-left:auto;margin-right:auto;text-align:center"
87+
>
88+
<tbody>
89+
<tr>
90+
<td>
91+
<a
92+
href=<%= "#{@phx_host}/app/payment" %>
93+
style="border-radius:9999px;font-weight:700;color:rgb(255,255,255);padding-left:1rem;padding-right:1rem;margin-top:1.5rem;margin-bottom:1.5rem;line-height:100%;text-decoration:none;display:inline-block;max-width:100%;mso-padding-alt:0px;background-color:#EB1A63;background-image:linear-gradient(#EB1A63, #EB1A63);font-size:16px;padding:12px 16px 12px 16px"
94+
target="_blank"
95+
><span
96+
><!--[if mso
97+
]><i
98+
style="mso-font-width:400%;mso-text-raise:18"
99+
hidden
100+
>&#8202;&#8202;</i
101+
><!
102+
[endif]--></span
103+
><span
104+
style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:9px"
105+
><div class="gmail-blend-difference">
106+
<div class="gmail-blend-screen">
107+
Efetuar pagamento
108+
</div>
109+
</div></span
110+
><span
111+
><!--[if mso
112+
]><i style="mso-font-width:400%" hidden
113+
>&#8202;&#8202;&#8203;</i
114+
><!
115+
[endif]--></span
116+
></a
117+
>
118+
</td>
119+
</tr>
120+
</tbody>
121+
</table>
122+
<p
123+
style="font-size:16px;line-height:26px;margin:16px 0;padding:0 16px"
124+
>
125+
Até breve,<br /><span style="color:rgb(100,116,139)"
126+
>Equipa da BugsByte</span
127+
>
128+
</p>
129+
<hr
130+
style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#cccccc;margin:20px 0"
131+
/>
132+
<p
133+
style="color:rgb(148,163,184);font-size:0.75rem;line-height:1rem;margin:16px 0"
134+
>
135+
Caso o botão acima não funcione, também podes clicar no seguinte link:<!-- -->
136+
<a
137+
href=<%= "#{@phx_host}/app/payment" %>
138+
style="color:rgb(51,65,85)"
139+
><%= "#{@phx_host}/app/payment" %></a
140+
>
141+
</p>
142+
<hr
143+
style="margin-top:16px;margin-bottom:16px;border-color:rgb(209,213,219);border-top-width:2px;width:100%;border:none;border-top:1px solid #eaeaea"
144+
/>
145+
<p
146+
style="font-size:1.25rem;line-height:1.75rem;font-weight:700;text-align:center;margin:16px 0"
147+
>
148+
Time is running out,
149+
<%= @user_name %>!
150+
</p>
151+
<p
152+
style="font-size:16px;line-height:26px;margin:16px 0;padding:0 16px"
153+
>
154+
Your team is registered, but there&#x27;s one crucial thing
155+
missing: <b>payment</b>. Right now, your team&#x27;s registration
156+
isn&#x27;t confirmed, and if you don&#x27;t complete the payment
157+
soon, your team will lose its spot at BugsByte.<!-- -->
158+
</p>
159+
<p
160+
style="font-size:16px;line-height:26px;margin:16px 0;padding:0 16px"
161+
>
162+
We want your team there! Complete the payment now before it&#x27;s
163+
too late.
164+
</p>
165+
<table
166+
align="center"
167+
width="100%"
168+
border="0"
169+
cellpadding="0"
170+
cellspacing="0"
171+
role="presentation"
172+
style="margin-left:auto;margin-right:auto;text-align:center"
173+
>
174+
<tbody>
175+
<tr>
176+
<td>
177+
<a
178+
href="PLACEHOLDER_PAYMENT_LINK"
179+
style="border-radius:9999px;font-weight:700;color:rgb(255,255,255);padding-left:1rem;padding-right:1rem;margin-top:1.5rem;margin-bottom:1.5rem;line-height:100%;text-decoration:none;display:inline-block;max-width:100%;mso-padding-alt:0px;background-color:#EB1A63;background-image:linear-gradient(#EB1A63, #EB1A63);font-size:16px;padding:12px 16px 12px 16px"
180+
target="_blank"
181+
><span
182+
><!--[if mso
183+
]><i
184+
style="mso-font-width:400%;mso-text-raise:18"
185+
hidden
186+
>&#8202;&#8202;</i
187+
><!
188+
[endif]--></span
189+
><span
190+
style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:9px"
191+
><div class="gmail-blend-difference">
192+
<div class="gmail-blend-screen">Complete payment</div>
193+
</div></span
194+
><span
195+
><!--[if mso
196+
]><i style="mso-font-width:400%" hidden
197+
>&#8202;&#8202;&#8203;</i
198+
><!
199+
[endif]--></span
200+
></a
201+
>
202+
</td>
203+
</tr>
204+
</tbody>
205+
</table>
206+
<p
207+
style="font-size:16px;line-height:26px;margin:16px 0;padding:0 16px"
208+
>
209+
See you soon,<br /><span style="color:rgb(100,116,139)"
210+
>BugsByte Team</span
211+
>
212+
</p>
213+
<hr
214+
style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#cccccc;margin:20px 0"
215+
/>
216+
<p
217+
style="color:rgb(148,163,184);font-size:0.75rem;line-height:1rem;margin:16px 0"
218+
>
219+
If the button above doesn&#x27;t work, you can also click on the
220+
following link:<!-- -->
221+
<a
222+
href=<%= "#{@phx_host}/app/payment" %>
223+
style="color:rgb(51,65,85)"
224+
><%= "#{@phx_host}/app/payment" %></a
225+
>
226+
</p>
227+
</td>
228+
</tr>
229+
</tbody>
230+
</table>
231+
<!--/$-->
232+
</body>
233+
</html>

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"gen_smtp": {:hex, :gen_smtp, "1.3.0", "62c3d91f0dcf6ce9db71bcb6881d7ad0d1d834c7f38c13fa8e952f4104a8442e", [:rebar3], [{:ranch, ">= 1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "0b73fbf069864ecbce02fe653b16d3f35fd889d0fdd4e14527675565c39d84e6"},
2424
"gettext": {:hex, :gettext, "0.26.2", "5978aa7b21fada6deabf1f6341ddba50bc69c999e812211903b169799208f2a8", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "aa978504bcf76511efdc22d580ba08e2279caab1066b76bb9aa81c4a1e0a32a5"},
2525
"hackney": {:hex, :hackney, "1.25.0", "390e9b83f31e5b325b9f43b76e1a785cbdb69b5b6cd4e079aa67835ded046867", [:rebar3], [{:certifi, "~> 2.15.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.4", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "7209bfd75fd1f42467211ff8f59ea74d6f2a9e81cbcee95a56711ee79fd6b1d4"},
26-
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "0435d4ca364a608cc75e2f8683d374e55abbae26", [tag: "v2.2.0", sparse: "optimized", depth: 1]},
26+
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "0435d4ca364a608cc75e2f8683d374e55abbae26", [tag: "v2.2.0", sparse: "optimized"]},
2727
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
2828
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
2929
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},

0 commit comments

Comments
 (0)