Skip to content

Commit

Permalink
Allow empty owner info
Browse files Browse the repository at this point in the history
  • Loading branch information
benpate committed Mar 26, 2024
1 parent 6c83274 commit 1849526
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config/owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ type Owner struct {
func NewOwner() Owner {
return Owner{}
}

func (owner Owner) IsEmpty() bool {
return owner.Username == ""
}
6 changes: 3 additions & 3 deletions config/owner_accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
func OwnerSchema() schema.Element {
return schema.Object{
Properties: schema.ElementMap{
"displayName": schema.String{MaxLength: 100, Required: true},
"username": schema.String{MaxLength: 255, Required: true},
"emailAddress": schema.String{MaxLength: 255, Format: "email", Required: true},
"displayName": schema.String{MaxLength: 100},
"username": schema.String{MaxLength: 255},
"emailAddress": schema.String{MaxLength: 255, Format: "email"},
"phoneNumber": schema.String{MaxLength: 20},
"mailingAddress": schema.String{MaxLength: 1000},
},
Expand Down
5 changes: 5 additions & 0 deletions service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ func (service *User) CalcRuleCount(userID primitive.ObjectID) {

func (service *User) SetOwner(owner config.Owner) error {

// If there is no owner data, then do not create/update an owner record.
if owner.IsEmpty() {
return nil
}

// Try to read the owner from the database
users, err := service.ListUsernameOrOwner(owner.Username)

Expand Down

0 comments on commit 1849526

Please sign in to comment.