"strings"
"time"
- "github.com/jloup/utils"
"git.immae.eu/Cryptoportfolio/Front.git/db"
"git.immae.eu/Cryptoportfolio/Front.git/markets"
+ "github.com/jloup/utils"
)
type MarketConfigQuery struct {
return nil
})
- if resultErr != nil {
+ var newStatus db.MarketConfigStatus = config.Status
+
+ if ErrorIs(resultErr, InvalidMarketCredentials) || ErrorIs(resultErr, IPRestrictedApiKey) || ErrorIs(resultErr, MarketCredentialsNotConfigured) {
+ newStatus = db.MarketConfigInvalidCredentials
+ } else if resultErr != nil {
+ return nil, NewInternalError(resultErr)
+ } else if resultErr != nil {
return nil, NewInternalError(resultErr)
}
+ if newStatus != config.Status {
+ config, err = db.SetMarketConfigStatus(*config, newStatus)
+ if err != nil {
+ return nil, NewInternalError(err)
+ }
+ }
+
return nil, nil
}
var newStatus db.MarketConfigStatus = db.MarketConfigEnabled
- if ErrorIs(resultErr, InvalidMarketCredentials) || ErrorIs(resultErr, IPRestrictedApiKey) {
+ if ErrorIs(resultErr, InvalidMarketCredentials) || ErrorIs(resultErr, IPRestrictedApiKey) || ErrorIs(resultErr, MarketCredentialsNotConfigured) {
newStatus = db.MarketConfigInvalidCredentials
} else if resultErr != nil {
return nil, NewInternalError(resultErr)