diff --git a/server/public/model/custom_profile_attributes.go b/server/public/model/custom_profile_attributes.go index 25136daf133..006db039174 100644 --- a/server/public/model/custom_profile_attributes.go +++ b/server/public/model/custom_profile_attributes.go @@ -54,9 +54,9 @@ func IsKnownCustomProfilteAttributesVisibility(visibility string) bool { } type CustomProfileAttributesSelectOption struct { - ID string - Name string - Color string + ID string `json:"id"` + Name string `json:"name"` + Color string `json:"color"` } func NewCustomProfileAttributesSelectOptionFromMap(m map[string]any) CustomProfileAttributesSelectOption { @@ -64,31 +64,19 @@ func NewCustomProfileAttributesSelectOptionFromMap(m map[string]any) CustomProfi name := "" color := "" - if v, ok := m["ID"]; ok { - if vStr, ok := v.(string); ok { - id = vStr - } - } else if v, ok := m["id"]; ok { + if v, ok := m["id"]; ok { if vStr, ok := v.(string); ok { id = vStr } } - if v, ok := m["Name"]; ok { - if vStr, ok := v.(string); ok { - name = vStr - } - } else if v, ok := m["name"]; ok { + if v, ok := m["name"]; ok { if vStr, ok := v.(string); ok { name = vStr } } - if v, ok := m["Color"]; ok { - if vStr, ok := v.(string); ok { - color = vStr - } - } else if v, ok := m["color"]; ok { + if v, ok := m["color"]; ok { if vStr, ok := v.(string); ok { color = vStr } diff --git a/server/public/model/custom_profile_attributes_test.go b/server/public/model/custom_profile_attributes_test.go index 95b6e081973..076a23f5fbf 100644 --- a/server/public/model/custom_profile_attributes_test.go +++ b/server/public/model/custom_profile_attributes_test.go @@ -117,18 +117,7 @@ func TestNewCustomProfileAttributesSelectOptionFromMap(t *testing.T) { expected CustomProfileAttributesSelectOption }{ { - name: "title case keys", - input: map[string]any{ - "Name": "Test Option", - "Color": "#FF0000", - }, - expected: CustomProfileAttributesSelectOption{ - Name: "Test Option", - Color: "#FF0000", - }, - }, - { - name: "lower case keys", + name: "valid option", input: map[string]any{ "name": "Test Option", "color": "#FF0000", @@ -138,17 +127,6 @@ func TestNewCustomProfileAttributesSelectOptionFromMap(t *testing.T) { Color: "#FF0000", }, }, - { - name: "mixed case keys", - input: map[string]any{ - "Name": "Test Option", - "color": "#FF0000", - }, - expected: CustomProfileAttributesSelectOption{ - Name: "Test Option", - Color: "#FF0000", - }, - }, { name: "with spaces to trim", input: map[string]any{ @@ -161,23 +139,10 @@ func TestNewCustomProfileAttributesSelectOptionFromMap(t *testing.T) { }, }, { - name: "with provided ID", - input: map[string]any{ - "ID": "existingid123456789012345678", - "Name": "Test Option", - "Color": "#FF0000", - }, - expected: CustomProfileAttributesSelectOption{ - ID: "existingid123456789012345678", - Name: "Test Option", - Color: "#FF0000", - }, - }, - { - name: "with provided lowercase id", + name: "with provided id", input: map[string]any{ "id": "existingid123456789012345678", - "name": "Test Option", + "name": "Test Option", "color": "#FF0000", }, expected: CustomProfileAttributesSelectOption{