Send acceptance email only to applicants

This commit is contained in:
Saku Laesvuori 2023-09-28 15:48:05 +03:00
parent 72b3e25913
commit 47c6ebf9a1
Signed by: slaesvuo
GPG Key ID: 257D284A2A1D3A32
2 changed files with 5 additions and 4 deletions

View File

@ -198,8 +198,9 @@ acceptApplication user = void $ do
Nothing -> throwError $ "No valid application for " <> show user <> "!"
Just email -> do
time <- currentTime
markAsAccepted user time
void $ sendApplicationAcceptedEmail $ dBEmailEmail $ entityVal email
applicationAccepted <- markAsAccepted user time
when applicationAccepted $
sendApplicationAcceptedEmail $ dBEmailEmail $ entityVal email
rejectApplication :: (MonadDB m, MonadTime m, MonadError GQLError m, MonadEmail m) => UserID -> m Unit
rejectApplication user = void $ do

View File

@ -160,8 +160,8 @@ updateEmail user email secret = getExpireTime >>= \expires -> runQuery $ do
, dBEmailVid = Just verificationId
}
markAsAccepted :: MonadDB m => UserID -> Time -> m ()
markAsAccepted userID time = runQuery $ update $ \user -> do
markAsAccepted :: MonadDB m => UserID -> Time -> m Bool
markAsAccepted userID time = fmap (> 0) $ runQuery $ updateCount $ \user -> do
set user [DBUserAccepted =. just (val time)]
where_ $ user ^. DBUserId ==. val (toDBKey userID) &&. isApplicant user