diff --git a/app/import_validators.go b/app/import_validators.go index 927776eac5..c22b782cdc 100644 --- a/app/import_validators.go +++ b/app/import_validators.go @@ -165,9 +165,9 @@ func validateChannelImportData(data *ChannelImportData) *model.AppError { return model.NewAppError("BulkImport", "app.import.validate_channel_import_data.name_characters.error", nil, "", http.StatusBadRequest) } - if data.DisplayName == nil { - return model.NewAppError("BulkImport", "app.import.validate_channel_import_data.display_name_missing.error", nil, "", http.StatusBadRequest) - } else if utf8.RuneCountInString(*data.DisplayName) == 0 || utf8.RuneCountInString(*data.DisplayName) > model.ChannelDisplayNameMaxRunes { + if data.DisplayName == nil || utf8.RuneCountInString(*data.DisplayName) == 0 { + data.DisplayName = data.Name // when displayName is missing we use name instead for displaying so we might as well convert it here. + } else if utf8.RuneCountInString(*data.DisplayName) > model.ChannelDisplayNameMaxRunes { return model.NewAppError("BulkImport", "app.import.validate_channel_import_data.display_name_length.error", nil, "", http.StatusBadRequest) } diff --git a/app/import_validators_test.go b/app/import_validators_test.go index 52f32d73e1..ff0b1c435d 100644 --- a/app/import_validators_test.go +++ b/app/import_validators_test.go @@ -404,11 +404,13 @@ func TestImportValidateChannelImportData(t *testing.T) { Type: &chanTypeOpen, } err = validateChannelImportData(&data) - require.NotNil(t, err, "Should have failed due to missing display_name.") + require.Nil(t, err, "Should have accepted having an empty display_name.") + require.Equal(t, data.Name, data.DisplayName, "Name and DisplayName should be the same if DisplayName is missing") data.DisplayName = ptrStr("") err = validateChannelImportData(&data) - require.NotNil(t, err, "Should have failed due to empty display_name.") + require.Nil(t, err, "Should have accepted having an empty display_name.") + require.Equal(t, data.Name, data.DisplayName, "Name and DisplayName should be the same if DisplayName is missing") data.DisplayName = ptrStr(strings.Repeat("abcdefghij", 7)) err = validateChannelImportData(&data) diff --git a/i18n/en.json b/i18n/en.json index c942c5594f..80d88dd093 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -5123,10 +5123,6 @@ "id": "app.import.validate_channel_import_data.display_name_length.error", "translation": "Channel display_name is not within permitted length constraints." }, - { - "id": "app.import.validate_channel_import_data.display_name_missing.error", - "translation": "Missing required channel property: display_name" - }, { "id": "app.import.validate_channel_import_data.header_length.error", "translation": "Channel header is too long."