Make GC emails also delete orphaned verifications
This commit is contained in:
parent
04d0efb545
commit
3666f29756
|
@ -137,6 +137,13 @@ deleteExpiredEmails time = runQuery $ delete $ do
|
|||
verification <- from $ table @DBEmailVerification
|
||||
where_ $ verification ^. DBEmailVerificationExpires <=. val time
|
||||
|
||||
deleteOrphanedVerifications :: MonadDB m => m ()
|
||||
deleteOrphanedVerifications = runQuery $ delete $ do
|
||||
verification <- from $ table @DBEmailVerification
|
||||
where_ $ (==. val (0 :: Int)) $ subSelectCount $ do
|
||||
email <- from $ table @DBEmail
|
||||
where_ $ email ^. DBEmailVid ==. just (verification ^. DBEmailVerificationId)
|
||||
|
||||
deleteUsersWithoutEmail :: MonadDB m => m ()
|
||||
deleteUsersWithoutEmail = runQuery $ delete $ do
|
||||
user <- from $ table @DBUser
|
||||
|
|
|
@ -58,6 +58,7 @@ gcEmailsMain :: CLIM ()
|
|||
gcEmailsMain = do
|
||||
time <- currentTime
|
||||
deleteExpiredEmails time
|
||||
deleteOrphanedVerifications
|
||||
|
||||
gcApplicationsMain :: CLIM ()
|
||||
gcApplicationsMain = do
|
||||
|
|
Loading…
Reference in New Issue