diff options
Diffstat (limited to 'identity/version.go')
-rw-r--r-- | identity/version.go | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/identity/version.go b/identity/version.go index b5b8dae3..85195049 100644 --- a/identity/version.go +++ b/identity/version.go @@ -24,8 +24,7 @@ type Version struct { unixTime int64 name string - email string // TODO: remove ? keep and use metadata for bridges ? - login string // TODO: remove + email string // as defined in git, not for bridges avatarURL string // The set of keys valid at that time, from this version onward, until they get removed @@ -53,19 +52,28 @@ type VersionJSON struct { UnixTime int64 `json:"unix_time"` Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` - Login string `json:"login,omitempty"` AvatarUrl string `json:"avatar_url,omitempty"` Keys []Key `json:"pub_keys,omitempty"` Nonce []byte `json:"nonce,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` } -type VersionMutator struct { - Name string - Email string - Login string - AvatarUrl string - Keys []Key +// Make a deep copy +func (v *Version) Clone() *Version { + + clone := &Version{ + name: v.name, + email: v.email, + avatarURL: v.avatarURL, + keys: make([]Key, len(v.keys)), + metadata: make(map[string]string), + } + + for i, op := range opp.Operations { + clone.Operations[i] = op + } + + return clone } func (v *Version) MarshalJSON() ([]byte, error) { @@ -75,7 +83,6 @@ func (v *Version) MarshalJSON() ([]byte, error) { UnixTime: v.unixTime, Name: v.name, Email: v.email, - Login: v.login, AvatarUrl: v.avatarURL, Keys: v.keys, Nonce: v.nonce, @@ -98,7 +105,6 @@ func (v *Version) UnmarshalJSON(data []byte) error { v.unixTime = aux.UnixTime v.name = aux.Name v.email = aux.Email - v.login = aux.Login v.avatarURL = aux.AvatarUrl v.keys = aux.Keys v.nonce = aux.Nonce @@ -116,8 +122,8 @@ func (v *Version) Validate() error { return fmt.Errorf("lamport time not set") } - if text.Empty(v.name) && text.Empty(v.login) { - return fmt.Errorf("either name or login should be set") + if text.Empty(v.name) { + return fmt.Errorf("name not set") } if strings.Contains(v.name, "\n") { @@ -128,14 +134,6 @@ func (v *Version) Validate() error { return fmt.Errorf("name is not fully printable") } - if strings.Contains(v.login, "\n") { - return fmt.Errorf("login should be a single line") - } - - if !text.Safe(v.login) { - return fmt.Errorf("login is not fully printable") - } - if strings.Contains(v.email, "\n") { return fmt.Errorf("email should be a single line") } @@ -210,7 +208,7 @@ func (v *Version) GetMetadata(key string) (string, bool) { return val, ok } -// AllMetadata return all metadata for this Identity +// AllMetadata return all metadata for this Version func (v *Version) AllMetadata() map[string]string { return v.metadata } |