infrastructure for detecting limited accounts (#320)

This commit is contained in:
Michael Quigley
2023-05-16 12:05:30 -04:00
parent 9591f5150e
commit d0cedaf6e5
3 changed files with 18 additions and 5 deletions

View File

@ -84,8 +84,20 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
}
envShrsList = append(envShrsList, envShrs)
}
var alj *store.AccountLimitJournal
aljEmpty, err := str.IsAccountLimitJournalEmpty(int(principal.ID), tx)
if err != nil {
logrus.Errorf("error checking account limit journal for '%v': %v", principal.Email, err)
}
if !aljEmpty {
alj, err = str.FindLatestAccountLimitJournal(int(principal.ID), tx)
if err != nil {
logrus.Errorf("error getting latest account limit journal entry for '%v': %v", principal.Email, err)
return metadata.NewOverviewInternalServerError()
}
}
return metadata.NewOverviewOK().WithPayload(&rest_model_zrok.Overview{
AccountLimited: false,
AccountLimited: alj != nil && alj.Action == store.LimitAction,
Environments: envShrsList,
})
}