summaryrefslogtreecommitdiffstats
path: root/models/ssh_key.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r--models/ssh_key.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 9365fab1ab..ea313f147a 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -25,6 +25,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/util"
)
const (
@@ -54,20 +55,16 @@ type PublicKey struct {
Mode AccessMode `xorm:"NOT NULL DEFAULT 2"`
Type KeyType `xorm:"NOT NULL DEFAULT 1"`
- Created time.Time `xorm:"-"`
- CreatedUnix int64 `xorm:"created"`
- Updated time.Time `xorm:"-"`
- UpdatedUnix int64 `xorm:"updated"`
- HasRecentActivity bool `xorm:"-"`
- HasUsed bool `xorm:"-"`
+ CreatedUnix util.TimeStamp `xorm:"created"`
+ UpdatedUnix util.TimeStamp `xorm:"updated"`
+ HasRecentActivity bool `xorm:"-"`
+ HasUsed bool `xorm:"-"`
}
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
func (key *PublicKey) AfterLoad() {
- key.Created = time.Unix(key.CreatedUnix, 0).Local()
- key.Updated = time.Unix(key.UpdatedUnix, 0).Local()
- key.HasUsed = key.Updated.After(key.Created)
- key.HasRecentActivity = key.Updated.Add(7 * 24 * time.Hour).After(time.Now())
+ key.HasUsed = key.UpdatedUnix > key.CreatedUnix
+ key.HasRecentActivity = key.UpdatedUnix.AddDuration(7*24*time.Hour) > util.TimeStampNow()
}
// OmitEmail returns content of public key without email address.
@@ -484,7 +481,7 @@ func UpdatePublicKeyUpdated(id int64) error {
}
_, err := x.ID(id).Cols("updated_unix").Update(&PublicKey{
- UpdatedUnix: time.Now().Unix(),
+ UpdatedUnix: util.TimeStampNow(),
})
if err != nil {
return err