|
|
@ -600,20 +600,16 @@ type DeployKey struct { |
|
|
|
Fingerprint string |
|
|
|
Fingerprint string |
|
|
|
Content string `xorm:"-"` |
|
|
|
Content string `xorm:"-"` |
|
|
|
|
|
|
|
|
|
|
|
Created time.Time `xorm:"-"` |
|
|
|
CreatedUnix util.TimeStamp `xorm:"created"` |
|
|
|
CreatedUnix int64 `xorm:"created"` |
|
|
|
UpdatedUnix util.TimeStamp `xorm:"updated"` |
|
|
|
Updated time.Time `xorm:"-"` |
|
|
|
|
|
|
|
UpdatedUnix int64 `xorm:"updated"` |
|
|
|
|
|
|
|
HasRecentActivity bool `xorm:"-"` |
|
|
|
HasRecentActivity bool `xorm:"-"` |
|
|
|
HasUsed bool `xorm:"-"` |
|
|
|
HasUsed bool `xorm:"-"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
|
|
|
|
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
|
|
|
|
func (key *DeployKey) AfterLoad() { |
|
|
|
func (key *DeployKey) AfterLoad() { |
|
|
|
key.Created = time.Unix(key.CreatedUnix, 0).Local() |
|
|
|
key.HasUsed = key.UpdatedUnix > key.CreatedUnix |
|
|
|
key.Updated = time.Unix(key.UpdatedUnix, 0).Local() |
|
|
|
key.HasRecentActivity = key.UpdatedUnix.AddDuration(7*24*time.Hour) > util.TimeStampNow() |
|
|
|
key.HasUsed = key.Updated.After(key.Created) |
|
|
|
|
|
|
|
key.HasRecentActivity = key.Updated.Add(7 * 24 * time.Hour).After(time.Now()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetContent gets associated public key content.
|
|
|
|
// GetContent gets associated public key content.
|
|
|
@ -740,6 +736,12 @@ func GetDeployKeyByRepo(keyID, repoID int64) (*DeployKey, error) { |
|
|
|
return key, nil |
|
|
|
return key, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// UpdateDeployKeyCols updates deploy key information in the specified columns.
|
|
|
|
|
|
|
|
func UpdateDeployKeyCols(key *DeployKey, cols ...string) error { |
|
|
|
|
|
|
|
_, err := x.ID(key.ID).Cols(cols...).Update(key) |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// UpdateDeployKey updates deploy key information.
|
|
|
|
// UpdateDeployKey updates deploy key information.
|
|
|
|
func UpdateDeployKey(key *DeployKey) error { |
|
|
|
func UpdateDeployKey(key *DeployKey) error { |
|
|
|
_, err := x.ID(key.ID).AllCols().Update(key) |
|
|
|
_, err := x.ID(key.ID).AllCols().Update(key) |
|
|
|