feat(invitations): save expiresAt to DB
This commit is contained in:
parent
0044cea857
commit
1c2f2b7221
@ -2,4 +2,5 @@ Invitation
|
||||
email UserEmail
|
||||
for Value
|
||||
data Value
|
||||
expiresAt UTCTime Maybe
|
||||
UniqueInvitation email for
|
||||
@ -220,7 +220,12 @@ sinkInvitations InvitationConfig{..} = determineExists .| sinkInvitations'
|
||||
jInvitationSubject <- fmap mr . mapReaderT liftHandlerT $ invitationSubject fEnt dat
|
||||
let jInvitationExplanation = invitationExplanation fEnt dat (toHtml . mr) ur
|
||||
|
||||
when (is _Nothing (ephemeralInvitation @junction)) $ insert_ $ Invitation jInvitee (invRef @junction fid) (toJSON $ dat ^. _invitationDBData)
|
||||
when (is _Nothing (ephemeralInvitation @junction)) $ insert_ $ Invitation
|
||||
{ invitationEmail = jInvitee
|
||||
, invitationFor = invRef @junction fid
|
||||
, invitationData = toJSON $ dat ^. _invitationDBData
|
||||
, invitationExpiresAt = tokenExpiresAt token
|
||||
}
|
||||
|
||||
queueDBJob JobInvitation{..}
|
||||
|
||||
@ -243,9 +248,9 @@ sourceInvitations :: forall junction.
|
||||
-> Source (YesodDB UniWorX) (UserEmail, InvitationDBData junction)
|
||||
sourceInvitations forKey = selectSource [InvitationFor ==. invRef @junction forKey] [] .| C.mapM decode
|
||||
where
|
||||
decode (Entity _ (Invitation email _ invitationData))
|
||||
decode (Entity _ (Invitation{invitationEmail, invitationData}))
|
||||
= case fromJSON invitationData of
|
||||
JSON.Success dbData -> return (email, dbData)
|
||||
JSON.Success dbData -> return (invitationEmail, dbData)
|
||||
JSON.Error str -> fail $ "Could not decode invitationData: " <> str
|
||||
|
||||
sourceInvitationsList :: forall junction.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user