add at
to time attributes in dbAccount
This commit is contained in:
parent
f72b2ff2c2
commit
ce13d09dcb
2 changed files with 13 additions and 15 deletions
|
@ -13,12 +13,12 @@ import (
|
||||||
|
|
||||||
// dbAccount represents an ACME account.
|
// dbAccount represents an ACME account.
|
||||||
type dbAccount struct {
|
type dbAccount struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Created time.Time `json:"created"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
Deactivated time.Time `json:"deactivated"`
|
DeactivatedAt time.Time `json:"deactivatedAt"`
|
||||||
Key *jose.JSONWebKey `json:"key"`
|
Key *jose.JSONWebKey `json:"key"`
|
||||||
Contact []string `json:"contact,omitempty"`
|
Contact []string `json:"contact,omitempty"`
|
||||||
Status acme.Status `json:"status"`
|
Status acme.Status `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dba *dbAccount) clone() *dbAccount {
|
func (dba *dbAccount) clone() *dbAccount {
|
||||||
|
@ -35,11 +35,11 @@ func (db *DB) CreateAccount(ctx context.Context, acc *acme.Account) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
dba := &dbAccount{
|
dba := &dbAccount{
|
||||||
ID: acc.ID,
|
ID: acc.ID,
|
||||||
Key: acc.Key,
|
Key: acc.Key,
|
||||||
Contact: acc.Contact,
|
Contact: acc.Contact,
|
||||||
Status: acc.Status,
|
Status: acc.Status,
|
||||||
Created: clock.Now(),
|
CreatedAt: clock.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
kid, err := acme.KeyToID(dba.Key)
|
kid, err := acme.KeyToID(dba.Key)
|
||||||
|
@ -105,7 +105,7 @@ func (db *DB) UpdateAccount(ctx context.Context, acc *acme.Account) error {
|
||||||
|
|
||||||
// If the status has changed to 'deactivated', then set deactivatedAt timestamp.
|
// If the status has changed to 'deactivated', then set deactivatedAt timestamp.
|
||||||
if acc.Status == acme.StatusDeactivated && old.Status != acme.StatusDeactivated {
|
if acc.Status == acme.StatusDeactivated && old.Status != acme.StatusDeactivated {
|
||||||
nu.Deactivated = clock.Now()
|
nu.DeactivatedAt = clock.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.save(ctx, old.ID, nu, old, "account", accountTable)
|
return db.save(ctx, old.ID, nu, old, "account", accountTable)
|
||||||
|
|
|
@ -105,9 +105,6 @@ func (db *DB) CreateOrder(ctx context.Context, o *acme.Order) error {
|
||||||
|
|
||||||
type orderIDsByAccount struct{}
|
type orderIDsByAccount struct{}
|
||||||
|
|
||||||
// addOrderID adds an order ID to a users index of in progress order IDs.
|
|
||||||
// This method will also cull any orders that are no longer in the `pending`
|
|
||||||
// state from the index before returning it.
|
|
||||||
func (db *DB) updateAddOrderIDs(ctx context.Context, accID string, addOids ...string) ([]string, error) {
|
func (db *DB) updateAddOrderIDs(ctx context.Context, accID string, addOids ...string) ([]string, error) {
|
||||||
ordersByAccountMux.Lock()
|
ordersByAccountMux.Lock()
|
||||||
defer ordersByAccountMux.Unlock()
|
defer ordersByAccountMux.Unlock()
|
||||||
|
@ -157,6 +154,7 @@ func (db *DB) updateAddOrderIDs(ctx context.Context, accID string, addOids ...st
|
||||||
return pendOids, nil
|
return pendOids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetOrdersByAccountID returns a list of order IDs owned by the account.
|
||||||
func (db *DB) GetOrdersByAccountID(ctx context.Context, accID string) ([]string, error) {
|
func (db *DB) GetOrdersByAccountID(ctx context.Context, accID string) ([]string, error) {
|
||||||
return db.updateAddOrderIDs(ctx, accID)
|
return db.updateAddOrderIDs(ctx, accID)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue