diff options
author | Corey Hulen <corey@hulen.com> | 2016-02-04 13:01:14 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-02-04 13:01:14 -0800 |
commit | af6ade338002a215ff7c7771f7fe6bbbb06f0cd7 (patch) | |
tree | a8e696aaaf8fd4e483d52f356e848aafcf2a6c25 /model/license.go | |
parent | ec51c31c325b3dc648a261f0e8634b6d70d7ba73 (diff) | |
parent | e45282deaa1d78d7ff3a125e9fd11e3fdc120b07 (diff) | |
download | chat-af6ade338002a215ff7c7771f7fe6bbbb06f0cd7.tar.gz chat-af6ade338002a215ff7c7771f7fe6bbbb06f0cd7.tar.bz2 chat-af6ade338002a215ff7c7771f7fe6bbbb06f0cd7.zip |
Merge pull request #2073 from mattermost/ee-updates
Some general updates to EE
Diffstat (limited to 'model/license.go')
-rw-r--r-- | model/license.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/model/license.go b/model/license.go index a271b46b7..ea66fef0d 100644 --- a/model/license.go +++ b/model/license.go @@ -8,6 +8,12 @@ import ( "io" ) +type LicenseRecord struct { + Id string `json:"id"` + CreateAt int64 `json:"create_at"` + Bytes string `json:"-"` +} + type License struct { Id string `json:"id"` IssuedAt int64 `json:"issued_at"` @@ -83,3 +89,23 @@ func LicenseFromJson(data io.Reader) *License { return nil } } + +func (lr *LicenseRecord) IsValid() *AppError { + if len(lr.Id) != 26 { + return NewLocAppError("LicenseRecord.IsValid", "model.license_record.is_valid.id.app_error", nil, "") + } + + if lr.CreateAt == 0 { + return NewLocAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "") + } + + if len(lr.Bytes) == 0 || len(lr.Bytes) > 10000 { + return NewLocAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "") + } + + return nil +} + +func (lr *LicenseRecord) PreSave() { + lr.CreateAt = GetMillis() +} |