@@ -25,6 +25,8 @@ import Mjml as Mjml
25
25
import MjmlHalogenElements as MjmlHalogenElements
26
26
import NodeMailer as NodeMailer
27
27
import PostgreSQLExtra as PostgreSQLExtra
28
+ import Data.Codec.Argonaut as CA
29
+ import Data.Codec.Argonaut.Record as CAR
28
30
29
31
html
30
32
:: forall w i
@@ -69,6 +71,13 @@ newtype Input = Input
69
71
derive instance newtypeInput :: Newtype Input _
70
72
derive instance genericInput :: Generic Input _
71
73
74
+ inputCodec ∷ CA.JsonCodec { id :: String }
75
+ inputCodec =
76
+ CA .object " Input" $
77
+ CAR .record
78
+ { id: CA .string
79
+ }
80
+
72
81
newtype UserDataFromDb
73
82
= UserDataFromDb
74
83
{ name :: Maybe String
@@ -109,24 +118,24 @@ job
109
118
, connection
110
119
, transporter
111
120
} = do
112
- ( input :: Input ) <- genericDecodeJson json
113
- # either (throwError <<< error <<< Argonaut .printJsonDecodeError) pure
121
+ input <- CA .decode inputCodec json
122
+ # either (throwError <<< error <<< CA .printJsonDecodeError) pure
114
123
115
124
(userData :: UserDataFromDb ) <-
116
125
PostgreSQLExtra .queryHeadOrThrow connection
117
126
( Query """
118
127
SELECT
119
- t_user_email .name AS name,
128
+ t_user .name AS name,
120
129
t_user_email.email AS email,
121
130
t_user_email.is_verified AS is_verified,
122
- t_user_email_secret .verification_token AS verification_token
123
- FROM app_public .user_emails AS t_user_email
124
- JOIN app_private.user_email_secrets AS t_user_email_secret
125
- ON t_user_email .id = t_user_email_secret.user_email_id
131
+ t_user_email .verification_token AS verification_token
132
+ FROM app_hidden .user_emails AS t_user_email
133
+ JOIN app_public.users AS t_user
134
+ ON t_user .id = t_user_email.user_id
126
135
WHERE t_user_email.id = $1
127
136
"""
128
137
)
129
- (Row1 (unwrap input) .id)
138
+ (Row1 input.id)
130
139
131
140
emailBody <- liftEffect $
132
141
Mjml .mjml2html
155
164
WHERE t_user_email_secret.user_email_id = $1
156
165
"""
157
166
)
158
- (Row1 (unwrap input) .id)
167
+ (Row1 input.id)
0 commit comments