diff --git a/server/channels/api4/apitestlib.go b/server/channels/api4/apitestlib.go index 4915d4e332..75c90fe79f 100644 --- a/server/channels/api4/apitestlib.go +++ b/server/channels/api4/apitestlib.go @@ -95,7 +95,7 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent memoryConfig.SetDefaults() *memoryConfig.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins") *memoryConfig.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp") - memoryConfig.ServiceSettings.EnableLocalMode = model.NewBool(true) + memoryConfig.ServiceSettings.EnableLocalMode = model.NewPointer(true) *memoryConfig.ServiceSettings.LocalModeSocketLocation = filepath.Join(tempWorkspace, "mattermost_local.sock") *memoryConfig.LogSettings.EnableSentry = false // disable error reporting during tests *memoryConfig.LogSettings.ConsoleLevel = mlog.LvlStdLog.Name @@ -866,7 +866,7 @@ func (th *TestHelper) CreateDmChannel(user *model.User) *model.Channel { func (th *TestHelper) PatchChannelModerationsForMembers(channelId, name string, val bool) { patch := []*model.ChannelModerationPatch{{ Name: &name, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(val)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(val)}, }} channel, err := th.App.GetChannel(th.Context, channelId) @@ -981,10 +981,10 @@ func (th *TestHelper) GenerateTestEmail() string { func (th *TestHelper) CreateGroup() *model.Group { id := model.NewId() group := &model.Group{ - Name: model.NewString("n-" + id), + Name: model.NewPointer("n-" + id), DisplayName: "dn_" + id, Source: model.GroupSourceLdap, - RemoteId: model.NewString("ri_" + model.NewId()), + RemoteId: model.NewPointer("ri_" + model.NewId()), } group, err := th.App.CreateGroup(group) diff --git a/server/channels/api4/bot_test.go b/server/channels/api4/bot_test.go index 8a43e2ad3b..322f87caf8 100644 --- a/server/channels/api4/bot_test.go +++ b/server/channels/api4/bot_test.go @@ -39,7 +39,7 @@ func TestCreateBot(t *testing.T) { th.AddPermissionToRole(model.PermissionCreateBot.Id, model.TeamUserRoleId) th.App.UpdateUserRoles(th.Context, th.BasicUser.Id, model.TeamUserRoleId, false) - th.App.Config().ServiceSettings.EnableBotAccountCreation = model.NewBool(false) + th.App.Config().ServiceSettings.EnableBotAccountCreation = model.NewPointer(false) _, _, err := th.Client.CreateBot(context.Background(), &model.Bot{ Username: GenerateTestUsername(), @@ -1351,7 +1351,7 @@ func TestConvertBotToUser(t *testing.T) { require.Error(t, err) CheckBadRequestStatus(t, resp) - user, resp, err := th.Client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewString("password")}, false) + user, resp, err := th.Client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewPointer("password")}, false) require.Error(t, err) CheckForbiddenStatus(t, resp) require.Nil(t, user) @@ -1370,7 +1370,7 @@ func TestConvertBotToUser(t *testing.T) { CheckBadRequestStatus(t, resp) require.Nil(t, user) - user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewString("password")}, false) + user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewPointer("password")}, false) require.NoError(t, err) require.NotNil(t, user) require.Equal(t, bot.UserId, user.Id) @@ -1387,7 +1387,7 @@ func TestConvertBotToUser(t *testing.T) { require.NoError(t, err) CheckCreatedStatus(t, resp) - user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewString("password")}, true) + user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewPointer("password")}, true) require.NoError(t, err) require.NotNil(t, user) require.Equal(t, bot.UserId, user.Id) diff --git a/server/channels/api4/channel_bookmark_test.go b/server/channels/api4/channel_bookmark_test.go index 7089727c04..7ae6c06d0a 100644 --- a/server/channels/api4/channel_bookmark_test.go +++ b/server/channels/api4/channel_bookmark_test.go @@ -353,8 +353,8 @@ func TestEditChannelBookmark(t *testing.T) { require.NotNil(t, cb) patch := &model.ChannelBookmarkPatch{ - DisplayName: model.NewString("Edited bookmark test"), - LinkUrl: model.NewString("http://edited.url"), + DisplayName: model.NewPointer("Edited bookmark test"), + LinkUrl: model.NewPointer("http://edited.url"), } ucb, resp, err := tc.userClient.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch) @@ -394,8 +394,8 @@ func TestEditChannelBookmark(t *testing.T) { // try to patch the channel bookmark patch := &model.ChannelBookmarkPatch{ - DisplayName: model.NewString("Edited bookmark test"), - LinkUrl: model.NewString("http://edited.url"), + DisplayName: model.NewPointer("Edited bookmark test"), + LinkUrl: model.NewPointer("http://edited.url"), } ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch) @@ -406,8 +406,8 @@ func TestEditChannelBookmark(t *testing.T) { t.Run("trying to edit a nonexistent bookmark should fail", func(t *testing.T) { patch := &model.ChannelBookmarkPatch{ - DisplayName: model.NewString("Edited bookmark test"), - LinkUrl: model.NewString("http://edited.url"), + DisplayName: model.NewPointer("Edited bookmark test"), + LinkUrl: model.NewPointer("http://edited.url"), } ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), th.BasicChannel.Id, model.NewId(), patch) @@ -434,8 +434,8 @@ func TestEditChannelBookmark(t *testing.T) { require.Nil(t, appErr) patch := &model.ChannelBookmarkPatch{ - DisplayName: model.NewString("Edited bookmark test"), - LinkUrl: model.NewString("http://edited.url"), + DisplayName: model.NewPointer("Edited bookmark test"), + LinkUrl: model.NewPointer("http://edited.url"), } ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch) @@ -471,8 +471,8 @@ func TestEditChannelBookmark(t *testing.T) { require.NotNil(t, cb) patch := &model.ChannelBookmarkPatch{ - DisplayName: model.NewString("Edited bookmark test"), - LinkUrl: model.NewString("http://edited.url"), + DisplayName: model.NewPointer("Edited bookmark test"), + LinkUrl: model.NewPointer("http://edited.url"), } ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch) @@ -521,8 +521,8 @@ func TestEditChannelBookmark(t *testing.T) { require.NotNil(t, cb) patch := &model.ChannelBookmarkPatch{ - DisplayName: model.NewString("Edited bookmark test"), - LinkUrl: model.NewString("http://edited.url"), + DisplayName: model.NewPointer("Edited bookmark test"), + LinkUrl: model.NewPointer("http://edited.url"), } ucb, resp, err := guestClient.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch) @@ -561,8 +561,8 @@ func TestEditChannelBookmark(t *testing.T) { require.NotNil(t, cb) patch := &model.ChannelBookmarkPatch{ - DisplayName: model.NewString("Edited bookmark test"), - LinkUrl: model.NewString("http://edited.url"), + DisplayName: model.NewPointer("Edited bookmark test"), + LinkUrl: model.NewPointer("http://edited.url"), } // create a client for basic user 2 @@ -611,7 +611,7 @@ func TestEditChannelBookmark(t *testing.T) { require.Nil(t, appErr) require.NotNil(t, cb) - patch := &model.ChannelBookmarkPatch{DisplayName: model.NewString("Edited bookmark test")} + patch := &model.ChannelBookmarkPatch{DisplayName: model.NewPointer("Edited bookmark test")} _, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch) require.NoError(t, err) CheckOKStatus(t, resp) diff --git a/server/channels/api4/channel_test.go b/server/channels/api4/channel_test.go index 85e73149bf..f9394b9871 100644 --- a/server/channels/api4/channel_test.go +++ b/server/channels/api4/channel_test.go @@ -139,7 +139,7 @@ func TestCreateChannel(t *testing.T) { require.Equal(t, http.StatusBadRequest, r.StatusCode, "Expected 400 Bad Request") // Test GroupConstrained flag - groupConstrainedChannel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.ChannelTypeOpen, TeamId: team.Id, GroupConstrained: model.NewBool(true)} + groupConstrainedChannel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.ChannelTypeOpen, TeamId: team.Id, GroupConstrained: model.NewPointer(true)} rchannel, _, err = client.CreateChannel(context.Background(), groupConstrainedChannel) require.NoError(t, err) @@ -187,7 +187,7 @@ func TestUpdateChannel(t *testing.T) { require.Equal(t, channel.Purpose, newChannel.Purpose, "Update failed for Purpose") // Test GroupConstrained flag - channel.GroupConstrained = model.NewBool(true) + channel.GroupConstrained = model.NewPointer(true) rchannel, resp, err := client.UpdateChannel(context.Background(), channel) require.NoError(t, err) CheckOKStatus(t, resp) @@ -386,7 +386,7 @@ func TestPatchChannel(t *testing.T) { CheckBadRequestStatus(t, resp) // Test GroupConstrained flag - patch.GroupConstrained = model.NewBool(true) + patch.GroupConstrained = model.NewPointer(true) rchannel, resp, err := client.PatchChannel(context.Background(), th.BasicChannel.Id, patch) require.NoError(t, err) CheckOKStatus(t, resp) @@ -1351,7 +1351,7 @@ func TestGetAllChannels(t *testing.T) { policy, err := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{policyChannel.Id}, }) @@ -1698,7 +1698,7 @@ func TestSearchAllChannels(t *testing.T) { DisplayName: "SearchAllChannels-groupConstrained-1", Name: "groupconstrained1", Type: model.ChannelTypePrivate, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), TeamId: team.Id, }) require.NoError(t, err) @@ -1853,7 +1853,7 @@ func TestSearchAllChannels(t *testing.T) { policy, savePolicyErr := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{policyChannel.Id}, }) @@ -1896,8 +1896,8 @@ func TestSearchAllChannelsPaged(t *testing.T) { search := &model.ChannelSearch{Term: th.BasicChannel.Name} search.Term = "" - search.Page = model.NewInt(0) - search.PerPage = model.NewInt(2) + search.Page = model.NewPointer(0) + search.PerPage = model.NewPointer(2) channelsWithCount, _, err := th.SystemAdminClient.SearchAllChannelsPaged(context.Background(), search) require.NoError(t, err) require.Len(t, channelsWithCount.Channels, 2) @@ -3369,7 +3369,7 @@ func TestAddChannelMember(t *testing.T) { client.Logout(context.Background()) // Set a channel to group-constrained - privateChannel.GroupConstrained = model.NewBool(true) + privateChannel.GroupConstrained = model.NewPointer(true) _, appErr := th.App.UpdateChannel(th.Context, privateChannel) require.Nil(t, appErr) @@ -3780,7 +3780,7 @@ func TestRemoveChannelMember(t *testing.T) { require.NoError(t, err) // If the channel is group-constrained the user cannot be removed - privateChannel.GroupConstrained = model.NewBool(true) + privateChannel.GroupConstrained = model.NewPointer(true) _, appErr := th.App.UpdateChannel(th.Context, privateChannel) require.Nil(t, appErr) _, err = client.RemoveUserFromChannel(context.Background(), privateChannel.Id, user2.Id) @@ -4272,7 +4272,7 @@ func TestChannelMembersMinusGroupMembers(t *testing.T) { _, appErr = th.App.AddChannelMember(th.Context, user2.Id, channel, app.ChannelMemberOpts{}) require.Nil(t, appErr) - channel.GroupConstrained = model.NewBool(true) + channel.GroupConstrained = model.NewPointer(true) channel, appErr = th.App.UpdateChannel(th.Context, channel) require.Nil(t, appErr) @@ -4615,7 +4615,7 @@ func TestPatchChannelModerations(t *testing.T) { patch := []*model.ChannelModerationPatch{ { Name: &createPosts, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)}, }, } @@ -4652,7 +4652,7 @@ func TestPatchChannelModerations(t *testing.T) { patch := []*model.ChannelModerationPatch{ { Name: &createPosts, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)}, }, } @@ -4729,7 +4729,7 @@ func TestPatchChannelModerations(t *testing.T) { patch := []*model.ChannelModerationPatch{ { Name: &createPosts, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)}, }, } @@ -4814,9 +4814,9 @@ func TestGetChannelMemberCountsByGroup(t *testing.T) { id := model.NewId() group := &model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, appErr = th.App.CreateGroup(group) diff --git a/server/channels/api4/command_test.go b/server/channels/api4/command_test.go index c9cf00dd17..c63ca75834 100644 --- a/server/channels/api4/command_test.go +++ b/server/channels/api4/command_test.go @@ -1130,8 +1130,8 @@ func TestExecuteCommandReadOnly(t *testing.T) { []*model.ChannelModerationPatch{{ Name: &model.PermissionCreatePost.Id, Roles: &model.ChannelModeratedRolesPatch{ - Guests: model.NewBool(false), - Members: model.NewBool(false), + Guests: model.NewPointer(false), + Members: model.NewPointer(false), }, }}) require.Nil(t, appErr) diff --git a/server/channels/api4/config_test.go b/server/channels/api4/config_test.go index ef363f277a..d908e4d315 100644 --- a/server/channels/api4/config_test.go +++ b/server/channels/api4/config_test.go @@ -178,8 +178,8 @@ func TestUpdateConfig(t *testing.T) { t.Run("Should fail with validation error if invalid config setting is passed", func(t *testing.T) { //Revert the change badcfg := cfg.Clone() - badcfg.PasswordSettings.MinimumLength = model.NewInt(4) - badcfg.PasswordSettings.MinimumLength = model.NewInt(4) + badcfg.PasswordSettings.MinimumLength = model.NewPointer(4) + badcfg.PasswordSettings.MinimumLength = model.NewPointer(4) _, resp, err = client.UpdateConfig(context.Background(), badcfg) require.Error(t, err) CheckBadRequestStatus(t, resp) @@ -496,11 +496,11 @@ func TestUpdateConfigDiffInAuditRecord(t *testing.T) { require.NoError(t, err) timeoutVal := *cfg.ServiceSettings.ReadTimeout - cfg.ServiceSettings.ReadTimeout = model.NewInt(timeoutVal + 1) + cfg.ServiceSettings.ReadTimeout = model.NewPointer(timeoutVal + 1) cfg, _, err = th.SystemAdminClient.UpdateConfig(context.Background(), cfg) require.NoError(t, err) defer th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.ReadTimeout = model.NewInt(timeoutVal) + cfg.ServiceSettings.ReadTimeout = model.NewPointer(timeoutVal) }) require.Equal(t, timeoutVal+1, *cfg.ServiceSettings.ReadTimeout) @@ -642,7 +642,7 @@ func TestPatchConfig(t *testing.T) { // Ensure ConsoleLevel is set to DEBUG config := model.Config{LogSettings: model.LogSettings{ - ConsoleLevel: model.NewString("DEBUG"), + ConsoleLevel: model.NewPointer("DEBUG"), }} _, _, err := th.SystemAdminClient.PatchConfig(context.Background(), &config) require.NoError(t, err) @@ -663,7 +663,7 @@ func TestPatchConfig(t *testing.T) { *th.App.Config().ExperimentalSettings.RestrictSystemAdmin = true config := model.Config{LogSettings: model.LogSettings{ - ConsoleLevel: model.NewString("INFO"), + ConsoleLevel: model.NewPointer("INFO"), }} updatedConfig, _, _ := th.SystemAdminClient.PatchConfig(context.Background(), &config) @@ -675,7 +675,7 @@ func TestPatchConfig(t *testing.T) { *th.App.Config().ExperimentalSettings.RestrictSystemAdmin = true config := model.Config{LogSettings: model.LogSettings{ - ConsoleLevel: model.NewString("INFO"), + ConsoleLevel: model.NewPointer("INFO"), }} oldConfig, _, _ := th.LocalClient.GetConfig(context.Background()) @@ -690,7 +690,7 @@ func TestPatchConfig(t *testing.T) { th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { t.Run("check if config is valid", func(t *testing.T) { config := model.Config{PasswordSettings: model.PasswordSettings{ - MinimumLength: model.NewInt(4), + MinimumLength: model.NewPointer(4), }} _, response, err := client.PatchConfig(context.Background(), &config) @@ -713,12 +713,12 @@ func TestPatchConfig(t *testing.T) { assert.True(t, oldConfig.PluginSettings.PluginStates["com.mattermost.nps"].Enable) states := make(map[string]*model.PluginState) - states["com.mattermost.nps"] = &model.PluginState{Enable: *model.NewBool(false)} + states["com.mattermost.nps"] = &model.PluginState{Enable: *model.NewPointer(false)} config := model.Config{PasswordSettings: model.PasswordSettings{ - Lowercase: model.NewBool(true), - MinimumLength: model.NewInt(15), + Lowercase: model.NewPointer(true), + MinimumLength: model.NewPointer(15), }, LogSettings: model.LogSettings{ - ConsoleLevel: model.NewString("INFO"), + ConsoleLevel: model.NewPointer("INFO"), }, TeamSettings: model.TeamSettings{ ExperimentalDefaultChannels: []string{"another-channel"}, @@ -746,7 +746,7 @@ func TestPatchConfig(t *testing.T) { t.Run("should sanitize config", func(t *testing.T) { config := model.Config{PasswordSettings: model.PasswordSettings{ - Symbol: model.NewBool(true), + Symbol: model.NewPointer(true), }} updatedConfig, _, err := client.PatchConfig(context.Background(), &config) @@ -757,7 +757,7 @@ func TestPatchConfig(t *testing.T) { t.Run("not allowing to toggle enable uploads for plugin via api", func(t *testing.T) { config := model.Config{PluginSettings: model.PluginSettings{ - EnableUploads: model.NewBool(true), + EnableUploads: model.NewPointer(true), }} updatedConfig, resp, err := client.PatchConfig(context.Background(), &config) @@ -810,7 +810,7 @@ func TestPatchConfig(t *testing.T) { nonEmptyURL := "http://localhost" config := model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString(nonEmptyURL), + SiteURL: model.NewPointer(nonEmptyURL), }, } updatedConfig, _, err := th.SystemAdminClient.PatchConfig(context.Background(), &config) @@ -820,7 +820,7 @@ func TestPatchConfig(t *testing.T) { // Check that the Site URL can't be cleared config = model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString(""), + SiteURL: model.NewPointer(""), }, } _, resp, err := th.SystemAdminClient.PatchConfig(context.Background(), &config) diff --git a/server/channels/api4/data_retention.go b/server/channels/api4/data_retention.go index 1653e94d94..43c8936190 100644 --- a/server/channels/api4/data_retention.go +++ b/server/channels/api4/data_retention.go @@ -243,8 +243,8 @@ func searchTeamsInPolicy(c *Context, w http.ResponseWriter, r *http.Request) { return } - props.PolicyID = model.NewString(c.Params.PolicyId) - props.IncludePolicyID = model.NewBool(true) + props.PolicyID = model.NewPointer(c.Params.PolicyId) + props.IncludePolicyID = model.NewPointer(true) teams, _, appErr := c.App.SearchAllTeams(&props) if appErr != nil { diff --git a/server/channels/api4/elasticsearch.go b/server/channels/api4/elasticsearch.go index eba5dcf286..763eaf6e46 100644 --- a/server/channels/api4/elasticsearch.go +++ b/server/channels/api4/elasticsearch.go @@ -30,7 +30,7 @@ func testElasticsearch(c *Context, w http.ResponseWriter, r *http.Request) { // we set BulkIndexingTimeWindowSeconds to a random value to avoid failing on the nil check // TODO: remove this hack once we remove BulkIndexingTimeWindowSeconds from the config. if cfg.ElasticsearchSettings.BulkIndexingTimeWindowSeconds == nil { - cfg.ElasticsearchSettings.BulkIndexingTimeWindowSeconds = model.NewInt(0) + cfg.ElasticsearchSettings.BulkIndexingTimeWindowSeconds = model.NewPointer(0) } if checkHasNilFields(&cfg.ElasticsearchSettings) { c.Err = model.NewAppError("testElasticsearch", "api.elasticsearch.test_elasticsearch_settings_nil.app_error", nil, "", http.StatusBadRequest) diff --git a/server/channels/api4/group_test.go b/server/channels/api4/group_test.go index 0abcfa793f..35eaeac27d 100644 --- a/server/channels/api4/group_test.go +++ b/server/channels/api4/group_test.go @@ -23,10 +23,10 @@ func TestGetGroup(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -72,7 +72,7 @@ func TestCreateGroup(t *testing.T) { id := model.NewId() g := &model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceCustom, Description: "description_" + id, AllowReference: true, @@ -95,7 +95,7 @@ func TestCreateGroup(t *testing.T) { gbroken := &model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: "rrrr", Description: "description_" + id, } @@ -106,7 +106,7 @@ func TestCreateGroup(t *testing.T) { validGroup := &model.Group{ DisplayName: "dn_" + model.NewId(), - Name: model.NewString("name" + model.NewId()), + Name: model.NewPointer("name" + model.NewId()), Source: model.GroupSourceCustom, AllowReference: true, } @@ -135,7 +135,7 @@ func TestCreateGroup(t *testing.T) { unReferenceableCustomGroup := &model.Group{ DisplayName: "dn_" + model.NewId(), - Name: model.NewString("name" + model.NewId()), + Name: model.NewPointer("name" + model.NewId()), Source: model.GroupSourceCustom, AllowReference: false, } @@ -149,10 +149,10 @@ func TestCreateGroup(t *testing.T) { customGroupWithRemoteID := &model.Group{ DisplayName: "dn_" + model.NewId(), - Name: model.NewString("name" + model.NewId()), + Name: model.NewPointer("name" + model.NewId()), Source: model.GroupSourceCustom, AllowReference: true, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, response, err = th.SystemAdminClient.CreateGroup(context.Background(), customGroupWithRemoteID) require.Error(t, err) @@ -160,7 +160,7 @@ func TestCreateGroup(t *testing.T) { reservedNameGroup := &model.Group{ DisplayName: "dn_" + model.NewId(), - Name: model.NewString("here"), + Name: model.NewPointer("here"), Source: model.GroupSourceCustom, AllowReference: true, } @@ -181,10 +181,10 @@ func TestDeleteGroup(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -209,7 +209,7 @@ func TestDeleteGroup(t *testing.T) { validGroup, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + model.NewId(), - Name: model.NewString("name" + model.NewId()), + Name: model.NewPointer("name" + model.NewId()), Source: model.GroupSourceCustom, }) assert.Nil(t, appErr) @@ -227,7 +227,7 @@ func TestUndeleteGroup(t *testing.T) { validGroup, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + model.NewId(), - Name: model.NewString("name" + model.NewId()), + Name: model.NewPointer("name" + model.NewId()), Source: model.GroupSourceCustom, }) assert.Nil(t, appErr) @@ -258,16 +258,16 @@ func TestPatchGroup(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) g2, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + model.NewId(), - Name: model.NewString("name" + model.NewId()), + Name: model.NewPointer("name" + model.NewId()), Source: model.GroupSourceCustom, AllowReference: true, }) @@ -325,24 +325,24 @@ func TestPatchGroup(t *testing.T) { CheckNotFoundStatus(t, response) _, response, err = th.SystemAdminClient.PatchGroup(context.Background(), g2.Id, &model.GroupPatch{ - Name: model.NewString(model.NewId()), - DisplayName: model.NewString("foo"), - AllowReference: model.NewBool(false), + Name: model.NewPointer(model.NewId()), + DisplayName: model.NewPointer("foo"), + AllowReference: model.NewPointer(false), }) require.Error(t, err) CheckBadRequestStatus(t, response) // ensure that omitting the AllowReference field from the patch doesn't patch it to false patchedG2, response, err := th.SystemAdminClient.PatchGroup(context.Background(), g2.Id, &model.GroupPatch{ - Name: model.NewString(model.NewId()), - DisplayName: model.NewString("foo"), + Name: model.NewPointer(model.NewId()), + DisplayName: model.NewPointer("foo"), }) require.NoError(t, err) CheckOKStatus(t, response) require.Equal(t, true, patchedG2.AllowReference) _, response, err = th.SystemAdminClient.PatchGroup(context.Background(), g2.Id, &model.GroupPatch{ - Name: model.NewString("here"), + Name: model.NewPointer("here"), }) require.Error(t, err) CheckBadRequestStatus(t, response) @@ -360,26 +360,26 @@ func TestLinkGroupTeam(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) id = model.NewId() gRef, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), AllowReference: true, }) assert.Nil(t, appErr) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } t.Run("Error if no license is installed", func(t *testing.T) { @@ -451,10 +451,10 @@ func TestLinkGroupTeam(t *testing.T) { gid := model.NewId() gCustom, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + gid, - Name: model.NewString("name" + gid), + Name: model.NewPointer("name" + gid), Source: model.GroupSourceCustom, Description: "description_" + gid, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -472,26 +472,26 @@ func TestLinkGroupChannel(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) id = model.NewId() gRef, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), AllowReference: true, }) assert.Nil(t, appErr) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } t.Run("Error if no license is installed", func(t *testing.T) { @@ -575,10 +575,10 @@ func TestLinkGroupChannel(t *testing.T) { gid := model.NewId() g2, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + gid, - Name: model.NewString("name" + gid), + Name: model.NewPointer("name" + gid), Source: model.GroupSourceCustom, Description: "description_" + gid, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -596,26 +596,26 @@ func TestUnlinkGroupTeam(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) id = model.NewId() gRef, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), AllowReference: true, }) assert.Nil(t, appErr) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } th.App.Srv().SetLicense(model.NewTestLicense("ldap")) @@ -694,10 +694,10 @@ func TestUnlinkGroupTeam(t *testing.T) { gid := model.NewId() g2, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + gid, - Name: model.NewString("name" + gid), + Name: model.NewPointer("name" + gid), Source: model.GroupSourceCustom, Description: "description_" + gid, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -714,26 +714,26 @@ func TestUnlinkGroupChannel(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) id = model.NewId() gRef, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), AllowReference: true, }) assert.Nil(t, appErr) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } th.App.Srv().SetLicense(model.NewTestLicense("ldap")) @@ -812,10 +812,10 @@ func TestUnlinkGroupChannel(t *testing.T) { gid := model.NewId() g2, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + gid, - Name: model.NewString("name" + gid), + Name: model.NewPointer("name" + gid), Source: model.GroupSourceCustom, Description: "description_" + gid, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -832,10 +832,10 @@ func TestGetGroupTeam(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -850,7 +850,7 @@ func TestGetGroupTeam(t *testing.T) { th.App.Srv().SetLicense(model.NewTestLicense("ldap")) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } _, response, _ = th.SystemAdminClient.LinkGroupSyncable(context.Background(), g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) @@ -894,10 +894,10 @@ func TestGetGroupChannel(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -912,7 +912,7 @@ func TestGetGroupChannel(t *testing.T) { th.App.Srv().SetLicense(model.NewTestLicense("ldap")) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } _, response, _ = th.SystemAdminClient.LinkGroupSyncable(context.Background(), g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) @@ -956,17 +956,17 @@ func TestGetGroupTeams(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) th.App.Srv().SetLicense(model.NewTestLicense("ldap")) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } for i := 0; i < 10; i++ { @@ -1009,17 +1009,17 @@ func TestGetGroupChannels(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) th.App.Srv().SetLicense(model.NewTestLicense("ldap")) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } for i := 0; i < 10; i++ { @@ -1061,15 +1061,15 @@ func TestPatchGroupTeam(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } th.App.Srv().SetLicense(model.NewTestLicense("ldap")) @@ -1090,7 +1090,7 @@ func TestPatchGroupTeam(t *testing.T) { th.App.Srv().SetLicense(model.NewTestLicense("ldap")) - patch.AutoAdd = model.NewBool(false) + patch.AutoAdd = model.NewPointer(false) groupSyncable, response, err = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) require.NoError(t, err) CheckOKStatus(t, response) @@ -1100,7 +1100,7 @@ func TestPatchGroupTeam(t *testing.T) { assert.Equal(t, th.BasicTeam.Id, groupSyncable.SyncableId) assert.Equal(t, model.GroupSyncableTypeTeam, groupSyncable.Type) - patch.AutoAdd = model.NewBool(true) + patch.AutoAdd = model.NewPointer(true) _, response, _ = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) CheckOKStatus(t, response) @@ -1133,15 +1133,15 @@ func TestPatchGroupChannel(t *testing.T) { id := model.NewId() g, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) patch := &model.GroupSyncablePatch{ - AutoAdd: model.NewBool(true), + AutoAdd: model.NewPointer(true), } th.App.Srv().SetLicense(model.NewTestLicense("ldap")) @@ -1171,7 +1171,7 @@ func TestPatchGroupChannel(t *testing.T) { th.App.Srv().SetLicense(model.NewTestLicense("ldap")) - patch.AutoAdd = model.NewBool(false) + patch.AutoAdd = model.NewPointer(false) groupSyncable, response, err = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) require.NoError(t, err) CheckOKStatus(t, response) @@ -1182,7 +1182,7 @@ func TestPatchGroupChannel(t *testing.T) { assert.Equal(t, th.BasicChannel.TeamId, groupSyncable.TeamID) assert.Equal(t, model.GroupSyncableTypeChannel, groupSyncable.Type) - patch.AutoAdd = model.NewBool(true) + patch.AutoAdd = model.NewPointer(true) _, response, err = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) require.NoError(t, err) CheckOKStatus(t, response) @@ -1216,10 +1216,10 @@ func TestGetGroupsByChannel(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1270,7 +1270,7 @@ func TestGetGroupsByChannel(t *testing.T) { var groups []*model.GroupWithSchemeAdmin groups, _, _, err = client.GetGroupsByChannel(context.Background(), th.BasicChannel.Id, opts) assert.NoError(t, err) - assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups) + assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) require.False(t, *groups[0].SchemeAdmin) }) @@ -1284,7 +1284,7 @@ func TestGetGroupsByChannel(t *testing.T) { groups, _, _, err := client.GetGroupsByChannel(context.Background(), th.BasicChannel.Id, opts) assert.NoError(t, err) // ensure that SchemeAdmin field is updated - assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups) + assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) require.True(t, *groups[0].SchemeAdmin) @@ -1301,10 +1301,10 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1342,7 +1342,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) { assert.Equal(t, map[string][]*model.GroupWithSchemeAdmin{ th.BasicChannel.Id: { - {Group: *group, SchemeAdmin: model.NewBool(false)}, + {Group: *group, SchemeAdmin: model.NewPointer(false)}, }, }, groups) @@ -1360,7 +1360,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) { assert.Equal(t, map[string][]*model.GroupWithSchemeAdmin{ th.BasicChannel.Id: { - {Group: *group, SchemeAdmin: model.NewBool(true)}, + {Group: *group, SchemeAdmin: model.NewPointer(true)}, }, }, groups) @@ -1396,10 +1396,10 @@ func TestGetGroupsByTeam(t *testing.T) { id := model.NewId() group, err := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, err) @@ -1443,7 +1443,7 @@ func TestGetGroupsByTeam(t *testing.T) { th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { groups, _, _, err := client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts) assert.NoError(t, err) - assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups) + assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) require.False(t, *groups[0].SchemeAdmin) }) @@ -1457,7 +1457,7 @@ func TestGetGroupsByTeam(t *testing.T) { groups, _, _, err := client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts) assert.NoError(t, err) // ensure that SchemeAdmin field is updated - assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups) + assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) require.True(t, *groups[0].SchemeAdmin) @@ -1471,7 +1471,7 @@ func TestGetGroupsByTeam(t *testing.T) { groups, _, _, err := client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts) require.NoError(t, err) require.Len(t, groups, 1) - require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups) + require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) require.True(t, *groups[0].SchemeAdmin) }, "groups can be fetched by system admins even if they're not part of a team") @@ -1480,7 +1480,7 @@ func TestGetGroupsByTeam(t *testing.T) { groups, _, _, err := th.Client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts) require.NoError(t, err) require.Len(t, groups, 1) - require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups) + require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) require.True(t, *groups[0].SchemeAdmin) }) @@ -1506,10 +1506,10 @@ func TestGetGroups(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) start := group.UpdateAt - 1 @@ -1517,10 +1517,10 @@ func TestGetGroups(t *testing.T) { id2 := model.NewId() group2, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id2, - Name: model.NewString("name" + id2), + Name: model.NewPointer("name" + id2), Source: model.GroupSourceCustom, Description: "description_" + id2, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1676,10 +1676,10 @@ func TestGetGroupsByUserId(t *testing.T) { id := model.NewId() group1, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1692,10 +1692,10 @@ func TestGetGroupsByUserId(t *testing.T) { id = model.NewId() group2, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1741,10 +1741,10 @@ func TestGetGroupMembers(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1807,10 +1807,10 @@ func TestGetGroupStats(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1859,10 +1859,10 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) { id := model.NewId() group, err := th.App.CreateGroup(&model.Group{ DisplayName: fmt.Sprintf("dn-foo_%d", i), - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.Nil(t, err) groups = append(groups, group) @@ -1876,7 +1876,7 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) { Name: "name" + id, Type: model.ChannelTypePrivate, TeamId: team.Id, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } channel, appErr := th.App.CreateChannel(th.Context, channel, false) require.Nil(t, appErr) @@ -1888,7 +1888,7 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) { require.Contains(t, apiGroups, groups[1]) require.Contains(t, apiGroups, groups[2]) - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) team, appErr = th.App.UpdateTeam(team) require.Nil(t, appErr) @@ -1939,7 +1939,7 @@ func TestAddMembersToGroup(t *testing.T) { id := model.NewId() group, err := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceCustom, Description: "description_" + id, }) @@ -1991,10 +1991,10 @@ func TestAddMembersToGroup(t *testing.T) { ldapId := model.NewId() ldapGroup, err := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + ldapId, - Name: model.NewString("name" + ldapId), + Name: model.NewPointer("name" + ldapId), Source: model.GroupSourceLdap, Description: "description_" + ldapId, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, err) @@ -2018,7 +2018,7 @@ func TestDeleteMembersFromGroup(t *testing.T) { id := model.NewId() g := &model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceCustom, Description: "description_" + id, } @@ -2069,10 +2069,10 @@ func TestDeleteMembersFromGroup(t *testing.T) { ldapId := model.NewId() g1 := &model.Group{ DisplayName: "dn_" + ldapId, - Name: model.NewString("name" + ldapId), + Name: model.NewPointer("name" + ldapId), Source: model.GroupSourceLdap, Description: "description_" + ldapId, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } ldapGroup, err := th.App.CreateGroupWithUserIds(&model.GroupWithUserIds{ Group: *g1, diff --git a/server/channels/api4/image_test.go b/server/channels/api4/image_test.go index 66883fb4fb..4beac06cbb 100644 --- a/server/channels/api4/image_test.go +++ b/server/channels/api4/image_test.go @@ -30,7 +30,7 @@ func TestGetImage(t *testing.T) { imageURL := "http://foo.bar/baz.gif" th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ImageProxySettings.Enable = model.NewBool(false) + cfg.ImageProxySettings.Enable = model.NewPointer(false) }) r, err := http.NewRequest("GET", th.Client.APIURL+"/image?url="+url.QueryEscape(imageURL), nil) @@ -48,10 +48,10 @@ func TestGetImage(t *testing.T) { proxiedURL := "https://proxy.foo.bar/004afe2ef382eb5f30c4490f793f8a8c5b33d8a2/687474703a2f2f666f6f2e6261722f62617a2e676966" th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ImageProxySettings.Enable = model.NewBool(true) - cfg.ImageProxySettings.ImageProxyType = model.NewString("atmos/camo") - cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewString("foo") - cfg.ImageProxySettings.RemoteImageProxyURL = model.NewString("https://proxy.foo.bar") + cfg.ImageProxySettings.Enable = model.NewPointer(true) + cfg.ImageProxySettings.ImageProxyType = model.NewPointer("atmos/camo") + cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewPointer("foo") + cfg.ImageProxySettings.RemoteImageProxyURL = model.NewPointer("https://proxy.foo.bar") }) r, err := http.NewRequest("GET", th.Client.APIURL+"/image?url="+url.QueryEscape(imageURL), nil) @@ -66,11 +66,11 @@ func TestGetImage(t *testing.T) { t.Run("local", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ImageProxySettings.Enable = model.NewBool(true) - cfg.ImageProxySettings.ImageProxyType = model.NewString("local") + cfg.ImageProxySettings.Enable = model.NewPointer(true) + cfg.ImageProxySettings.ImageProxyType = model.NewPointer("local") // Allow requests to the "remote" image - cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewString("127.0.0.1") + cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewPointer("127.0.0.1") }) handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -104,7 +104,7 @@ func TestGetImage(t *testing.T) { // protocol relative URLs should be handled by proxy th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.SiteURL = model.NewString("http://foo.com") + cfg.ServiceSettings.SiteURL = model.NewPointer("http://foo.com") }) r, err = http.NewRequest("GET", th.Client.APIURL+"/image?url="+strings.TrimPrefix(imageServer.URL, "http:")+"/image.png", nil) require.NoError(t, err) diff --git a/server/channels/api4/integration_action_test.go b/server/channels/api4/integration_action_test.go index ca53caf7c9..d2ed44153f 100644 --- a/server/channels/api4/integration_action_test.go +++ b/server/channels/api4/integration_action_test.go @@ -272,7 +272,7 @@ func TestOpenDialog(t *testing.T) { t.Run("Should fail if trigger timeout is extended", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1) + cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1)) }) time.Sleep(2 * time.Second) diff --git a/server/channels/api4/ip_filtering_test.go b/server/channels/api4/ip_filtering_test.go index 67989baaf7..9338ffd264 100644 --- a/server/channels/api4/ip_filtering_test.go +++ b/server/channels/api4/ip_filtering_test.go @@ -16,8 +16,8 @@ import ( func Test_getIPFilters(t *testing.T) { lic := &model.License{ Features: &model.Features{ - CustomPermissionsSchemes: model.NewBool(false), - Cloud: model.NewBool(true), + CustomPermissionsSchemes: model.NewPointer(false), + Cloud: model.NewPointer(true), }, Customer: &model.Customer{ Name: "TestName", @@ -247,8 +247,8 @@ func Test_applyIPFilters(t *testing.T) { func Test_getMyIP(t *testing.T) { lic := &model.License{ Features: &model.Features{ - CustomPermissionsSchemes: model.NewBool(false), - Cloud: model.NewBool(true), + CustomPermissionsSchemes: model.NewPointer(false), + Cloud: model.NewPointer(true), }, Customer: &model.Customer{ Name: "TestName", diff --git a/server/channels/api4/license_test.go b/server/channels/api4/license_test.go index d3270974b8..060659ffef 100644 --- a/server/channels/api4/license_test.go +++ b/server/channels/api4/license_test.go @@ -131,7 +131,7 @@ func TestUploadLicenseFile(t *testing.T) { license := model.License{ Id: model.NewId(), Features: &model.Features{ - Users: model.NewInt(100), + Users: model.NewPointer(100), }, Customer: &model.Customer{ Name: "Test", @@ -259,7 +259,7 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) { t.Run("trial license user count less than current users", func(t *testing.T) { license := model.NewTestLicense() - license.Features.Users = model.NewInt(nUsers) + license.Features.Users = model.NewPointer(nUsers) licenseJSON, jsonErr := json.Marshal(license) require.NoError(t, jsonErr) testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -295,7 +295,7 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) { t.Run("returns status 451 when it receives status 451", func(t *testing.T) { license := model.NewTestLicense() - license.Features.Users = model.NewInt(nUsers) + license.Features.Users = model.NewPointer(nUsers) licenseJSON, jsonErr := json.Marshal(license) require.NoError(t, jsonErr) testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -328,7 +328,7 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) { validTrialRequest.Users = 100 defer func() { validTrialRequest.CompanyCountry = "US" }() license := model.NewTestLicense() - license.Features.Users = model.NewInt(nUsers) + license.Features.Users = model.NewPointer(nUsers) licenseJSON, jsonErr := json.Marshal(license) require.NoError(t, jsonErr) testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -389,7 +389,7 @@ func TestRequestTrialLicense(t *testing.T) { t.Run("trial license user count less than current users", func(t *testing.T) { nUsers := 1 license := model.NewTestLicense() - license.Features.Users = model.NewInt(nUsers) + license.Features.Users = model.NewPointer(nUsers) licenseJSON, jsonErr := json.Marshal(license) require.NoError(t, jsonErr) testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -424,7 +424,7 @@ func TestRequestTrialLicense(t *testing.T) { t.Run("returns status 451 when it receives status 451", func(t *testing.T) { nUsers := 1 license := model.NewTestLicense() - license.Features.Users = model.NewInt(nUsers) + license.Features.Users = model.NewPointer(nUsers) licenseJSON, jsonErr := json.Marshal(license) require.NoError(t, jsonErr) testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { diff --git a/server/channels/api4/outgoing_oauth_connection_test.go b/server/channels/api4/outgoing_oauth_connection_test.go index 88a1151d16..55826f19d6 100644 --- a/server/channels/api4/outgoing_oauth_connection_test.go +++ b/server/channels/api4/outgoing_oauth_connection_test.go @@ -215,7 +215,7 @@ func TestClientOutgoingOAuthConnectionGet(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(false) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(false) defer func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -255,7 +255,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -290,7 +290,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -326,7 +326,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -369,7 +369,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) { outgoingOauthIface.Mock.On("SanitizeConnections", mock.Anything) outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -414,7 +414,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -453,7 +453,7 @@ func TestClientGetOutgoingOAuthConnection(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -489,7 +489,7 @@ func TestClientGetOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -530,7 +530,7 @@ func TestClientCreateOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -563,7 +563,7 @@ func TestClientCreateOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -602,7 +602,7 @@ func TestClientUpdateOutgoingOAuthConnection(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -638,7 +638,7 @@ func TestClientUpdateOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -681,7 +681,7 @@ func TestClientDeleteOutgoingOAuthConnection(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -715,7 +715,7 @@ func TestClientDeleteOutgoingOAuthConnection(t *testing.T) { outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -753,7 +753,7 @@ func TestEnsureOutgoingOAuthConnectionInterface(t *testing.T) { defer th.TearDown() outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig }) @@ -776,7 +776,7 @@ func TestEnsureOutgoingOAuthConnectionInterface(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -799,7 +799,7 @@ func TestEnsureOutgoingOAuthConnectionInterface(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -850,7 +850,7 @@ func TestHandlerOutgoingOAuthConnectionListGet(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) th.App.Srv().OutgoingOAuthConnection = outgoingOauthIface defaultRolePermissions := th.SaveDefaultRolePermissions() @@ -973,7 +973,7 @@ func TestHandlerOutgoingOAuthConnectionListReadOnly(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) th.App.Srv().OutgoingOAuthConnection = outgoingOauthIface defaultRolePermissions := th.SaveDefaultRolePermissions() @@ -1109,7 +1109,7 @@ func TestHandlerOutgoingOAuthConnectionUpdate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1161,7 +1161,7 @@ func TestHandlerOutgoingOAuthConnectionUpdate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1227,7 +1227,7 @@ func TestHandlerOutgoingOAuthConnectionUpdate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1261,7 +1261,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerCreate(t *testing.T) { defer th.App.Srv().RemoveLicense() outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig }) @@ -1320,7 +1320,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerCreate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1374,7 +1374,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerCreate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1435,7 +1435,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1525,7 +1525,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1577,7 +1577,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig @@ -1632,7 +1632,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig diff --git a/server/channels/api4/post.go b/server/channels/api4/post.go index fa9ac6404f..718b84b1a8 100644 --- a/server/channels/api4/post.go +++ b/server/channels/api4/post.go @@ -1074,7 +1074,7 @@ func saveIsPinnedPost(c *Context, w http.ResponseWriter, isPinned bool) { } patch := &model.PostPatch{} - patch.IsPinned = model.NewBool(isPinned) + patch.IsPinned = model.NewPointer(isPinned) patchedPost, err := c.App.PatchPost(c.AppContext, c.Params.PostId, patch) if err != nil { diff --git a/server/channels/api4/post_test.go b/server/channels/api4/post_test.go index 9fe86aa9b2..f219b7bb8e 100644 --- a/server/channels/api4/post_test.go +++ b/server/channels/api4/post_test.go @@ -233,7 +233,7 @@ func TestCreatePost(t *testing.T) { t.Run("Should not be able to define the RemoteId of a post from the API", func(t *testing.T) { newPost := &model.Post{ - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), ChannelId: th.BasicChannel.Id, Message: "post content " + model.NewId(), DeleteAt: 0, @@ -273,7 +273,7 @@ func TestCreatePostForPriority(t *testing.T) { post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("urgent"), + Priority: model.NewPointer("urgent"), }, }} @@ -291,7 +291,7 @@ func TestCreatePostForPriority(t *testing.T) { replyPost := &model.Post{RootId: post.Id, ChannelId: th.BasicChannel.Id, Message: "reply", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("urgent"), + Priority: model.NewPointer("urgent"), }, }} _, resp, err = client.CreatePost(context.Background(), replyPost) @@ -305,8 +305,8 @@ func TestCreatePostForPriority(t *testing.T) { // for Acknowledment p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("urgent"), - RequestedAck: model.NewBool(true), + Priority: model.NewPointer("urgent"), + RequestedAck: model.NewPointer(true), }, }} _, resp, err := client.CreatePost(context.Background(), p1) @@ -316,8 +316,8 @@ func TestCreatePostForPriority(t *testing.T) { // for Persistent Notification p2 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("urgent"), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("urgent"), + PersistentNotifications: model.NewPointer(true), }, }} _, resp, err = client.CreatePost(context.Background(), p2) @@ -337,8 +337,8 @@ func TestCreatePostForPriority(t *testing.T) { p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("urgent"), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("urgent"), + PersistentNotifications: model.NewPointer(true), }, }} _, resp, err := client.CreatePost(context.Background(), p1) @@ -349,8 +349,8 @@ func TestCreatePostForPriority(t *testing.T) { t.Run("should return badRequest when post is not urgent for persistent notification", func(t *testing.T) { p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + PersistentNotifications: model.NewPointer(true), }, }} _, resp, err := client.CreatePost(context.Background(), p1) @@ -373,8 +373,8 @@ func TestCreatePostForPriority(t *testing.T) { p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("urgent"), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("urgent"), + PersistentNotifications: model.NewPointer(true), }, }} _, resp, err := client.CreatePost(context.Background(), p1) @@ -385,7 +385,7 @@ func TestCreatePostForPriority(t *testing.T) { t.Run("should create priority post", func(t *testing.T) { p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), + Priority: model.NewPointer("important"), }, }} _, resp, err := client.CreatePost(context.Background(), p1) @@ -396,8 +396,8 @@ func TestCreatePostForPriority(t *testing.T) { t.Run("should create acknowledge post", func(t *testing.T) { p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(""), - RequestedAck: model.NewBool(true), + Priority: model.NewPointer(""), + RequestedAck: model.NewPointer(true), }, }} _, resp, err := client.CreatePost(context.Background(), p1) @@ -408,9 +408,9 @@ func TestCreatePostForPriority(t *testing.T) { t.Run("should create persistent notification post", func(t *testing.T) { p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test @" + th.BasicUser2.Username, Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("urgent"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("urgent"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, }} _, resp, err := client.CreatePost(context.Background(), p1) @@ -615,7 +615,7 @@ func testCreatePostWithOutgoingHook( } outGoingHookResponse := &model.OutgoingWebhookResponse{ - Text: model.NewString("some test text"), + Text: model.NewPointer("some test text"), Username: "TestCommandServer", IconURL: "https://mattermost.com/wp-content/uploads/2022/02/icon.png", Type: "custom_as", @@ -1532,12 +1532,12 @@ func TestPatchPost(t *testing.T) { t.Run("new message, props, files, HasReactions bit", func(t *testing.T) { patch := &model.PostPatch{} - patch.IsPinned = model.NewBool(false) - patch.Message = model.NewString("#otherhashtag other message") + patch.IsPinned = model.NewPointer(false) + patch.Message = model.NewPointer("#otherhashtag other message") patch.Props = &model.StringInterface{"channel_header": "new_header"} patchFileIds := model.StringArray(fileIDs) // one extra file patch.FileIds = &patchFileIds - patch.HasReactions = model.NewBool(false) + patch.HasReactions = model.NewPointer(false) rpost, _, err = client.PatchPost(context.Background(), post.Id, patch) require.NoError(t, err) @@ -1655,7 +1655,7 @@ func TestPatchPost(t *testing.T) { require.NoError(t, err) patch2 := &model.PostPatch{ - Message: model.NewString("new message"), + Message: model.NewPointer("new message"), } _, resp, err := th.SystemAdminClient.PatchPost(context.Background(), post2.Id, patch2) require.Error(t, err) @@ -3757,7 +3757,7 @@ func TestGetEditHistoryForPost(t *testing.T) { // update the post message patch := &model.PostPatch{ - Message: model.NewString("new message edited"), + Message: model.NewPointer("new message edited"), } // Patch the post @@ -3767,7 +3767,7 @@ func TestGetEditHistoryForPost(t *testing.T) { // update the post message again patch = &model.PostPatch{ - Message: model.NewString("new message edited again"), + Message: model.NewPointer("new message edited again"), } _, response2, err2 := client.PatchPost(context.Background(), rpost.Id, patch) diff --git a/server/channels/api4/remote_cluster_test.go b/server/channels/api4/remote_cluster_test.go index 1bf89be6a2..0be46e5983 100644 --- a/server/channels/api4/remote_cluster_test.go +++ b/server/channels/api4/remote_cluster_test.go @@ -446,7 +446,7 @@ func TestPatchRemoteCluster(t *testing.T) { Token: model.NewId(), } - rcp := &model.RemoteClusterPatch{DisplayName: model.NewString("different value")} + rcp := &model.RemoteClusterPatch{DisplayName: model.NewPointer("different value")} t.Run("Should not work if the remote cluster service is not enabled", func(t *testing.T) { th := Setup(t) @@ -488,7 +488,7 @@ func TestPatchRemoteCluster(t *testing.T) { }) t.Run("should correctly patch the remote cluster", func(t *testing.T) { - rcp := &model.RemoteClusterPatch{DisplayName: model.NewString("patched!")} + rcp := &model.RemoteClusterPatch{DisplayName: model.NewPointer("patched!")} patchedRC, resp, err := th.SystemAdminClient.PatchRemoteCluster(context.Background(), rc.RemoteId, rcp) CheckOKStatus(t, resp) diff --git a/server/channels/api4/role_test.go b/server/channels/api4/role_test.go index 593dd0adc5..a62b784386 100644 --- a/server/channels/api4/role_test.go +++ b/server/channels/api4/role_test.go @@ -316,7 +316,7 @@ func TestPatchRole(t *testing.T) { t.Run("Check guest permissions editing without E20 license", func(t *testing.T) { license := model.NewTestLicense() - license.Features.GuestAccountsPermissions = model.NewBool(false) + license.Features.GuestAccountsPermissions = model.NewPointer(false) th.App.Srv().SetLicense(license) guestRole, err := th.App.Srv().Store().Role().GetByName(context.Background(), "system_guest") @@ -328,7 +328,7 @@ func TestPatchRole(t *testing.T) { t.Run("Check guest permissions editing with E20 license", func(t *testing.T) { license := model.NewTestLicense() - license.Features.GuestAccountsPermissions = model.NewBool(true) + license.Features.GuestAccountsPermissions = model.NewPointer(true) th.App.Srv().SetLicense(license) guestRole, err := th.App.Srv().Store().Role().GetByName(context.Background(), "system_guest") require.NoError(t, err) diff --git a/server/channels/api4/saml_test.go b/server/channels/api4/saml_test.go index a3a69804c8..fcdfe1ce99 100644 --- a/server/channels/api4/saml_test.go +++ b/server/channels/api4/saml_test.go @@ -61,7 +61,7 @@ func TestSamlResetId(t *testing.T) { user := th.BasicUser _, appErr := th.App.UpdateUserAuth(nil, user.Id, &model.UserAuth{ - AuthData: model.NewString(model.NewId()), + AuthData: model.NewPointer(model.NewId()), AuthService: model.UserAuthServiceSaml, }) require.Nil(t, appErr) diff --git a/server/channels/api4/scheme_test.go b/server/channels/api4/scheme_test.go index 13fc4ac7ef..d8350fa7d8 100644 --- a/server/channels/api4/scheme_test.go +++ b/server/channels/api4/scheme_test.go @@ -153,7 +153,7 @@ func TestCreateScheme(t *testing.T) { // Create scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature. lic := &model.License{ Features: &model.Features{ - CustomPermissionsSchemes: model.NewBool(false), + CustomPermissionsSchemes: model.NewPointer(false), }, Customer: &model.Customer{ Name: "TestName", @@ -607,7 +607,7 @@ func TestPatchScheme(t *testing.T) { // Patch scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature. lic := &model.License{ Features: &model.Features{ - CustomPermissionsSchemes: model.NewBool(false), + CustomPermissionsSchemes: model.NewPointer(false), }, Customer: &model.Customer{ Name: "TestName", @@ -821,7 +821,7 @@ func TestDeleteScheme(t *testing.T) { // Delete scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature. lic := &model.License{ Features: &model.Features{ - CustomPermissionsSchemes: model.NewBool(false), + CustomPermissionsSchemes: model.NewPointer(false), }, Customer: &model.Customer{ Name: "TestName", diff --git a/server/channels/api4/shared_channel_test.go b/server/channels/api4/shared_channel_test.go index 7ec223b078..17a40f8159 100644 --- a/server/channels/api4/shared_channel_test.go +++ b/server/channels/api4/shared_channel_test.go @@ -162,7 +162,7 @@ func TestCreateDirectChannelWithRemoteUser(t *testing.T) { localUser := th.BasicUser remoteUser := th.CreateUser() - remoteUser.RemoteId = model.NewString(model.NewId()) + remoteUser.RemoteId = model.NewPointer(model.NewId()) remoteUser, appErr := th.App.UpdateUser(th.Context, remoteUser, false) require.Nil(t, appErr) @@ -191,7 +191,7 @@ func TestCreateDirectChannelWithRemoteUser(t *testing.T) { rc, appErr := th.App.AddRemoteCluster(rc) require.Nil(t, appErr) - remoteUser.RemoteId = model.NewString(rc.RemoteId) + remoteUser.RemoteId = model.NewPointer(rc.RemoteId) remoteUser, appErr = th.App.UpdateUser(th.Context, remoteUser, false) require.Nil(t, appErr) @@ -220,7 +220,7 @@ func TestCreateDirectChannelWithRemoteUser(t *testing.T) { rc, appErr := th.App.AddRemoteCluster(rc) require.Nil(t, appErr) - remoteUser.RemoteId = model.NewString(rc.RemoteId) + remoteUser.RemoteId = model.NewPointer(rc.RemoteId) remoteUser, appErr = th.App.UpdateUser(th.Context, remoteUser, false) require.Nil(t, appErr) diff --git a/server/channels/api4/system_test.go b/server/channels/api4/system_test.go index 1e99ea51bf..a9eb8acdc1 100644 --- a/server/channels/api4/system_test.go +++ b/server/channels/api4/system_test.go @@ -137,27 +137,27 @@ func TestEmailTest(t *testing.T) { es := model.EmailSettings{} es.SetDefaults(false) - es.SMTPServer = model.NewString("") - es.SMTPPort = model.NewString("") - es.SMTPPassword = model.NewString("") - es.FeedbackName = model.NewString("") - es.FeedbackEmail = model.NewString("some-addr@test.com") - es.ReplyToAddress = model.NewString("some-addr@test.com") - es.ConnectionSecurity = model.NewString("") - es.SMTPUsername = model.NewString("") - es.EnableSMTPAuth = model.NewBool(false) - es.SkipServerCertificateVerification = model.NewBool(true) - es.SendEmailNotifications = model.NewBool(false) - es.SMTPServerTimeout = model.NewInt(15) + es.SMTPServer = model.NewPointer("") + es.SMTPPort = model.NewPointer("") + es.SMTPPassword = model.NewPointer("") + es.FeedbackName = model.NewPointer("") + es.FeedbackEmail = model.NewPointer("some-addr@test.com") + es.ReplyToAddress = model.NewPointer("some-addr@test.com") + es.ConnectionSecurity = model.NewPointer("") + es.SMTPUsername = model.NewPointer("") + es.EnableSMTPAuth = model.NewPointer(false) + es.SkipServerCertificateVerification = model.NewPointer(true) + es.SendEmailNotifications = model.NewPointer(false) + es.SMTPServerTimeout = model.NewPointer(15) config := model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString(""), + SiteURL: model.NewPointer(""), }, EmailSettings: es, FileSettings: model.FileSettings{ - DriverName: model.NewString(model.ImageDriverLocal), - Directory: model.NewString(dir), + DriverName: model.NewPointer(model.ImageDriverLocal), + Directory: model.NewPointer(dir), }, } @@ -573,14 +573,14 @@ func TestS3TestConnection(t *testing.T) { fs := model.FileSettings{} fs.SetDefaults(false) - fs.DriverName = model.NewString(model.ImageDriverS3) - fs.AmazonS3AccessKeyId = model.NewString(model.MinioAccessKey) - fs.AmazonS3SecretAccessKey = model.NewString(model.MinioSecretKey) - fs.AmazonS3Bucket = model.NewString("") - fs.AmazonS3Endpoint = model.NewString(s3Endpoint) - fs.AmazonS3Region = model.NewString("") - fs.AmazonS3PathPrefix = model.NewString("") - fs.AmazonS3SSL = model.NewBool(false) + fs.DriverName = model.NewPointer(model.ImageDriverS3) + fs.AmazonS3AccessKeyId = model.NewPointer(model.MinioAccessKey) + fs.AmazonS3SecretAccessKey = model.NewPointer(model.MinioSecretKey) + fs.AmazonS3Bucket = model.NewPointer("") + fs.AmazonS3Endpoint = model.NewPointer(s3Endpoint) + fs.AmazonS3Region = model.NewPointer("") + fs.AmazonS3PathPrefix = model.NewPointer("") + fs.AmazonS3SSL = model.NewPointer(false) config := model.Config{ FileSettings: fs, @@ -599,18 +599,18 @@ func TestS3TestConnection(t *testing.T) { // If this fails, check the test configuration to ensure minio is setup with the // `mattermost-test` bucket defined by model.MINIO_BUCKET. *config.FileSettings.AmazonS3Bucket = model.MinioBucket - config.FileSettings.AmazonS3PathPrefix = model.NewString("") + config.FileSettings.AmazonS3PathPrefix = model.NewPointer("") *config.FileSettings.AmazonS3Region = "us-east-1" resp, err = th.SystemAdminClient.TestS3Connection(context.Background(), &config) require.NoError(t, err) CheckOKStatus(t, resp) - config.FileSettings.AmazonS3Region = model.NewString("") + config.FileSettings.AmazonS3Region = model.NewPointer("") resp, err = th.SystemAdminClient.TestS3Connection(context.Background(), &config) require.NoError(t, err) CheckOKStatus(t, resp) - config.FileSettings.AmazonS3Bucket = model.NewString("Wrong_bucket") + config.FileSettings.AmazonS3Bucket = model.NewPointer("Wrong_bucket") resp, err = th.SystemAdminClient.TestS3Connection(context.Background(), &config) CheckInternalErrorStatus(t, resp) CheckErrorID(t, err, "api.file.test_connection_s3_bucket_does_not_exist.app_error") @@ -1054,7 +1054,7 @@ func TestCheckHasNilFields(t *testing.T) { t.Run("check if the struct has any nil fields", func(t *testing.T) { s := model.FileSettings{ - DriverName: model.NewString(model.ImageDriverLocal), + DriverName: model.NewPointer(model.ImageDriverLocal), } res := checkHasNilFields(&s) require.True(t, res) diff --git a/server/channels/api4/team.go b/server/channels/api4/team.go index e8055a02dd..7e7d57dcd7 100644 --- a/server/channels/api4/team.go +++ b/server/channels/api4/team.go @@ -1124,10 +1124,10 @@ func getAllTeams(c *Context, w http.ResponseWriter, r *http.Request) { c.SetPermissionError(model.PermissionSysconsoleReadComplianceDataRetentionPolicy) return } - opts.ExcludePolicyConstrained = model.NewBool(true) + opts.ExcludePolicyConstrained = model.NewPointer(true) } if c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionSysconsoleReadComplianceDataRetentionPolicy) { - opts.IncludePolicyID = model.NewBool(true) + opts.IncludePolicyID = model.NewPointer(true) } listPrivate := c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionListPrivateTeams) @@ -1136,9 +1136,9 @@ func getAllTeams(c *Context, w http.ResponseWriter, r *http.Request) { offset := limit * c.Params.Page if listPrivate && listPublic { } else if listPrivate { - opts.AllowOpenInvite = model.NewBool(false) + opts.AllowOpenInvite = model.NewPointer(false) } else if listPublic { - opts.AllowOpenInvite = model.NewBool(true) + opts.AllowOpenInvite = model.NewPointer(true) } else { // The user doesn't have permissions to list private as well as public teams. c.Err = model.NewAppError("getAllTeams", "api.team.get_all_teams.insufficient_permissions", nil, "", http.StatusForbidden) @@ -1188,7 +1188,7 @@ func searchTeams(c *Context, w http.ResponseWriter, r *http.Request) { // policy ID may only be used through the /data_retention/policies endpoint props.PolicyID = nil if c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionSysconsoleReadComplianceDataRetentionPolicy) { - props.IncludePolicyID = model.NewBool(true) + props.IncludePolicyID = model.NewPointer(true) } var ( diff --git a/server/channels/api4/team_test.go b/server/channels/api4/team_test.go index 48436b8ec7..07c3c92770 100644 --- a/server/channels/api4/team_test.go +++ b/server/channels/api4/team_test.go @@ -62,7 +62,7 @@ func TestCreateTeam(t *testing.T) { require.Equalf(t, r.StatusCode, http.StatusBadRequest, "wrong status code, actual: %s, expected: %s", strconv.Itoa(r.StatusCode), strconv.Itoa(http.StatusBadRequest)) // Test GroupConstrained flag - groupConstrainedTeam := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen, GroupConstrained: model.NewBool(true)} + groupConstrainedTeam := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen, GroupConstrained: model.NewPointer(true)} rteam, resp, err = client.CreateTeam(context.Background(), groupConstrainedTeam) require.NoError(t, err) CheckCreatedStatus(t, resp) @@ -163,7 +163,7 @@ func TestCreateTeam(t *testing.T) { cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{ Teams: &model.TeamsLimits{ - Active: model.NewInt(1), + Active: model.NewPointer(1), }, }, nil).Once() team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen} @@ -184,7 +184,7 @@ func TestCreateTeam(t *testing.T) { cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{ Teams: &model.TeamsLimits{ - Active: model.NewInt(200), + Active: model.NewPointer(200), }, }, nil).Once() team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen} @@ -412,7 +412,7 @@ func TestUpdateTeam(t *testing.T) { require.Equal(t, uteam.DisplayName, "Updated Name", "Update failed") // Test GroupConstrained flag - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) rteam, resp, err := client.UpdateTeam(context.Background(), team) require.NoError(t, err) CheckOKStatus(t, resp) @@ -531,10 +531,10 @@ func TestPatchTeam(t *testing.T) { team, _, _ = th.Client.CreateTeam(context.Background(), team) patch := &model.TeamPatch{} - patch.DisplayName = model.NewString("Other name") - patch.Description = model.NewString("Other description") - patch.CompanyName = model.NewString("Other company name") - patch.AllowOpenInvite = model.NewBool(true) + patch.DisplayName = model.NewPointer("Other name") + patch.Description = model.NewPointer("Other description") + patch.CompanyName = model.NewPointer("Other company name") + patch.AllowOpenInvite = model.NewPointer(true) _, resp, err := th.Client.PatchTeam(context.Background(), GenerateTestID(), patch) require.Error(t, err) @@ -566,7 +566,7 @@ func TestPatchTeam(t *testing.T) { team2, _, _ = client.CreateTeam(context.Background(), team2) patch2 := &model.TeamPatch{ - AllowOpenInvite: model.NewBool(false), + AllowOpenInvite: model.NewPointer(false), } rteam2, _, err3 := client.PatchTeam(context.Background(), team2.Id, patch2) @@ -581,7 +581,7 @@ func TestPatchTeam(t *testing.T) { team2, _, _ = client.CreateTeam(context.Background(), team2) patch2 := &model.TeamPatch{ - AllowOpenInvite: model.NewBool(true), + AllowOpenInvite: model.NewPointer(true), } rteam2, _, err3 := client.PatchTeam(context.Background(), team2.Id, patch2) @@ -592,7 +592,7 @@ func TestPatchTeam(t *testing.T) { }) // Test GroupConstrained flag - patch.GroupConstrained = model.NewBool(true) + patch.GroupConstrained = model.NewPointer(true) rteam, resp, err2 := client.PatchTeam(context.Background(), team.Id, patch) require.NoError(t, err2) CheckOKStatus(t, resp) @@ -709,7 +709,7 @@ func TestRestoreTeam(t *testing.T) { cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{ Teams: &model.TeamsLimits{ - Active: model.NewInt(1), + Active: model.NewPointer(1), }, }, nil).Once() @@ -730,7 +730,7 @@ func TestRestoreTeam(t *testing.T) { cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{ Teams: &model.TeamsLimits{ - Active: model.NewInt(200), + Active: model.NewPointer(200), }, }, nil).Twice() team := createTeam(t, true, model.TeamOpen) @@ -917,9 +917,9 @@ func TestTeamUnicodeNames(t *testing.T) { patch := &model.TeamPatch{} - patch.DisplayName = model.NewString("Goat\u206e Team") - patch.Description = model.NewString("\ufffaGreat team.") - patch.CompanyName = model.NewString("\u202bAcme Inc\u202c") + patch.DisplayName = model.NewPointer("Goat\u206e Team") + patch.Description = model.NewPointer("\ufffaGreat team.") + patch.CompanyName = model.NewPointer("\u202bAcme Inc\u202c") rteam, _, err := client.PatchTeam(context.Background(), team.Id, patch) require.NoError(t, err) @@ -1243,7 +1243,7 @@ func TestGetAllTeams(t *testing.T) { policy, savePolicyErr := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, TeamIDs: []string{policyTeam.Id}, }) @@ -1568,7 +1568,7 @@ func TestSearchAllTeams(t *testing.T) { policy, savePolicyErr := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, TeamIDs: []string{policyTeam.Id}, }) @@ -1637,37 +1637,37 @@ func TestSearchAllTeamsPaged(t *testing.T) { }{ { Name: "Retrieve foobar team using partial term search", - Search: &model.TeamSearch{Term: "oobardisplay", Page: model.NewInt(0), PerPage: model.NewInt(100)}, + Search: &model.TeamSearch{Term: "oobardisplay", Page: model.NewPointer(0), PerPage: model.NewPointer(100)}, ExpectedTeams: []string{foobarTeam.Id}, ExpectedTotalCount: 1, }, { Name: "Retrieve foobar team using the beginning of the display name as search text", - Search: &model.TeamSearch{Term: "foobar", Page: model.NewInt(0), PerPage: model.NewInt(100)}, + Search: &model.TeamSearch{Term: "foobar", Page: model.NewPointer(0), PerPage: model.NewPointer(100)}, ExpectedTeams: []string{foobarTeam.Id}, ExpectedTotalCount: 1, }, { Name: "Retrieve foobar team using the ending of the term of the display name", - Search: &model.TeamSearch{Term: "bardisplayname", Page: model.NewInt(0), PerPage: model.NewInt(100)}, + Search: &model.TeamSearch{Term: "bardisplayname", Page: model.NewPointer(0), PerPage: model.NewPointer(100)}, ExpectedTeams: []string{foobarTeam.Id}, ExpectedTotalCount: 1, }, { Name: "Retrieve foobar team using partial term search on the name property of team", - Search: &model.TeamSearch{Term: "what", Page: model.NewInt(0), PerPage: model.NewInt(100)}, + Search: &model.TeamSearch{Term: "what", Page: model.NewPointer(0), PerPage: model.NewPointer(100)}, ExpectedTeams: []string{foobarTeam.Id}, ExpectedTotalCount: 1, }, { Name: "Retrieve foobar team using partial term search on the name property of team #2", - Search: &model.TeamSearch{Term: "ever", Page: model.NewInt(0), PerPage: model.NewInt(100)}, + Search: &model.TeamSearch{Term: "ever", Page: model.NewPointer(0), PerPage: model.NewPointer(100)}, ExpectedTeams: []string{foobarTeam.Id}, ExpectedTotalCount: 1, }, { Name: "Get all teams on one page", - Search: &model.TeamSearch{Term: commonRandom, Page: model.NewInt(0), PerPage: model.NewInt(100)}, + Search: &model.TeamSearch{Term: commonRandom, Page: model.NewPointer(0), PerPage: model.NewPointer(100)}, ExpectedTeams: []string{teams[0].Id, teams[1].Id, teams[2].Id}, ExpectedTotalCount: 3, }, @@ -1691,13 +1691,13 @@ func TestSearchAllTeamsPaged(t *testing.T) { }, { Name: "Get 2 teams on the first page", - Search: &model.TeamSearch{Term: commonRandom, Page: model.NewInt(0), PerPage: model.NewInt(2)}, + Search: &model.TeamSearch{Term: commonRandom, Page: model.NewPointer(0), PerPage: model.NewPointer(2)}, ExpectedTeams: []string{teams[0].Id, teams[1].Id}, ExpectedTotalCount: 3, }, { Name: "Get 1 team on the second page", - Search: &model.TeamSearch{Term: commonRandom, Page: model.NewInt(1), PerPage: model.NewInt(2)}, + Search: &model.TeamSearch{Term: commonRandom, Page: model.NewPointer(1), PerPage: model.NewPointer(2)}, ExpectedTeams: []string{teams[2].Id}, ExpectedTotalCount: 3, }, @@ -1727,7 +1727,7 @@ func TestSearchAllTeamsPaged(t *testing.T) { }) } - _, _, resp, err := th.Client.SearchTeamsPaged(context.Background(), &model.TeamSearch{Term: commonRandom, PerPage: model.NewInt(100)}) + _, _, resp, err := th.Client.SearchTeamsPaged(context.Background(), &model.TeamSearch{Term: commonRandom, PerPage: model.NewPointer(100)}) CheckErrorID(t, err, "api.team.search_teams.pagination_not_implemented.public_team_search") require.Equal(t, http.StatusNotImplemented, resp.StatusCode) } @@ -2329,7 +2329,7 @@ func TestAddTeamMember(t *testing.T) { require.Nil(t, tm, "should have not returned team member") // Set a team to group-constrained - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) _, appErr = th.App.UpdateTeam(team) require.Nil(t, appErr) @@ -2648,7 +2648,7 @@ func TestAddTeamMembers(t *testing.T) { CheckForbiddenStatus(t, resp) // Set a team to group-constrained - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) _, appErr = th.App.UpdateTeam(team) require.Nil(t, appErr) @@ -2721,7 +2721,7 @@ func TestRemoveTeamMember(t *testing.T) { require.NoError(t, err) // If the team is group-constrained the user cannot be removed - th.BasicTeam.GroupConstrained = model.NewBool(true) + th.BasicTeam.GroupConstrained = model.NewPointer(true) _, appErr := th.App.UpdateTeam(th.BasicTeam) require.Nil(t, appErr) th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { @@ -3860,7 +3860,7 @@ func TestTeamMembersMinusGroupMembers(t *testing.T) { user2 := th.BasicUser2 team := th.CreateTeam() - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) team, appErr := th.App.UpdateTeam(team) require.Nil(t, appErr) diff --git a/server/channels/api4/user.go b/server/channels/api4/user.go index fb43430f4f..2638b5e1df 100644 --- a/server/channels/api4/user.go +++ b/server/channels/api4/user.go @@ -62,7 +62,7 @@ func (api *API) InitUser() { api.BaseRoutes.User.Handle("/mfa/generate", api.APISessionRequiredMfa(generateMfaSecret)).Methods(http.MethodPost) api.BaseRoutes.Users.Handle("/login", api.APIHandler(login)).Methods(http.MethodPost) - api.BaseRoutes.Users.Handle("/login/desktop_token", api.RateLimitedHandler(api.APIHandler(loginWithDesktopToken), model.RateLimitSettings{PerSec: model.NewInt(2), MaxBurst: model.NewInt(1)})).Methods(http.MethodPost) + api.BaseRoutes.Users.Handle("/login/desktop_token", api.RateLimitedHandler(api.APIHandler(loginWithDesktopToken), model.RateLimitSettings{PerSec: model.NewPointer(2), MaxBurst: model.NewPointer(1)})).Methods(http.MethodPost) api.BaseRoutes.Users.Handle("/login/switch", api.APIHandler(switchAccountType)).Methods(http.MethodPost) api.BaseRoutes.Users.Handle("/login/cws", api.APIHandlerTrustRequester(loginCWS)).Methods(http.MethodPost) api.BaseRoutes.Users.Handle("/logout", api.APIHandler(logout)).Methods(http.MethodPost) diff --git a/server/channels/api4/user_test.go b/server/channels/api4/user_test.go index 8c361e44db..ae53666190 100644 --- a/server/channels/api4/user_test.go +++ b/server/channels/api4/user_test.go @@ -138,7 +138,7 @@ func TestCreateUser(t *testing.T) { email := th.GenerateTestEmail() newUser := &model.User{ Id: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Email: email, Password: "Password1", Username: GenerateTestUsername(), @@ -281,7 +281,7 @@ func TestCreateUserInputFilter(t *testing.T) { Email: "foobar+testdomainrestriction@mattermost.org", Username: GenerateTestUsername(), AuthService: "ldap", - AuthData: model.NewString("999099"), + AuthData: model.NewPointer("999099"), } u, _, err := th.SystemAdminClient.CreateUser(context.Background(), user) require.NoError(t, err) @@ -293,7 +293,7 @@ func TestCreateUserInputFilter(t *testing.T) { Email: "foobar+testdomainrestrictionlocalclient@mattermost.org", Username: GenerateTestUsername(), AuthService: "ldap", - AuthData: model.NewString("999100"), + AuthData: model.NewPointer("999100"), } u, _, err := th.LocalClient.CreateUser(context.Background(), user) require.NoError(t, err) @@ -698,12 +698,12 @@ func TestCreateUserWithInviteId(t *testing.T) { t.Run("GroupConstrainedTeam", func(t *testing.T) { user := model.User{Email: th.GenerateTestEmail(), Nickname: "", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId} - th.BasicTeam.GroupConstrained = model.NewBool(true) + th.BasicTeam.GroupConstrained = model.NewPointer(true) team, appErr := th.App.UpdateTeam(th.BasicTeam) require.Nil(t, appErr) defer func() { - th.BasicTeam.GroupConstrained = model.NewBool(false) + th.BasicTeam.GroupConstrained = model.NewPointer(false) _, appErr = th.App.UpdateTeam(th.BasicTeam) require.Nil(t, appErr) }() @@ -717,12 +717,12 @@ func TestCreateUserWithInviteId(t *testing.T) { th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { user := model.User{Email: th.GenerateTestEmail(), Nickname: "", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId} - th.BasicTeam.GroupConstrained = model.NewBool(true) + th.BasicTeam.GroupConstrained = model.NewPointer(true) team, appErr := th.App.UpdateTeam(th.BasicTeam) require.Nil(t, appErr) defer func() { - th.BasicTeam.GroupConstrained = model.NewBool(false) + th.BasicTeam.GroupConstrained = model.NewPointer(false) _, appErr = th.App.UpdateTeam(th.BasicTeam) require.Nil(t, appErr) }() @@ -1381,10 +1381,10 @@ func TestSearchUsers(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -1421,10 +1421,10 @@ func TestSearchUsers(t *testing.T) { id = model.NewId() group, appErr = th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceCustom, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -2061,10 +2061,10 @@ func TestPatchUser(t *testing.T) { }) patch := &model.UserPatch{} - patch.Password = model.NewString("testpassword") - patch.Nickname = model.NewString("Joram Wilander") - patch.FirstName = model.NewString("Joram") - patch.LastName = model.NewString("Wilander") + patch.Password = model.NewPointer("testpassword") + patch.Nickname = model.NewPointer("Joram Wilander") + patch.FirstName = model.NewPointer("Joram") + patch.LastName = model.NewPointer("Wilander") patch.Position = new(string) patch.NotifyProps = model.StringMap{} patch.NotifyProps["comment"] = "somethingrandom" @@ -2099,19 +2099,19 @@ func TestPatchUser(t *testing.T) { require.Nil(t, appErr, "Password should still match") patch = &model.UserPatch{} - patch.Email = model.NewString(th.GenerateTestEmail()) + patch.Email = model.NewPointer(th.GenerateTestEmail()) _, resp, err := th.Client.PatchUser(context.Background(), user.Id, patch) require.Error(t, err) CheckBadRequestStatus(t, resp) - patch.Password = model.NewString(currentPassword) + patch.Password = model.NewPointer(currentPassword) ruser, _, err = th.Client.PatchUser(context.Background(), user.Id, patch) require.NoError(t, err) require.Equal(t, *patch.Email, ruser.Email, "Email should update properly") - patch.Username = model.NewString(th.BasicUser2.Username) + patch.Username = model.NewPointer(th.BasicUser2.Username) _, resp, err = th.Client.PatchUser(context.Background(), user.Id, patch) require.Error(t, err) CheckBadRequestStatus(t, resp) @@ -2135,7 +2135,7 @@ func TestPatchUser(t *testing.T) { session.IsOAuth = true th.App.AddSessionToCache(session) - patch.Email = model.NewString(th.GenerateTestEmail()) + patch.Email = model.NewPointer(th.GenerateTestEmail()) _, resp, err = th.Client.PatchUser(context.Background(), user.Id, patch) require.Error(t, err) CheckForbiddenStatus(t, resp) @@ -2164,7 +2164,7 @@ func TestPatchBotUser(t *testing.T) { bot := th.CreateBotWithSystemAdminClient() patch := &model.UserPatch{} - patch.Email = model.NewString("newemail@test.com") + patch.Email = model.NewPointer("newemail@test.com") user, _, err := th.SystemAdminClient.PatchUser(context.Background(), bot.UserId, patch) require.NoError(t, err) @@ -2183,7 +2183,7 @@ func TestPatchAdminUser(t *testing.T) { th.App.UpdateUserRoles(th.Context, user.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false) patch := &model.UserPatch{} - patch.Email = model.NewString(th.GenerateTestEmail()) + patch.Email = model.NewPointer(th.GenerateTestEmail()) th.AddPermissionToRole(model.PermissionEditOtherUsers.Id, model.SystemUserManagerRoleId) th.App.UpdateUserRoles(th.Context, th.BasicUser.Id, model.SystemUserManagerRoleId+" "+model.SystemUserAccessTokenRoleId, false) @@ -2244,9 +2244,9 @@ func TestUserUnicodeNames(t *testing.T) { client.Login(context.Background(), user.Email, user.Password) patch := &model.UserPatch{} - patch.Nickname = model.NewString("\U000E0000Ender\u206d Wiggin\U000E007F") - patch.FirstName = model.NewString("\U0001d173Andrew\U0001d17a") - patch.LastName = model.NewString("\u2028Wiggin\u2029") + patch.Nickname = model.NewPointer("\U000E0000Ender\u206d Wiggin\U000E007F") + patch.FirstName = model.NewPointer("\U0001d173Andrew\U0001d17a") + patch.LastName = model.NewPointer("\u2028Wiggin\u2029") ruser, _, err := client.PatchUser(context.Background(), user.Id, patch) require.NoError(t, err) @@ -2279,7 +2279,7 @@ func TestUpdateUserAuth(t *testing.T) { _, respErr, _ := th.SystemAdminClient.UpdateUserAuth(context.Background(), user.Id, userAuth) require.NotNil(t, respErr, "Shouldn't have permissions. Only Admins") - userAuth.AuthData = model.NewString("test@test.com") + userAuth.AuthData = model.NewPointer("test@test.com") userAuth.AuthService = model.UserAuthServiceSaml ruser, _, err := th.SystemAdminClient.UpdateUserAuth(context.Background(), user.Id, userAuth) require.NoError(t, err) @@ -3068,20 +3068,20 @@ func TestGetUsersInGroup(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) cid := model.NewId() customGroup, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + cid, - Name: model.NewString("name" + cid), + Name: model.NewPointer("name" + cid), Source: model.GroupSourceCustom, Description: "description_" + cid, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -3145,10 +3145,10 @@ func TestGetUsersInGroupByDisplayName(t *testing.T) { id := model.NewId() group, appErr := th.App.CreateGroup(&model.Group{ DisplayName: "dn-foo_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) assert.Nil(t, appErr) @@ -3930,7 +3930,7 @@ func TestLogin(t *testing.T) { t.Run("remote user login rejected", func(t *testing.T) { email := th.GenerateTestEmail() - user := model.User{Email: email, Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId, RemoteId: model.NewString("remote-id")} + user := model.User{Email: email, Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId, RemoteId: model.NewPointer("remote-id")} ruser, appErr := th.App.CreateUser(th.Context, &user) require.Nil(t, appErr) @@ -4702,7 +4702,7 @@ func TestCreateUserAccessToken(t *testing.T) { // make a remote user remoteUser, appErr := th.App.CreateUser(request.TestContext(t), &model.User{ Username: "remoteuser", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Password: model.NewId(), Email: "remoteuser@example.com", }) @@ -6415,7 +6415,7 @@ func TestGetThreadsForUser(t *testing.T) { Message: "testMsg", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), + Priority: model.NewPointer(model.PostPriorityUrgent), }, }, }) @@ -6442,7 +6442,7 @@ func TestGetThreadsForUser(t *testing.T) { Message: "testReply", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), + Priority: model.NewPointer(model.PostPriorityUrgent), }, }, }) @@ -6462,7 +6462,7 @@ func TestGetThreadsForUser(t *testing.T) { Message: "testMsg", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), + Priority: model.NewPointer(model.PostPriorityUrgent), }, }, }) @@ -7235,7 +7235,7 @@ func TestSingleThreadGet(t *testing.T) { Message: "testMsg2", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), + Priority: model.NewPointer(model.PostPriorityUrgent), }, }, }) @@ -7588,7 +7588,7 @@ func TestPatchAndUpdateWithProviderAttributes(t *testing.T) { model.ServiceOpenid, } { user := th.CreateUserWithAuth(authService) - patch := &model.UserPatch{Username: model.NewString("something new")} + patch := &model.UserPatch{Username: model.NewPointer("something new")} conflictField := th.App.CheckProviderAttributes(th.Context, user, patch) require.NotEqual(t, "", conflictField) } diff --git a/server/channels/app/authorization_test.go b/server/channels/app/authorization_test.go index 7164dc4ca8..2df5280604 100644 --- a/server/channels/app/authorization_test.go +++ b/server/channels/app/authorization_test.go @@ -492,7 +492,7 @@ func TestSessionHasPermissionToGroup(t *testing.T) { require.Nil(t, err) group, err := th.App.CreateGroup(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceCustom, AllowReference: true, @@ -699,7 +699,7 @@ func TestSessionHasPermissionToChannelByPost(t *testing.T) { t.Run("read archived channel - setting off", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(false) + cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(false) }) require.Equal(t, false, th.App.SessionHasPermissionToChannelByPost(*session, archivedPost.Id, model.PermissionReadChannel)) require.Equal(t, false, th.App.SessionHasPermissionToChannelByPost(*session2, archivedPost.Id, model.PermissionReadChannel)) @@ -707,7 +707,7 @@ func TestSessionHasPermissionToChannelByPost(t *testing.T) { t.Run("read archived channel - setting on", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(true) + cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(true) }) require.Equal(t, true, th.App.SessionHasPermissionToChannelByPost(*session, archivedPost.Id, model.PermissionReadChannel)) require.Equal(t, false, th.App.SessionHasPermissionToChannelByPost(*session2, archivedPost.Id, model.PermissionReadChannel)) @@ -748,7 +748,7 @@ func TestHasPermissionToChannelByPost(t *testing.T) { t.Run("read archived channel - setting off", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(false) + cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(false) }) require.Equal(t, false, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser.Id, archivedPost.Id, model.PermissionReadChannel)) require.Equal(t, false, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser2.Id, archivedPost.Id, model.PermissionReadChannel)) @@ -756,7 +756,7 @@ func TestHasPermissionToChannelByPost(t *testing.T) { t.Run("read archived channel - setting on", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(true) + cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(true) }) require.Equal(t, true, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser.Id, archivedPost.Id, model.PermissionReadChannel)) require.Equal(t, false, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser2.Id, archivedPost.Id, model.PermissionReadChannel)) diff --git a/server/channels/app/channel_test.go b/server/channels/app/channel_test.go index 44cc457ee8..8511ab21ad 100644 --- a/server/channels/app/channel_test.go +++ b/server/channels/app/channel_test.go @@ -785,7 +785,7 @@ func TestAppUpdateChannelScheme(t *testing.T) { defer th.TearDown() channel := th.BasicChannel - mockID := model.NewString("x") + mockID := model.NewPointer("x") channel.SchemeId = mockID updatedChannel, err := th.App.UpdateChannelScheme(th.Context, channel) @@ -1632,7 +1632,7 @@ func TestAddUserToChannel(t *testing.T) { require.True(t, cm2.SchemeAdmin) privateChannel := th.CreatePrivateChannel(th.Context, th.BasicTeam) - privateChannel.GroupConstrained = model.NewBool(true) + privateChannel.GroupConstrained = model.NewPointer(true) _, err = th.App.UpdateChannel(th.Context, privateChannel) require.Nil(t, err) @@ -1685,7 +1685,7 @@ func TestRemoveUserFromChannel(t *testing.T) { }) require.Nil(t, err) - privateChannel.GroupConstrained = model.NewBool(true) + privateChannel.GroupConstrained = model.NewPointer(true) _, err = th.App.UpdateChannel(th.Context, privateChannel) require.Nil(t, err) @@ -1735,7 +1735,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createPosts, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1746,7 +1746,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createPosts, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)}, }, }, }, @@ -1755,7 +1755,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createReactions, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1766,7 +1766,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createReactions, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)}, }, }, }, @@ -1775,7 +1775,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &channelMentions, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1786,7 +1786,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &channelMentions, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)}, }, }, }, @@ -1795,7 +1795,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &manageMembers, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1806,7 +1806,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &manageMembers, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)}, }, }, }, @@ -1815,7 +1815,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &manageBookmarks, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1826,7 +1826,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &manageBookmarks, - Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)}, }, }, }, @@ -1835,7 +1835,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createPosts, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1846,7 +1846,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createPosts, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(true)}, }, }, }, @@ -1855,7 +1855,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createReactions, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1866,7 +1866,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &createReactions, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(true)}, }, }, }, @@ -1875,7 +1875,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &channelMentions, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{ @@ -1886,7 +1886,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { RevertChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &channelMentions, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(true)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(true)}, }, }, }, @@ -1895,7 +1895,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &manageMembers, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{}, @@ -1907,7 +1907,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { ChannelModerationsPatch: []*model.ChannelModerationPatch{ { Name: &manageBookmarks, - Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)}, + Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)}, }, }, PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{}, @@ -1920,8 +1920,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &nonChannelModeratedPermission, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(false), - Guests: model.NewBool(false), + Members: model.NewPointer(false), + Guests: model.NewPointer(false), }, }, }, @@ -1935,8 +1935,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(true), - Guests: model.NewBool(false), + Members: model.NewPointer(true), + Guests: model.NewPointer(false), }, }, }, @@ -1950,8 +1950,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(false), - Guests: model.NewBool(true), + Members: model.NewPointer(false), + Guests: model.NewPointer(true), }, }, }, @@ -1965,7 +1965,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(false), + Members: model.NewPointer(false), }, }, }, @@ -1990,34 +1990,34 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(true), - Guests: model.NewBool(true), + Members: model.NewPointer(true), + Guests: model.NewPointer(true), }, }, { Name: &createReactions, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(true), - Guests: model.NewBool(true), + Members: model.NewPointer(true), + Guests: model.NewPointer(true), }, }, { Name: &channelMentions, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(true), - Guests: model.NewBool(true), + Members: model.NewPointer(true), + Guests: model.NewPointer(true), }, }, { Name: &manageMembers, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(true), + Members: model.NewPointer(true), }, }, { Name: &manageBookmarks, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(true), + Members: model.NewPointer(true), }, }, }, @@ -2097,8 +2097,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(false), - Guests: model.NewBool(false), + Members: model.NewPointer(false), + Guests: model.NewPointer(false), }, }, } @@ -2106,8 +2106,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(false), - Guests: model.NewBool(false), + Members: model.NewPointer(false), + Guests: model.NewPointer(false), }, }, } @@ -2142,7 +2142,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(true), + Members: model.NewPointer(true), }, }, } @@ -2150,7 +2150,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) { { Name: &createPosts, Roles: &model.ChannelModeratedRolesPatch{ - Members: model.NewBool(false), + Members: model.NewPointer(false), }, }, } diff --git a/server/channels/app/config.go b/server/channels/app/config.go index 682d5ed45a..d079f15219 100644 --- a/server/channels/app/config.go +++ b/server/channels/app/config.go @@ -237,11 +237,11 @@ func (a *App) HandleMessageExportConfig(cfg *model.Config, appCfg *model.Config) if *cfg.MessageExportSettings.EnableExport != *appCfg.MessageExportSettings.EnableExport { if *cfg.MessageExportSettings.EnableExport && *cfg.MessageExportSettings.ExportFromTimestamp == int64(0) { // When the feature is toggled on, use the current timestamp as the start time for future exports. - cfg.MessageExportSettings.ExportFromTimestamp = model.NewInt64(model.GetMillis()) + cfg.MessageExportSettings.ExportFromTimestamp = model.NewPointer(model.GetMillis()) } else if !*cfg.MessageExportSettings.EnableExport { // When the feature is disabled, reset the timestamp so that the timestamp will be set if // the feature is re-enabled from the System Console in future. - cfg.MessageExportSettings.ExportFromTimestamp = model.NewInt64(0) + cfg.MessageExportSettings.ExportFromTimestamp = model.NewPointer(int64(0)) } } } diff --git a/server/channels/app/config_test.go b/server/channels/app/config_test.go index b075d047c1..38c9567a0b 100644 --- a/server/channels/app/config_test.go +++ b/server/channels/app/config_test.go @@ -70,25 +70,25 @@ func TestEnsureInstallationDate(t *testing.T) { Name: "New installation: no users, no installation date", PrevInstallationDate: nil, UsersCreationDates: nil, - ExpectedInstallationDate: model.NewInt64(utils.MillisFromTime(time.Now())), + ExpectedInstallationDate: model.NewPointer(utils.MillisFromTime(time.Now())), }, { Name: "Old installation: users, no installation date", PrevInstallationDate: nil, UsersCreationDates: []int64{10000000000, 30000000000, 20000000000}, - ExpectedInstallationDate: model.NewInt64(10000000000), + ExpectedInstallationDate: model.NewPointer(int64(10000000000)), }, { Name: "New installation, second run: no users, installation date", - PrevInstallationDate: model.NewInt64(80000000000), + PrevInstallationDate: model.NewPointer(int64(80000000000)), UsersCreationDates: []int64{10000000000, 30000000000, 20000000000}, - ExpectedInstallationDate: model.NewInt64(80000000000), + ExpectedInstallationDate: model.NewPointer(int64(80000000000)), }, { Name: "Old installation already updated: users, installation date", - PrevInstallationDate: model.NewInt64(90000000000), + PrevInstallationDate: model.NewPointer(int64(90000000000)), UsersCreationDates: []int64{10000000000, 30000000000, 20000000000}, - ExpectedInstallationDate: model.NewInt64(90000000000), + ExpectedInstallationDate: model.NewPointer(int64(90000000000)), }, } diff --git a/server/channels/app/download_test.go b/server/channels/app/download_test.go index c2e23de334..fb746611ff 100644 --- a/server/channels/app/download_test.go +++ b/server/channels/app/download_test.go @@ -19,7 +19,7 @@ func TestDownloadFromURL(t *testing.T) { defer th.TearDown() app := th.App - app.Config().PluginSettings.AllowInsecureDownloadURL = model.NewBool(true) + app.Config().PluginSettings.AllowInsecureDownloadURL = model.NewPointer(true) // To keep track of how many times an endpoint is retried. This needs to be reset // for each test run. diff --git a/server/channels/app/email/email_test.go b/server/channels/app/email/email_test.go index 4ee3f8e222..b896acb6b8 100644 --- a/server/channels/app/email/email_test.go +++ b/server/channels/app/email/email_test.go @@ -293,7 +293,7 @@ func TestMailServiceConfig(t *testing.T) { config: func() *model.Config { return &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString(""), + SiteURL: model.NewPointer(""), }, EmailSettings: model.EmailSettings{ EnableSignUpWithEmail: new(bool), @@ -304,7 +304,7 @@ func TestMailServiceConfig(t *testing.T) { RequireEmailVerification: new(bool), FeedbackName: new(string), FeedbackEmail: new(string), - ReplyToAddress: model.NewString(configuredReplyTo), + ReplyToAddress: model.NewPointer(configuredReplyTo), FeedbackOrganization: new(string), EnableSMTPAuth: new(bool), SMTPUsername: new(string), diff --git a/server/channels/app/file_test.go b/server/channels/app/file_test.go index 1251bd4327..959f99995c 100644 --- a/server/channels/app/file_test.go +++ b/server/channels/app/file_test.go @@ -654,7 +654,7 @@ func TestComputeLastAccessibleFileTime(t *testing.T) { cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{ Files: &model.FilesLimits{ - TotalStorage: model.NewInt64(1), + TotalStorage: model.NewPointer(int64(1)), }, }, nil) diff --git a/server/channels/app/group.go b/server/channels/app/group.go index 4189f0bbc1..35d70c4ccd 100644 --- a/server/channels/app/group.go +++ b/server/channels/app/group.go @@ -40,7 +40,7 @@ func (a *App) GetGroup(id string, opts *model.GetGroupOpts, viewRestrictions *mo if err != nil { return nil, model.NewAppError("GetGroup", "app.member_count", nil, "", http.StatusInternalServerError).Wrap(err) } - group.MemberCount = model.NewInt(int(memberCount)) + group.MemberCount = model.NewPointer(int(memberCount)) } return group, nil @@ -160,7 +160,7 @@ func (a *App) CreateGroupWithUserIds(group *model.GroupWithUserIds) (*model.Grou if err != nil { return nil, model.NewAppError("CreateGroupWithUserIds", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err) } - group.MemberCount = model.NewInt(int(count)) + group.MemberCount = model.NewPointer(int(count)) groupJSON, jsonErr := json.Marshal(newGroup) if jsonErr != nil { return nil, model.NewAppError("CreateGroupWithUserIds", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(jsonErr) @@ -199,7 +199,7 @@ func (a *App) UpdateGroup(group *model.Group) (*model.Group, *model.AppError) { return nil, model.NewAppError("UpdateGroup", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err) } - updatedGroup.MemberCount = model.NewInt(int(count)) + updatedGroup.MemberCount = model.NewPointer(int(count)) messageWs := model.NewWebSocketEvent(model.WebsocketEventReceivedGroup, "", "", "", nil, "") groupJSON, err := json.Marshal(updatedGroup) @@ -229,7 +229,7 @@ func (a *App) DeleteGroup(groupID string) (*model.Group, *model.AppError) { return nil, model.NewAppError("DeleteGroup", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err) } - deletedGroup.MemberCount = model.NewInt(int(count)) + deletedGroup.MemberCount = model.NewPointer(int(count)) messageWs := model.NewWebSocketEvent(model.WebsocketEventReceivedGroup, "", "", "", nil, "") @@ -260,7 +260,7 @@ func (a *App) RestoreGroup(groupID string) (*model.Group, *model.AppError) { return nil, model.NewAppError("RestoreGroup", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err) } - restoredGroup.MemberCount = model.NewInt(int(count)) + restoredGroup.MemberCount = model.NewPointer(int(count)) messageWs := model.NewWebSocketEvent(model.WebsocketEventReceivedGroup, "", "", "", nil, "") diff --git a/server/channels/app/group_test.go b/server/channels/app/group_test.go index 849f88c637..3f04b29951 100644 --- a/server/channels/app/group_test.go +++ b/server/channels/app/group_test.go @@ -71,9 +71,9 @@ func TestCreateGroup(t *testing.T) { id := model.NewId() group := &model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } g, err := th.App.CreateGroup(group) @@ -90,7 +90,7 @@ func TestCreateGroup(t *testing.T) { DisplayName: "dn_" + model.NewId(), Name: &user.Username, Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } g, err = th.App.CreateGroup(usernameGroup) require.NotNil(t, err) @@ -213,7 +213,7 @@ func TestUpsertGroupSyncableTeamGroupConstrained(t *testing.T) { group2 := th.CreateGroup() team := th.CreateTeam() - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) team, err := th.App.UpdateTeam(team) require.Nil(t, err) _, err = th.App.UpsertGroupSyncable(model.NewGroupTeam(group1.Id, team.Id, false)) @@ -311,7 +311,7 @@ func TestGetGroupsByChannel(t *testing.T) { groups, _, err := th.App.GetGroupsByChannel(th.BasicChannel.Id, opts) require.Nil(t, err) - require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups) + require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) groups, _, err = th.App.GetGroupsByChannel(model.NewId(), opts) @@ -348,7 +348,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) { assert.Equal(t, map[string][]*model.GroupWithSchemeAdmin{ th.BasicChannel.Id: { - {Group: *group, SchemeAdmin: model.NewBool(false)}, + {Group: *group, SchemeAdmin: model.NewPointer(false)}, }, }, groups) require.NotNil(t, groups[th.BasicChannel.Id][0].SchemeAdmin) @@ -377,7 +377,7 @@ func TestGetGroupsByTeam(t *testing.T) { groups, _, err := th.App.GetGroupsByTeam(th.BasicTeam.Id, model.GroupSearchOpts{}) require.Nil(t, err) - require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups) + require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups) require.NotNil(t, groups[0].SchemeAdmin) groups, _, err = th.App.GetGroupsByTeam(model.NewId(), model.GroupSearchOpts{}) diff --git a/server/channels/app/helper_test.go b/server/channels/app/helper_test.go index 6d5dd00b98..5ceecc74be 100644 --- a/server/channels/app/helper_test.go +++ b/server/channels/app/helper_test.go @@ -370,13 +370,13 @@ type ChannelOption func(*model.Channel) func WithShared(v bool) ChannelOption { return func(channel *model.Channel) { - channel.Shared = model.NewBool(v) + channel.Shared = model.NewPointer(v) } } func WithCreateAt(v int64) ChannelOption { return func(channel *model.Channel) { - channel.CreateAt = *model.NewInt64(v) + channel.CreateAt = *model.NewPointer(v) } } @@ -539,10 +539,10 @@ func (th *TestHelper) CreateGroup() *model.Group { id := model.NewId() group := &model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } var err *model.AppError diff --git a/server/channels/app/import_functions.go b/server/channels/app/import_functions.go index 0ec689b0d3..8089f50ceb 100644 --- a/server/channels/app/import_functions.go +++ b/server/channels/app/import_functions.go @@ -85,8 +85,8 @@ func (a *App) importScheme(rctx request.CTX, data *imports.SchemeImportData, dry if data.DefaultTeamGuestRole == nil { data.DefaultTeamGuestRole = &imports.RoleImportData{ - DisplayName: model.NewString("Team Guest Role for Scheme"), - SchemeManaged: model.NewBool(true), + DisplayName: model.NewPointer("Team Guest Role for Scheme"), + SchemeManaged: model.NewPointer(true), } } data.DefaultTeamGuestRole.Name = &scheme.DefaultTeamGuestRole @@ -108,8 +108,8 @@ func (a *App) importScheme(rctx request.CTX, data *imports.SchemeImportData, dry if data.DefaultChannelGuestRole == nil { data.DefaultChannelGuestRole = &imports.RoleImportData{ - DisplayName: model.NewString("Channel Guest Role for Scheme"), - SchemeManaged: model.NewBool(true), + DisplayName: model.NewPointer("Channel Guest Role for Scheme"), + SchemeManaged: model.NewPointer(true), } } data.DefaultChannelGuestRole.Name = &scheme.DefaultChannelGuestRole @@ -889,7 +889,7 @@ func (a *App) importUserTeams(rctx request.CTX, user *model.User, data *[]import channels[team.Id] = append(channels[team.Id], *tdata.Channels...) } if !user.IsGuest() { - channels[team.Id] = append(channels[team.Id], imports.UserChannelImportData{Name: model.NewString(model.DefaultChannelName)}) + channels[team.Id] = append(channels[team.Id], imports.UserChannelImportData{Name: model.NewPointer(model.DefaultChannelName)}) } teamsByID[team.Id] = team diff --git a/server/channels/app/import_functions_test.go b/server/channels/app/import_functions_test.go index 1f65b535a3..488a21b586 100644 --- a/server/channels/app/import_functions_test.go +++ b/server/channels/app/import_functions_test.go @@ -461,7 +461,7 @@ func TestImportImportRole(t *testing.T) { data.DisplayName = ptrStr("new display name") data.Description = ptrStr("description") data.Permissions = &[]string{"manage_slash_commands"} - data.SchemeManaged = model.NewBool(true) + data.SchemeManaged = model.NewPointer(true) err = th.App.importRole(th.Context, &data, false) require.Nil(t, err, "Should have succeeded. %v", err) @@ -1580,7 +1580,7 @@ func TestImportUserTeams(t *testing.T) { name: "Not existing team should fail", data: &[]imports.UserTeamImportData{ { - Name: model.NewString("not-existing-team-name"), + Name: model.NewPointer("not-existing-team-name"), }, }, expectedError: true, @@ -1596,7 +1596,7 @@ func TestImportUserTeams(t *testing.T) { data: &[]imports.UserTeamImportData{ { Name: &th.BasicTeam.Name, - Roles: model.NewString("not-existing-role"), + Roles: model.NewPointer("not-existing-role"), }, }, expectedError: true, @@ -1624,7 +1624,7 @@ func TestImportUserTeams(t *testing.T) { data: &[]imports.UserTeamImportData{ { Name: &th.BasicTeam.Name, - Roles: model.NewString(model.TeamAdminRoleId), + Roles: model.NewPointer(model.TeamAdminRoleId), }, }, expectedError: false, @@ -1718,7 +1718,7 @@ func TestImportUserTeams(t *testing.T) { Name: &channel3.Name, }, { - Name: model.NewString("town-square"), + Name: model.NewPointer("town-square"), }, }, }, @@ -1785,9 +1785,9 @@ func TestImportUserChannels(t *testing.T) { channel2 := th.CreateChannel(th.Context, th.BasicTeam) customRole := th.CreateRole("test_custom_role") sampleNotifyProps := imports.UserChannelNotifyPropsImportData{ - Desktop: model.NewString("all"), - Mobile: model.NewString("none"), - MarkUnread: model.NewString("all"), + Desktop: model.NewPointer("all"), + Mobile: model.NewPointer("none"), + MarkUnread: model.NewPointer("all"), } tt := []struct { @@ -1803,7 +1803,7 @@ func TestImportUserChannels(t *testing.T) { name: "Not existing channel should fail", data: &[]imports.UserChannelImportData{ { - Name: model.NewString("not-existing-channel-name"), + Name: model.NewPointer("not-existing-channel-name"), }, }, expectedError: true, @@ -1818,7 +1818,7 @@ func TestImportUserChannels(t *testing.T) { data: &[]imports.UserChannelImportData{ { Name: &th.BasicChannel.Name, - Roles: model.NewString("not-existing-role"), + Roles: model.NewPointer("not-existing-role"), }, }, expectedError: true, @@ -1844,7 +1844,7 @@ func TestImportUserChannels(t *testing.T) { data: &[]imports.UserChannelImportData{ { Name: &th.BasicChannel.Name, - Roles: model.NewString(model.ChannelAdminRoleId), + Roles: model.NewPointer(model.ChannelAdminRoleId), }, }, expectedError: false, @@ -4399,7 +4399,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) { data.Post.Attachments = &[]imports.AttachmentImportData{{Path: &filePath}} data.Post.Replies = nil - data.Post.Message = model.NewString("new post") + data.Post.Message = model.NewPointer("new post") errLine, appErr := th.App.importMultiplePostLines(th.Context, []imports.LineImportWorkerData{data}, false, true) require.Nil(t, appErr) require.Equal(t, 0, errLine) @@ -4436,7 +4436,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) { data.Post.Attachments = &[]imports.AttachmentImportData{{Path: &filePath}} data.Post.Replies = nil - data.Post.Message = model.NewString("new post2") + data.Post.Message = model.NewPointer("new post2") errLine, appErr := th.App.importMultiplePostLines(th.Context, []imports.LineImportWorkerData{data}, false, true) require.Nil(t, appErr) require.Equal(t, 0, errLine) @@ -4757,7 +4757,7 @@ func TestZippedImportPostAndRepliesWithAttachments(t *testing.T) { require.NotNil(t, fileB) data.Post.Attachments = &[]imports.AttachmentImportData{{Path: &fileA.Name, Data: fileA}} - data.Post.Message = model.NewString("new post") + data.Post.Message = model.NewPointer("new post") data.Post.Replies = nil errLine, err := th.App.importMultiplePostLines(th.Context, []imports.LineImportWorkerData{data}, false, true) require.Nil(t, err) @@ -4867,15 +4867,15 @@ func BenchmarkCompareFilesContent(b *testing.B) { b.Run("s3", func(b *testing.B) { th := SetupConfig(b, func(cfg *model.Config) { cfg.FileSettings = model.FileSettings{ - DriverName: model.NewString(model.ImageDriverS3), - AmazonS3AccessKeyId: model.NewString(model.MinioAccessKey), - AmazonS3SecretAccessKey: model.NewString(model.MinioSecretKey), - AmazonS3Bucket: model.NewString("comparefilescontentbucket"), - AmazonS3Endpoint: model.NewString("localhost:9000"), - AmazonS3Region: model.NewString(""), - AmazonS3PathPrefix: model.NewString(""), - AmazonS3SSL: model.NewBool(false), - AmazonS3RequestTimeoutMilliseconds: model.NewInt64(300 * 1000), + DriverName: model.NewPointer(model.ImageDriverS3), + AmazonS3AccessKeyId: model.NewPointer(model.MinioAccessKey), + AmazonS3SecretAccessKey: model.NewPointer(model.MinioSecretKey), + AmazonS3Bucket: model.NewPointer("comparefilescontentbucket"), + AmazonS3Endpoint: model.NewPointer("localhost:9000"), + AmazonS3Region: model.NewPointer(""), + AmazonS3PathPrefix: model.NewPointer(""), + AmazonS3SSL: model.NewPointer(false), + AmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(300 * 1000)), } }) defer th.TearDown() @@ -5003,15 +5003,15 @@ func BenchmarkCompareFilesContent(b *testing.B) { b.Run("s3", func(b *testing.B) { th := SetupConfig(b, func(cfg *model.Config) { cfg.FileSettings = model.FileSettings{ - DriverName: model.NewString(model.ImageDriverS3), - AmazonS3AccessKeyId: model.NewString(model.MinioAccessKey), - AmazonS3SecretAccessKey: model.NewString(model.MinioSecretKey), - AmazonS3Bucket: model.NewString("comparefilescontentbucket"), - AmazonS3Endpoint: model.NewString("localhost:9000"), - AmazonS3Region: model.NewString(""), - AmazonS3PathPrefix: model.NewString(""), - AmazonS3SSL: model.NewBool(false), - AmazonS3RequestTimeoutMilliseconds: model.NewInt64(300 * 1000), + DriverName: model.NewPointer(model.ImageDriverS3), + AmazonS3AccessKeyId: model.NewPointer(model.MinioAccessKey), + AmazonS3SecretAccessKey: model.NewPointer(model.MinioSecretKey), + AmazonS3Bucket: model.NewPointer("comparefilescontentbucket"), + AmazonS3Endpoint: model.NewPointer("localhost:9000"), + AmazonS3Region: model.NewPointer(""), + AmazonS3PathPrefix: model.NewPointer(""), + AmazonS3SSL: model.NewPointer(false), + AmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(300 * 1000)), } }) defer th.TearDown() diff --git a/server/channels/app/import_test.go b/server/channels/app/import_test.go index 1e0817f73b..139e37eaa3 100644 --- a/server/channels/app/import_test.go +++ b/server/channels/app/import_test.go @@ -295,10 +295,10 @@ func TestProcessAttachments(t *testing.T) { genAttachments := func() *[]imports.AttachmentImportData { return &[]imports.AttachmentImportData{ { - Path: model.NewString("file.jpg"), + Path: model.NewPointer("file.jpg"), }, { - Path: model.NewString("somedir/file.jpg"), + Path: model.NewPointer("somedir/file.jpg"), }, } } @@ -320,24 +320,24 @@ func TestProcessAttachments(t *testing.T) { userLine := imports.LineImportData{ Type: "user", User: &imports.UserImportData{ - ProfileImage: model.NewString("profile.jpg"), + ProfileImage: model.NewPointer("profile.jpg"), }, } emojiLine := imports.LineImportData{ Type: "emoji", Emoji: &imports.EmojiImportData{ - Image: model.NewString("emoji.png"), + Image: model.NewPointer("emoji.png"), }, } t.Run("empty path", func(t *testing.T) { expected := &[]imports.AttachmentImportData{ { - Path: model.NewString("file.jpg"), + Path: model.NewPointer("file.jpg"), }, { - Path: model.NewString("somedir/file.jpg"), + Path: model.NewPointer("somedir/file.jpg"), }, } @@ -352,10 +352,10 @@ func TestProcessAttachments(t *testing.T) { t.Run("valid path", func(t *testing.T) { expected := &[]imports.AttachmentImportData{ { - Path: model.NewString("/tmp/file.jpg"), + Path: model.NewPointer("/tmp/file.jpg"), }, { - Path: model.NewString("/tmp/somedir/file.jpg"), + Path: model.NewPointer("/tmp/somedir/file.jpg"), }, } @@ -499,7 +499,7 @@ func TestImportBulkImportWithAttachments(t *testing.T) { } require.NotNil(t, jsonFile) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewInt(1000) }) + th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewPointer(1000) }) appErr, _ := th.App.BulkImportWithPath(th.Context, jsonFile, importZipReader, false, true, 1, model.ExportDataDir) require.Nil(t, appErr) diff --git a/server/channels/app/integration_action_test.go b/server/channels/app/integration_action_test.go index a033ab5457..6880ddc137 100644 --- a/server/channels/app/integration_action_test.go +++ b/server/channels/app/integration_action_test.go @@ -163,7 +163,7 @@ func TestPostActionEmptyResponse(t *testing.T) { require.True(t, ok) th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1) + cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1)) }) _, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil) diff --git a/server/channels/app/login_test.go b/server/channels/app/login_test.go index 989a51b72e..53dbce604f 100644 --- a/server/channels/app/login_test.go +++ b/server/channels/app/login_test.go @@ -43,7 +43,7 @@ func TestCWSLogin(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() license := model.NewTestLicense() - license.Features.Cloud = model.NewBool(true) + license.Features.Cloud = model.NewPointer(true) th.App.Srv().SetLicense(license) t.Run("Should authenticate user when CWS login is enabled and tokens are equal", func(t *testing.T) { diff --git a/server/channels/app/mention_parser_standard_test.go b/server/channels/app/mention_parser_standard_test.go index 471c3dc988..3d5c83697c 100644 --- a/server/channels/app/mention_parser_standard_test.go +++ b/server/channels/app/mention_parser_standard_test.go @@ -229,24 +229,24 @@ func TestCheckForMentionGroups(t *testing.T) { "No matching groups": { Word: "nothing", Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{}, }, "matching group with no @": { Word: "engineering", Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{}, }, "matching group with preceding @": { Word: "@engineering", Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ GroupMentions: map[string]MentionType{ @@ -257,8 +257,8 @@ func TestCheckForMentionGroups(t *testing.T) { "matching upper case group with preceding @": { Word: "@Engineering", Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ GroupMentions: map[string]MentionType{ @@ -294,8 +294,8 @@ func TestProcessText(t *testing.T) { Text: "hello user @user1", Keywords: map[string][]string{"@user1": {userID1}}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ Mentions: map[string]MentionType{ @@ -307,8 +307,8 @@ func TestProcessText(t *testing.T) { Text: "hello user.@user1", Keywords: map[string][]string{"@user1": {userID1}}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ Mentions: map[string]MentionType{ @@ -329,8 +329,8 @@ func TestProcessText(t *testing.T) { Text: "hello user:@user1", Keywords: map[string][]string{"@user1": {userID1}}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ Mentions: map[string]MentionType{ @@ -342,8 +342,8 @@ func TestProcessText(t *testing.T) { Text: "hello all:@here", Keywords: map[string][]string{}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ HereMentioned: true, @@ -353,8 +353,8 @@ func TestProcessText(t *testing.T) { Text: "hello all-@all", Keywords: map[string][]string{}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ AllMentioned: true, @@ -364,8 +364,8 @@ func TestProcessText(t *testing.T) { Text: "hello channel.@channel", Keywords: map[string][]string{}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ ChannelMentioned: true, @@ -375,8 +375,8 @@ func TestProcessText(t *testing.T) { Text: "hello @potentialuser and @otherpotentialuser", Keywords: map[string][]string{}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ OtherPotentialMentions: []string{"potentialuser", "otherpotentialuser"}, @@ -386,8 +386,8 @@ func TestProcessText(t *testing.T) { Text: "@user1, you can use @systembot to get help", Keywords: map[string][]string{"@user1": {userID1}}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ Mentions: map[string]MentionType{ @@ -400,8 +400,8 @@ func TestProcessText(t *testing.T) { Text: "@engineering", Keywords: map[string][]string{"@user1": {userID1}}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ GroupMentions: map[string]MentionType{groupID1: GroupMention}, @@ -411,8 +411,8 @@ func TestProcessText(t *testing.T) { Text: "@engineering @user1, you can use @systembot to get help from", Keywords: map[string][]string{"@user1": {userID1}}, Groups: map[string]*model.Group{ - groupID1: {Id: groupID1, Name: model.NewString("engineering")}, - groupID2: {Id: groupID2, Name: model.NewString("developers")}, + groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}, + groupID2: {Id: groupID2, Name: model.NewPointer("developers")}, }, Expected: &MentionResults{ Mentions: map[string]MentionType{ diff --git a/server/channels/app/migrations.go b/server/channels/app/migrations.go index 5f4b272721..c09cac5bc9 100644 --- a/server/channels/app/migrations.go +++ b/server/channels/app/migrations.go @@ -337,7 +337,7 @@ func (s *Server) doContentExtractionConfigDefaultTrueMigration() error { } s.platform.UpdateConfig(func(config *model.Config) { - config.FileSettings.ExtractContent = model.NewBool(true) + config.FileSettings.ExtractContent = model.NewPointer(true) }) system := model.System{ @@ -561,7 +561,7 @@ func (s *Server) doPostPriorityConfigDefaultTrueMigration() error { } s.platform.UpdateConfig(func(config *model.Config) { - config.ServiceSettings.PostPriority = model.NewBool(true) + config.ServiceSettings.PostPriority = model.NewPointer(true) }) system := model.System{ diff --git a/server/channels/app/notification_test.go b/server/channels/app/notification_test.go index f126d7947c..08662d3892 100644 --- a/server/channels/app/notification_test.go +++ b/server/channels/app/notification_test.go @@ -819,7 +819,7 @@ func TestFilterOutOfChannelMentions(t *testing.T) { require.Nil(t, appErr) constrainedChannel := th.CreateChannel(th.Context, th.BasicTeam) - constrainedChannel.GroupConstrained = model.NewBool(true) + constrainedChannel.GroupConstrained = model.NewPointer(true) constrainedChannel, appErr = th.App.UpdateChannel(th.Context, constrainedChannel) require.Nil(t, appErr) @@ -1361,7 +1361,7 @@ func TestGetExplicitMentions(t *testing.T) { }, "No matching groups": { Message: "@nothing", - Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}}, + Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}}, Expected: &MentionResults{ Mentions: nil, GroupMentions: nil, @@ -1370,7 +1370,7 @@ func TestGetExplicitMentions(t *testing.T) { }, "matching group with no @": { Message: "engineering", - Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}}, + Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}}, Expected: &MentionResults{ Mentions: nil, GroupMentions: nil, @@ -1379,7 +1379,7 @@ func TestGetExplicitMentions(t *testing.T) { }, "matching group with preceding @": { Message: "@engineering", - Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}}, + Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}}, Expected: &MentionResults{ Mentions: nil, GroupMentions: map[string]MentionType{ @@ -1389,7 +1389,7 @@ func TestGetExplicitMentions(t *testing.T) { }, "matching upper case group with preceding @": { Message: "@Engineering", - Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}}, + Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}}, Expected: &MentionResults{ Mentions: nil, GroupMentions: map[string]MentionType{ @@ -2517,7 +2517,7 @@ func TestInsertGroupMentions(t *testing.T) { channel := th.BasicChannel group := th.CreateGroup() group.DisplayName = "engineering" - group.Name = model.NewString("engineering") + group.Name = model.NewPointer("engineering") group, err := th.App.UpdateGroup(group) require.Nil(t, err) @@ -2544,7 +2544,7 @@ func TestInsertGroupMentions(t *testing.T) { groupWithNoMembers := th.CreateGroup() groupWithNoMembers.DisplayName = "marketing" - groupWithNoMembers.Name = model.NewString("marketing") + groupWithNoMembers.Name = model.NewPointer("marketing") groupWithNoMembers, err = th.App.UpdateGroup(groupWithNoMembers) require.Nil(t, err) @@ -2672,7 +2672,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) { customGroupId := model.NewId() customGroup, err := th.App.CreateGroup(&model.Group{ DisplayName: customGroupId, - Name: model.NewString("name" + customGroupId), + Name: model.NewPointer("name" + customGroupId), Source: model.GroupSourceCustom, Description: "description_" + customGroupId, AllowReference: true, @@ -2689,7 +2689,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) { // Sync first group to constrained channel constrainedChannel := th.CreateChannel(th.Context, th.BasicTeam) - constrainedChannel.GroupConstrained = model.NewBool(true) + constrainedChannel.GroupConstrained = model.NewPointer(true) constrainedChannel, err = th.App.UpdateChannel(th.Context, constrainedChannel) require.Nil(t, err) _, err = th.App.UpsertGroupSyncable(&model.GroupSyncable{ @@ -2715,7 +2715,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) { require.Nil(t, err) // Sync group2 to the team - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) team, err = th.App.UpdateTeam(team) require.Nil(t, err) _, err = th.App.UpsertGroupSyncable(&model.GroupSyncable{ @@ -2745,7 +2745,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) { require.Equal(t, groupsMap[customGroup.Id], customGroup) }) - team.GroupConstrained = model.NewBool(false) + team.GroupConstrained = model.NewPointer(false) team, err = th.App.UpdateTeam(team) require.Nil(t, err) @@ -2998,7 +2998,7 @@ func TestRemoveNotifications(t *testing.T) { t.Run("when mentioned via a user group", func(t *testing.T) { group, appErr := th.App.CreateGroup(&model.Group{ - Name: model.NewString("test_group"), + Name: model.NewPointer("test_group"), DisplayName: "test_group", Source: model.GroupSourceCustom, }) diff --git a/server/channels/app/oauth.go b/server/channels/app/oauth.go index dd9d6d075a..636cb3f818 100644 --- a/server/channels/app/oauth.go +++ b/server/channels/app/oauth.go @@ -627,7 +627,7 @@ func (a *App) LoginByOAuth(c request.CTX, service string, userData io.Reader, te map[string]any{"Service": service}, "", http.StatusBadRequest) } - user, err := a.GetUserByAuth(model.NewString(*authUser.AuthData), service) + user, err := a.GetUserByAuth(model.NewPointer(*authUser.AuthData), service) if err != nil { if err.Id == MissingAuthAccountError { user, err = a.CreateOAuthUser(c, service, bytes.NewReader(buf.Bytes()), teamID, tokenUser) diff --git a/server/channels/app/platform/config_test.go b/server/channels/app/platform/config_test.go index b0987e8125..bdc33aea47 100644 --- a/server/channels/app/platform/config_test.go +++ b/server/channels/app/platform/config_test.go @@ -61,7 +61,7 @@ func TestConfigSave(t *testing.T) { t.Run("trigger a config changed event for the cluster", func(t *testing.T) { oldCfg := th.Service.Config() newCfg := oldCfg.Clone() - newCfg.ServiceSettings.SiteURL = model.NewString("http://newhost.me") + newCfg.ServiceSettings.SiteURL = model.NewPointer("http://newhost.me") sanitizedOldCfg := th.Service.configStore.RemoveEnvironmentOverrides(oldCfg) sanitizedNewCfg := th.Service.configStore.RemoveEnvironmentOverrides(newCfg) @@ -87,16 +87,16 @@ func TestConfigSave(t *testing.T) { // Change a random config setting cfg := th.Service.Config().Clone() - cfg.ThemeSettings.EnableThemeSelection = model.NewBool(!*cfg.ThemeSettings.EnableThemeSelection) + cfg.ThemeSettings.EnableThemeSelection = model.NewPointer(!*cfg.ThemeSettings.EnableThemeSelection) th.Service.SaveConfig(cfg, false) metricsMock.AssertNumberOfCalls(t, "Register", 0) // Disable metrics - cfg.MetricsSettings.Enable = model.NewBool(false) + cfg.MetricsSettings.Enable = model.NewPointer(false) th.Service.SaveConfig(cfg, false) // Change the metrics setting - cfg.MetricsSettings.Enable = model.NewBool(true) + cfg.MetricsSettings.Enable = model.NewPointer(true) th.Service.SaveConfig(cfg, false) metricsMock.AssertNumberOfCalls(t, "Register", 1) }) diff --git a/server/channels/app/platform/helper_test.go b/server/channels/app/platform/helper_test.go index a9b0fbcf4f..729921e14d 100644 --- a/server/channels/app/platform/helper_test.go +++ b/server/channels/app/platform/helper_test.go @@ -264,7 +264,7 @@ type ChannelOption func(*model.Channel) func WithShared(v bool) ChannelOption { return func(channel *model.Channel) { - channel.Shared = model.NewBool(v) + channel.Shared = model.NewPointer(v) } } diff --git a/server/channels/app/platform/service_test.go b/server/channels/app/platform/service_test.go index 0abdd08b4f..f4985f5fe4 100644 --- a/server/channels/app/platform/service_test.go +++ b/server/channels/app/platform/service_test.go @@ -98,7 +98,7 @@ func TestMetrics(t *testing.T) { // there is no config listener for the metrics // we handle it on config save step cfg := th.Service.Config().Clone() - cfg.MetricsSettings.Enable = model.NewBool(true) + cfg.MetricsSettings.Enable = model.NewPointer(true) th.Service.SaveConfig(cfg, false) require.NotNil(t, th.Service.metrics) @@ -109,7 +109,7 @@ func TestMetrics(t *testing.T) { require.NoError(t, err) require.Equal(t, http.StatusOK, resp.StatusCode) - cfg.MetricsSettings.Enable = model.NewBool(false) + cfg.MetricsSettings.Enable = model.NewPointer(false) th.Service.SaveConfig(cfg, false) _, err = http.Get(metricsAddr) diff --git a/server/channels/app/platform/shared_channel_notifier_test.go b/server/channels/app/platform/shared_channel_notifier_test.go index b028b7381d..b79ebcea76 100644 --- a/server/channels/app/platform/shared_channel_notifier_test.go +++ b/server/channels/app/platform/shared_channel_notifier_test.go @@ -81,7 +81,7 @@ func TestServerSyncSharedChannelHandler(t *testing.T) { mockChannelStore := &mocks.ChannelStore{} mockChannelStore.On("Get", "channelID", true).Return(&model.Channel{ Id: "channelID", - Shared: model.NewBool(true), + Shared: model.NewPointer(true), }, nil) mockUserStore := &mocks.UserStore{} diff --git a/server/channels/app/platform/web_conn.go b/server/channels/app/platform/web_conn.go index 657982cdb6..9c2bd3e149 100644 --- a/server/channels/app/platform/web_conn.go +++ b/server/channels/app/platform/web_conn.go @@ -852,7 +852,7 @@ func (wc *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool { // see sensitive data. Prevents admin clients from receiving events with bad data var hasReadPrivateDataPermission *bool if msg.GetBroadcast().ContainsSanitizedData { - hasReadPrivateDataPermission = model.NewBool(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id)) + hasReadPrivateDataPermission = model.NewPointer(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id)) if *hasReadPrivateDataPermission { return false @@ -862,7 +862,7 @@ func (wc *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool { // If the event contains sensitive data, only send to users with permission to see it if msg.GetBroadcast().ContainsSensitiveData { if hasReadPrivateDataPermission == nil { - hasReadPrivateDataPermission = model.NewBool(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id)) + hasReadPrivateDataPermission = model.NewPointer(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id)) } if !*hasReadPrivateDataPermission { diff --git a/server/channels/app/plugin_api_test.go b/server/channels/app/plugin_api_test.go index 887228f704..28f016e66f 100644 --- a/server/channels/app/plugin_api_test.go +++ b/server/channels/app/plugin_api_test.go @@ -2408,8 +2408,8 @@ func TestPluginServeMetrics(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { prevEnable = cfg.MetricsSettings.Enable prevAddress = cfg.MetricsSettings.ListenAddress - cfg.MetricsSettings.Enable = model.NewBool(true) - cfg.MetricsSettings.ListenAddress = model.NewString(":30067") + cfg.MetricsSettings.Enable = model.NewPointer(true) + cfg.MetricsSettings.ListenAddress = model.NewPointer(":30067") }) defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.MetricsSettings.Enable = prevEnable diff --git a/server/channels/app/plugin_api_tests/test_db_driver/main.go b/server/channels/app/plugin_api_tests/test_db_driver/main.go index 62bc6dd718..6a25a109d4 100644 --- a/server/channels/app/plugin_api_tests/test_db_driver/main.go +++ b/server/channels/app/plugin_api_tests/test_db_driver/main.go @@ -32,7 +32,7 @@ func (p *MyPlugin) OnConfigurationChange() error { func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) { rctx := request.TestContext(p.t) settings := p.API.GetUnsanitizedConfig().SqlSettings - settings.Trace = model.NewBool(false) + settings.Trace = model.NewPointer(false) store, err := sqlstore.New(settings, rctx.Logger(), nil) if err != nil { panic(err) diff --git a/server/channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go b/server/channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go index 44e5d6f8f3..dd83b3d891 100644 --- a/server/channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go +++ b/server/channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go @@ -56,7 +56,7 @@ func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model // Update BasicUser to SAML expectedUserAuth := &model.UserAuth{ AuthService: model.UserAuthServiceSaml, - AuthData: model.NewString("saml_auth_data"), + AuthData: model.NewPointer("saml_auth_data"), } _, appErr = p.API.UpdateUserAuth(p.configuration.BasicUserID, expectedUserAuth) if appErr != nil { @@ -69,7 +69,7 @@ func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model // Update BasicUser to LDAP expectedUserAuth = &model.UserAuth{ AuthService: model.UserAuthServiceLdap, - AuthData: model.NewString("ldap_auth_data"), + AuthData: model.NewPointer("ldap_auth_data"), } _, err := p.API.UpdateUserAuth(p.configuration.BasicUserID, expectedUserAuth) if err != nil { diff --git a/server/channels/app/plugin_test.go b/server/channels/app/plugin_test.go index 8258a8c705..fcc1a75a88 100644 --- a/server/channels/app/plugin_test.go +++ b/server/channels/app/plugin_test.go @@ -479,7 +479,7 @@ func TestPluginSync(t *testing.T) { { "local", func(cfg *model.Config) { - cfg.FileSettings.DriverName = model.NewString(model.ImageDriverLocal) + cfg.FileSettings.DriverName = model.NewPointer(model.ImageDriverLocal) }, }, { @@ -496,14 +496,14 @@ func TestPluginSync(t *testing.T) { } s3Endpoint := fmt.Sprintf("%s:%s", s3Host, s3Port) - cfg.FileSettings.DriverName = model.NewString(model.ImageDriverS3) - cfg.FileSettings.AmazonS3AccessKeyId = model.NewString(model.MinioAccessKey) - cfg.FileSettings.AmazonS3SecretAccessKey = model.NewString(model.MinioSecretKey) - cfg.FileSettings.AmazonS3Bucket = model.NewString(model.MinioBucket) - cfg.FileSettings.AmazonS3PathPrefix = model.NewString("") - cfg.FileSettings.AmazonS3Endpoint = model.NewString(s3Endpoint) - cfg.FileSettings.AmazonS3Region = model.NewString("") - cfg.FileSettings.AmazonS3SSL = model.NewBool(false) + cfg.FileSettings.DriverName = model.NewPointer(model.ImageDriverS3) + cfg.FileSettings.AmazonS3AccessKeyId = model.NewPointer(model.MinioAccessKey) + cfg.FileSettings.AmazonS3SecretAccessKey = model.NewPointer(model.MinioSecretKey) + cfg.FileSettings.AmazonS3Bucket = model.NewPointer(model.MinioBucket) + cfg.FileSettings.AmazonS3PathPrefix = model.NewPointer("") + cfg.FileSettings.AmazonS3Endpoint = model.NewPointer(s3Endpoint) + cfg.FileSettings.AmazonS3Region = model.NewPointer("") + cfg.FileSettings.AmazonS3SSL = model.NewPointer(false) }, }, } diff --git a/server/channels/app/post.go b/server/channels/app/post.go index b48e7ae569..4d2193a311 100644 --- a/server/channels/app/post.go +++ b/server/channels/app/post.go @@ -693,7 +693,7 @@ func (a *App) UpdatePost(c request.CTX, receivedUpdatedPost *model.Post, safeUpd } if receivedUpdatedPost.IsRemote() { - oldPost.RemoteId = model.NewString(*receivedUpdatedPost.RemoteId) + oldPost.RemoteId = model.NewPointer(*receivedUpdatedPost.RemoteId) } var rejectionReason string diff --git a/server/channels/app/post_test.go b/server/channels/app/post_test.go index 1110efcef3..f3d562f58f 100644 --- a/server/channels/app/post_test.go +++ b/server/channels/app/post_test.go @@ -700,10 +700,10 @@ func TestImageProxy(t *testing.T) { } { t.Run(name, func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ImageProxySettings.Enable = model.NewBool(true) - cfg.ImageProxySettings.ImageProxyType = model.NewString(tc.ProxyType) - cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewString(tc.ProxyOptions) - cfg.ImageProxySettings.RemoteImageProxyURL = model.NewString(tc.ProxyURL) + cfg.ImageProxySettings.Enable = model.NewPointer(true) + cfg.ImageProxySettings.ImageProxyType = model.NewPointer(tc.ProxyType) + cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewPointer(tc.ProxyOptions) + cfg.ImageProxySettings.RemoteImageProxyURL = model.NewPointer(tc.ProxyURL) }) post := &model.Post{ @@ -1131,7 +1131,7 @@ func TestPatchPost(t *testing.T) { assert.NotEqual(t, "![image]("+proxiedImageURL+")", rpost.Message) patch := &model.PostPatch{ - Message: model.NewString("![image](" + imageURL + ")"), + Message: model.NewPointer("![image](" + imageURL + ")"), } rpost, err = th.App.PatchPost(th.Context, rpost.Id, patch) @@ -1155,13 +1155,13 @@ func TestPatchPost(t *testing.T) { require.Nil(t, err) t.Run("Does not set prop when user has USE_CHANNEL_MENTIONS", func(t *testing.T) { - patchWithNoMention := &model.PostPatch{Message: model.NewString("This patch has no channel mention")} + patchWithNoMention := &model.PostPatch{Message: model.NewPointer("This patch has no channel mention")} rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithNoMention) require.Nil(t, err) assert.Equal(t, rpost.GetProps(), model.StringInterface{}) - patchWithMention := &model.PostPatch{Message: model.NewString("This patch has a mention now @here")} + patchWithMention := &model.PostPatch{Message: model.NewPointer("This patch has a mention now @here")} rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithMention) require.Nil(t, err) @@ -1172,12 +1172,12 @@ func TestPatchPost(t *testing.T) { th.RemovePermissionFromRole(model.PermissionUseChannelMentions.Id, model.ChannelUserRoleId) th.RemovePermissionFromRole(model.PermissionUseChannelMentions.Id, model.ChannelAdminRoleId) - patchWithNoMention := &model.PostPatch{Message: model.NewString("This patch still does not have a mention")} + patchWithNoMention := &model.PostPatch{Message: model.NewPointer("This patch still does not have a mention")} rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithNoMention) require.Nil(t, err) assert.Equal(t, rpost.GetProps(), model.StringInterface{}) - patchWithMention := &model.PostPatch{Message: model.NewString("This patch has a mention now @here")} + patchWithMention := &model.PostPatch{Message: model.NewPointer("This patch has a mention now @here")} rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithMention) require.Nil(t, err) @@ -1373,7 +1373,7 @@ func TestPatchPostInArchivedChannel(t *testing.T) { post := th.CreatePost(archivedChannel) th.App.DeleteChannel(th.Context, archivedChannel, "") - _, err := th.App.PatchPost(th.Context, post.Id, &model.PostPatch{IsPinned: model.NewBool(true)}) + _, err := th.App.PatchPost(th.Context, post.Id, &model.PostPatch{IsPinned: model.NewPointer(true)}) require.NotNil(t, err) require.Equal(t, "api.post.patch_post.can_not_update_post_in_deleted.error", err.Id) } @@ -2471,7 +2471,7 @@ func TestCountMentionsFromPost(t *testing.T) { Message: fmt.Sprintf("@%s", user2.Username), Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), + Priority: model.NewPointer(model.PostPriorityUrgent), }, }, }, channel, false, true) @@ -2490,7 +2490,7 @@ func TestCountMentionsFromPost(t *testing.T) { Message: "apple", Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), + Priority: model.NewPointer(model.PostPriorityUrgent), }, }, }, channel, false, true) @@ -3263,7 +3263,7 @@ func TestComputeLastAccessiblePostTime(t *testing.T) { // cloud-starter, limit is applicable cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{ Messages: &model.MessagesLimits{ - History: model.NewInt(1), + History: model.NewPointer(1), }, }, nil) @@ -3323,14 +3323,14 @@ func TestGetEditHistoryForPost(t *testing.T) { // update the post message patch := &model.PostPatch{ - Message: model.NewString("new message edited"), + Message: model.NewPointer("new message edited"), } _, err1 := th.App.PatchPost(th.Context, rpost.Id, patch) require.Nil(t, err1) // update the post message again patch = &model.PostPatch{ - Message: model.NewString("new message edited again"), + Message: model.NewPointer("new message edited again"), } _, err2 := th.App.PatchPost(th.Context, rpost.Id, patch) @@ -3410,11 +3410,11 @@ func TestValidateMoveOrCopy(t *testing.T) { defer th.TearDown() th.App.UpdateConfig(func(cfg *model.Config) { - cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewBool(true) - cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewBool(true) - cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewBool(true) - cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewBool(true) - cfg.WranglerSettings.MoveThreadMaxCount = model.NewInt64(100) + cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewPointer(true) + cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewPointer(true) + cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewPointer(true) + cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewPointer(true) + cfg.WranglerSettings.MoveThreadMaxCount = model.NewPointer(int64(100)) }) t.Run("empty post list", func(t *testing.T) { @@ -3433,7 +3433,7 @@ func TestValidateMoveOrCopy(t *testing.T) { require.Nil(t, err) th.App.UpdateConfig(func(cfg *model.Config) { - cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewBool(false) + cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewPointer(false) }) e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: privateChannel.Id}}}, privateChannel, th.BasicChannel, th.BasicUser) @@ -3446,7 +3446,7 @@ func TestValidateMoveOrCopy(t *testing.T) { require.Nil(t, err) require.NotNil(t, directChannel) th.App.UpdateConfig(func(cfg *model.Config) { - cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewBool(false) + cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewPointer(false) }) e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: directChannel.Id}}}, directChannel, th.BasicChannel, th.BasicUser) @@ -3464,7 +3464,7 @@ func TestValidateMoveOrCopy(t *testing.T) { require.Nil(t, err) th.App.UpdateConfig(func(cfg *model.Config) { - cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewBool(false) + cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewPointer(false) }) e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: groupChannel.Id}}}, groupChannel, th.BasicChannel, th.BasicUser) @@ -3493,7 +3493,7 @@ func TestValidateMoveOrCopy(t *testing.T) { require.Nil(t, err) th.App.UpdateConfig(func(cfg *model.Config) { - cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewBool(false) + cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewPointer(false) }) e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: th.BasicChannel.Id}}}, th.BasicChannel, targetChannel, th.BasicUser) diff --git a/server/channels/app/product_notices_test.go b/server/channels/app/product_notices_test.go index 1d1ed12af3..6eb64e0468 100644 --- a/server/channels/app/product_notices_test.go +++ b/server/channels/app/product_notices_test.go @@ -248,7 +248,7 @@ func TestNoticeValidation(t *testing.T) { userCount: 300, notice: &model.ProductNotice{ Conditions: model.Conditions{ - NumberOfUsers: model.NewInt64(400), + NumberOfUsers: model.NewPointer(int64(400)), }, }, }, @@ -262,8 +262,8 @@ func TestNoticeValidation(t *testing.T) { postCount: 2000, notice: &model.ProductNotice{ Conditions: model.Conditions{ - NumberOfUsers: model.NewInt64(400), - NumberOfPosts: model.NewInt64(3000), + NumberOfUsers: model.NewPointer(int64(400)), + NumberOfPosts: model.NewPointer(int64(3000)), }, }, }, @@ -275,7 +275,7 @@ func TestNoticeValidation(t *testing.T) { args: args{ notice: &model.ProductNotice{ Conditions: model.Conditions{ - DisplayDate: model.NewString("> 2000-03-01T00:00:00Z <= 2999-04-01T00:00:00Z"), + DisplayDate: model.NewPointer("> 2000-03-01T00:00:00Z <= 2999-04-01T00:00:00Z"), }, }, }, @@ -287,7 +287,7 @@ func TestNoticeValidation(t *testing.T) { args: args{ notice: &model.ProductNotice{ Conditions: model.Conditions{ - DisplayDate: model.NewString(fmt.Sprintf("= %sT00:00:00Z", time.Now().UTC().Format("2006-01-02"))), + DisplayDate: model.NewPointer(fmt.Sprintf("= %sT00:00:00Z", time.Now().UTC().Format("2006-01-02"))), }, }, }, @@ -299,7 +299,7 @@ func TestNoticeValidation(t *testing.T) { args: args{ notice: &model.ProductNotice{ Conditions: model.Conditions{ - DisplayDate: model.NewString("> 2999-03-01T00:00:00Z <= 3000-04-01T00:00:00Z"), + DisplayDate: model.NewPointer("> 2999-03-01T00:00:00Z <= 3000-04-01T00:00:00Z"), }, }, }, @@ -311,7 +311,7 @@ func TestNoticeValidation(t *testing.T) { args: args{ notice: &model.ProductNotice{ Conditions: model.Conditions{ - DisplayDate: model.NewString("> 2000 -03-01T00:00:00Z <= 2999-04-01T00:00:00Z"), + DisplayDate: model.NewPointer("> 2000 -03-01T00:00:00Z <= 2999-04-01T00:00:00Z"), }, }, }, @@ -618,7 +618,7 @@ func TestNoticeFetch(t *testing.T) { notices2 := model.ProductNotices{model.ProductNotice{ Conditions: model.Conditions{ - NumberOfPosts: model.NewInt64(99999), + NumberOfPosts: model.NewPointer(int64(99999)), }, ID: "333", LocalizedMessages: map[string]model.NoticeMessageInternal{ diff --git a/server/channels/app/ratelimit_test.go b/server/channels/app/ratelimit_test.go index e026640ccd..2c57b25ae9 100644 --- a/server/channels/app/ratelimit_test.go +++ b/server/channels/app/ratelimit_test.go @@ -16,12 +16,12 @@ import ( func genRateLimitSettings(useAuth, useIP bool, header string) *model.RateLimitSettings { return &model.RateLimitSettings{ - Enable: model.NewBool(true), - PerSec: model.NewInt(10), - MaxBurst: model.NewInt(100), - MemoryStoreSize: model.NewInt(10000), - VaryByRemoteAddr: model.NewBool(useIP), - VaryByUser: model.NewBool(useAuth), + Enable: model.NewPointer(true), + PerSec: model.NewPointer(10), + MaxBurst: model.NewPointer(100), + MemoryStoreSize: model.NewPointer(10000), + VaryByRemoteAddr: model.NewPointer(useIP), + VaryByUser: model.NewPointer(useAuth), VaryByHeader: header, } } @@ -39,7 +39,7 @@ func TestNewRateLimiterSuccess(t *testing.T) { func TestNewRateLimiterFailure(t *testing.T) { invalidSettings := genRateLimitSettings(false, false, "") - invalidSettings.MaxBurst = model.NewInt(-100) + invalidSettings.MaxBurst = model.NewPointer(-100) rateLimiter, err := NewRateLimiter(invalidSettings, nil) require.Nil(t, rateLimiter) require.Error(t, err) diff --git a/server/channels/app/server_test.go b/server/channels/app/server_test.go index 97941a083f..4727cef97f 100644 --- a/server/channels/app/server_test.go +++ b/server/channels/app/server_test.go @@ -102,14 +102,14 @@ func TestStartServerNoS3Bucket(t *testing.T) { cfg := store.Get() cfg.FileSettings = model.FileSettings{ - DriverName: model.NewString(model.ImageDriverS3), - AmazonS3AccessKeyId: model.NewString(model.MinioAccessKey), - AmazonS3SecretAccessKey: model.NewString(model.MinioSecretKey), - AmazonS3Bucket: model.NewString("nosuchbucket"), - AmazonS3Endpoint: model.NewString(s3Endpoint), - AmazonS3Region: model.NewString(""), - AmazonS3PathPrefix: model.NewString(""), - AmazonS3SSL: model.NewBool(false), + DriverName: model.NewPointer(model.ImageDriverS3), + AmazonS3AccessKeyId: model.NewPointer(model.MinioAccessKey), + AmazonS3SecretAccessKey: model.NewPointer(model.MinioSecretKey), + AmazonS3Bucket: model.NewPointer("nosuchbucket"), + AmazonS3Endpoint: model.NewPointer(s3Endpoint), + AmazonS3Region: model.NewPointer(""), + AmazonS3PathPrefix: model.NewPointer(""), + AmazonS3SSL: model.NewPointer(false), } *cfg.ServiceSettings.ListenAddress = "localhost:0" *cfg.AnnouncementSettings.AdminNoticesEnabled = false @@ -316,9 +316,9 @@ func TestPanicLog(t *testing.T) { logger, _ := mlog.NewLogger() logSettings := model.NewLogSettings() - logSettings.EnableConsole = model.NewBool(true) - logSettings.ConsoleJson = model.NewBool(true) - logSettings.EnableFile = model.NewBool(true) + logSettings.EnableConsole = model.NewPointer(true) + logSettings.ConsoleJson = model.NewPointer(true) + logSettings.EnableFile = model.NewPointer(true) logSettings.FileLocation = &tmpDir logSettings.FileLevel = &mlog.LvlInfo.Name diff --git a/server/channels/app/slashcommands/command_invite_test.go b/server/channels/app/slashcommands/command_invite_test.go index 5923ceb8ad..5b4b4d516c 100644 --- a/server/channels/app/slashcommands/command_invite_test.go +++ b/server/channels/app/slashcommands/command_invite_test.go @@ -145,7 +145,7 @@ func TestInviteProvider(t *testing.T) { groupChannel := th.createChannel(th.BasicTeam, model.ChannelTypePrivate) _, err := th.App.AddChannelMember(th.Context, th.BasicUser.Id, groupChannel, app.ChannelMemberOpts{}) require.Nil(t, err) - groupChannel.GroupConstrained = model.NewBool(true) + groupChannel.GroupConstrained = model.NewPointer(true) groupChannel, _ = th.App.UpdateChannel(th.Context, groupChannel) msg := "@" + th.BasicUser2.Username + " ~" + groupChannel.Name @@ -213,7 +213,7 @@ func TestInviteGroup(t *testing.T) { th := setup(t).initBasic() defer th.tearDown() - th.BasicTeam.GroupConstrained = model.NewBool(true) + th.BasicTeam.GroupConstrained = model.NewPointer(true) var err *model.AppError _, _ = th.App.AddTeamMember(th.Context, th.BasicTeam.Id, th.BasicUser.Id) _, err = th.App.AddTeamMember(th.Context, th.BasicTeam.Id, th.BasicUser2.Id) @@ -274,7 +274,7 @@ func TestUserGroups(t *testing.T) { id := model.NewId() teamGroup, err := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceCustom, Description: "description_" + id, AllowReference: true, @@ -293,7 +293,7 @@ func TestUserGroups(t *testing.T) { id2 := model.NewId() nonTeamGroup, err := th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id2, - Name: model.NewString("name" + id2), + Name: model.NewPointer("name" + id2), Source: model.GroupSourceCustom, Description: "description_" + id2, AllowReference: true, diff --git a/server/channels/app/slashcommands/command_test.go b/server/channels/app/slashcommands/command_test.go index 0751c8d54a..d9dbd0896a 100644 --- a/server/channels/app/slashcommands/command_test.go +++ b/server/channels/app/slashcommands/command_test.go @@ -354,8 +354,8 @@ func TestDoCommandRequest(t *testing.T) { defer th.tearDown() th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewString("127.0.0.1") - cfg.ServiceSettings.EnableCommands = model.NewBool(true) + cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewPointer("127.0.0.1") + cfg.ServiceSettings.EnableCommands = model.NewPointer(true) }) t.Run("with a valid text response", func(t *testing.T) { @@ -434,7 +434,7 @@ func TestDoCommandRequest(t *testing.T) { defer server.Close() th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1) + cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1)) }) _, _, err := th.App.DoCommandRequest(th.Context, &model.Command{URL: server.URL}, url.Values{}) @@ -452,7 +452,7 @@ func TestDoCommandRequest(t *testing.T) { defer server.Close() th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(2) + cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(2)) }) _, resp, err := th.App.DoCommandRequest(th.Context, &model.Command{URL: server.URL}, url.Values{}) @@ -466,7 +466,7 @@ func TestDoCommandRequest(t *testing.T) { outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{} outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections - th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true) + th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true) t.Cleanup(func() { th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig diff --git a/server/channels/app/slashcommands/helper_test.go b/server/channels/app/slashcommands/helper_test.go index 88161fa214..e75b89c52f 100644 --- a/server/channels/app/slashcommands/helper_test.go +++ b/server/channels/app/slashcommands/helper_test.go @@ -261,7 +261,7 @@ type ChannelOption func(*model.Channel) func WithShared(v bool) ChannelOption { return func(channel *model.Channel) { - channel.Shared = model.NewBool(v) + channel.Shared = model.NewPointer(v) } } diff --git a/server/channels/app/support_packet_test.go b/server/channels/app/support_packet_test.go index e1f0989877..8088f66c30 100644 --- a/server/channels/app/support_packet_test.go +++ b/server/channels/app/support_packet_test.go @@ -49,7 +49,7 @@ func TestGenerateSupportPacketYaml(t *testing.T) { licenseUsers := 100 license := model.NewTestLicense("ldap") - license.Features.Users = model.NewInt(licenseUsers) + license.Features.Users = model.NewPointer(licenseUsers) th.App.Srv().SetLicense(license) generateSupportPacket := func(t *testing.T) *model.SupportPacket { @@ -126,7 +126,7 @@ func TestGenerateSupportPacketYaml(t *testing.T) { t.Run("post count should be present if number of users extends AnalyticsSettings.MaxUsersForStatistics", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { - cfg.AnalyticsSettings.MaxUsersForStatistics = model.NewInt(1) + cfg.AnalyticsSettings.MaxUsersForStatistics = model.NewPointer(1) }) for i := 0; i < 5; i++ { diff --git a/server/channels/app/syncables_test.go b/server/channels/app/syncables_test.go index 1075648ae5..66f5e5232c 100644 --- a/server/channels/app/syncables_test.go +++ b/server/channels/app/syncables_test.go @@ -61,9 +61,9 @@ func TestCreateDefaultMemberships(t *testing.T) { } gleeGroup, err := th.App.CreateGroup(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "Glee Club", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) if err != nil { @@ -71,9 +71,9 @@ func TestCreateDefaultMemberships(t *testing.T) { } scienceGroup, err := th.App.CreateGroup(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "Science Club", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) if err != nil { @@ -403,9 +403,9 @@ func TestCreateDefaultMemberships(t *testing.T) { } group1, err := th.App.CreateGroup(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "Group 1", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) if err != nil { @@ -549,14 +549,14 @@ func TestDeleteGroupMemberships(t *testing.T) { // make team group-constrained team := th.BasicTeam - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) team, err = th.App.UpdateTeam(team) require.Nil(t, err) require.True(t, *team.GroupConstrained) // make channel group-constrained channel := th.BasicChannel - channel.GroupConstrained = model.NewBool(true) + channel.GroupConstrained = model.NewPointer(true) channel, err = th.App.UpdateChannel(th.Context, channel) require.Nil(t, err) require.True(t, *channel.GroupConstrained) @@ -603,7 +603,7 @@ func TestSyncSyncableRoles(t *testing.T) { team := th.CreateTeam() channel := th.CreateChannel(th.Context, team) - channel.GroupConstrained = model.NewBool(true) + channel.GroupConstrained = model.NewPointer(true) channel, err := th.App.UpdateChannel(th.Context, channel) require.Nil(t, err) diff --git a/server/channels/app/team_test.go b/server/channels/app/team_test.go index 7062db0553..6653a6b65c 100644 --- a/server/channels/app/team_test.go +++ b/server/channels/app/team_test.go @@ -119,7 +119,7 @@ func TestAddUserToTeam(t *testing.T) { require.NotNil(t, err, "Should not add restricted user") require.Equal(t, "JoinUserToTeam", err.Where, "Error should be JoinUserToTeam") - user = model.User{Email: strings.ToLower(model.NewId()) + "test@invalid.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), AuthService: "notnil", AuthData: model.NewString("notnil")} + user = model.User{Email: strings.ToLower(model.NewId()) + "test@invalid.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), AuthService: "notnil", AuthData: model.NewPointer("notnil")} ruser, err = th.App.CreateUser(th.Context, &user) require.Nil(t, err, "Error creating authservice user: %s", err) defer th.App.PermanentDeleteUser(th.Context, &user) @@ -381,7 +381,7 @@ func TestAddUserToTeamByToken(t *testing.T) { }) t.Run("group-constrained team", func(t *testing.T) { - th.BasicTeam.GroupConstrained = model.NewBool(true) + th.BasicTeam.GroupConstrained = model.NewPointer(true) _, err := th.App.UpdateTeam(th.BasicTeam) require.Nil(t, err, "Should update the team") @@ -395,7 +395,7 @@ func TestAddUserToTeamByToken(t *testing.T) { require.NotNil(t, err, "Should return an error when trying to join a group-constrained team.") require.Equal(t, "app.team.invite_token.group_constrained.error", err.Id) - th.BasicTeam.GroupConstrained = model.NewBool(false) + th.BasicTeam.GroupConstrained = model.NewPointer(false) _, err = th.App.UpdateTeam(th.BasicTeam) require.Nil(t, err, "Should update the team") }) @@ -964,7 +964,7 @@ func TestJoinUserToTeam(t *testing.T) { }) require.Nil(t, err) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewInt(999) }) + th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewPointer(999) }) tm1, appErr := th.App.JoinUserToTeam(th.Context, team, ruser1, "") require.Nil(t, appErr) @@ -1073,7 +1073,7 @@ func TestAppUpdateTeamScheme(t *testing.T) { defer th.TearDown() team := th.BasicTeam - mockID := model.NewString("x") + mockID := model.NewPointer("x") team.SchemeId = mockID updatedTeam, err := th.App.UpdateTeamScheme(th.BasicTeam) diff --git a/server/channels/app/upload.go b/server/channels/app/upload.go index a8083ebf65..0317d60d63 100644 --- a/server/channels/app/upload.go +++ b/server/channels/app/upload.go @@ -273,7 +273,7 @@ func (a *App) UploadData(c request.CTX, us *model.UploadSession, rd io.Reader) ( info.CreatorId = us.UserId info.ChannelId = us.ChannelId info.Path = us.Path - info.RemoteId = model.NewString(us.RemoteId) + info.RemoteId = model.NewPointer(us.RemoteId) if us.ReqFileId != "" { info.Id = us.ReqFileId } diff --git a/server/channels/app/user_test.go b/server/channels/app/user_test.go index aa675040f0..4c8c49304d 100644 --- a/server/channels/app/user_test.go +++ b/server/channels/app/user_test.go @@ -58,14 +58,14 @@ func TestCreateOAuthUser(t *testing.T) { dbUser := th.BasicUser // mock oAuth Provider, return data - mockUser := &model.User{Id: "abcdef", AuthData: model.NewString("e7110007-64be-43d8-9840-4a7e9c26b710"), Email: dbUser.Email} + mockUser := &model.User{Id: "abcdef", AuthData: model.NewPointer("e7110007-64be-43d8-9840-4a7e9c26b710"), Email: dbUser.Email} providerMock := &mocks.OAuthProvider{} providerMock.On("IsSameUser", mock.AnythingOfType("*request.Context"), mock.Anything, mock.Anything).Return(true) providerMock.On("GetUserFromJSON", mock.AnythingOfType("*request.Context"), mock.Anything, mock.Anything).Return(mockUser, nil) einterfaces.RegisterOAuthProvider(model.ServiceOffice365, providerMock) // Update user to be OAuth, formatting to match Office365 OAuth data - s, er2 := th.App.Srv().Store().User().UpdateAuthData(dbUser.Id, model.ServiceOffice365, model.NewString("e711000764be43d898404a7e9c26b710"), "", false) + s, er2 := th.App.Srv().Store().User().UpdateAuthData(dbUser.Id, model.ServiceOffice365, model.NewPointer("e711000764be43d898404a7e9c26b710"), "", false) assert.NoError(t, er2) assert.Equal(t, dbUser.Id, s) @@ -1903,7 +1903,7 @@ func TestPatchUser(t *testing.T) { t.Run("Patch with a username already exists", func(t *testing.T) { _, err := th.App.PatchUser(th.Context, testUser.Id, &model.UserPatch{ - Username: model.NewString(th.BasicUser.Username), + Username: model.NewPointer(th.BasicUser.Username), }, true) require.NotNil(t, err) @@ -1912,7 +1912,7 @@ func TestPatchUser(t *testing.T) { t.Run("Patch with a email already exists", func(t *testing.T) { _, err := th.App.PatchUser(th.Context, testUser.Id, &model.UserPatch{ - Email: model.NewString(th.BasicUser.Email), + Email: model.NewPointer(th.BasicUser.Email), }, true) require.NotNil(t, err) @@ -1921,7 +1921,7 @@ func TestPatchUser(t *testing.T) { t.Run("Patch username with a new username", func(t *testing.T) { u, err := th.App.PatchUser(th.Context, testUser.Id, &model.UserPatch{ - Username: model.NewString(model.NewUsername()), + Username: model.NewPointer(model.NewUsername()), }, true) require.Nil(t, err) diff --git a/server/channels/app/users/password_test.go b/server/channels/app/users/password_test.go index c889e8760e..2aa765483f 100644 --- a/server/channels/app/users/password_test.go +++ b/server/channels/app/users/password_test.go @@ -22,100 +22,100 @@ func TestIsPasswordValidWithSettings(t *testing.T) { "Short": { Password: strings.Repeat("x", 3), Settings: &model.PasswordSettings{ - MinimumLength: model.NewInt(3), - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + MinimumLength: model.NewPointer(3), + Lowercase: model.NewPointer(false), + Uppercase: model.NewPointer(false), + Number: model.NewPointer(false), + Symbol: model.NewPointer(false), }, }, "Long": { Password: strings.Repeat("x", model.PasswordMaximumLength), Settings: &model.PasswordSettings{ - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Lowercase: model.NewPointer(false), + Uppercase: model.NewPointer(false), + Number: model.NewPointer(false), + Symbol: model.NewPointer(false), }, }, "TooShort": { Password: strings.Repeat("x", 2), Settings: &model.PasswordSettings{ - MinimumLength: model.NewInt(3), - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + MinimumLength: model.NewPointer(3), + Lowercase: model.NewPointer(false), + Uppercase: model.NewPointer(false), + Number: model.NewPointer(false), + Symbol: model.NewPointer(false), }, ExpectedError: "model.user.is_valid.pwd_min_length.app_error", }, "TooLong": { Password: strings.Repeat("x", model.PasswordMaximumLength+1), Settings: &model.PasswordSettings{ - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Lowercase: model.NewPointer(false), + Uppercase: model.NewPointer(false), + Number: model.NewPointer(false), + Symbol: model.NewPointer(false), }, ExpectedError: "model.user.is_valid.pwd_max_length.app_error", }, "MissingLower": { Password: "AAAAAAAAAAASD123!@#", Settings: &model.PasswordSettings{ - Lowercase: model.NewBool(true), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Lowercase: model.NewPointer(true), + Uppercase: model.NewPointer(false), + Number: model.NewPointer(false), + Symbol: model.NewPointer(false), }, ExpectedError: "model.user.is_valid.pwd_lowercase.app_error", }, "MissingUpper": { Password: "aaaaaaaaaaaaasd123!@#", Settings: &model.PasswordSettings{ - Uppercase: model.NewBool(true), - Lowercase: model.NewBool(false), - Number: model.NewBool(false), - Symbol: model.NewBool(false), + Uppercase: model.NewPointer(true), + Lowercase: model.NewPointer(false), + Number: model.NewPointer(false), + Symbol: model.NewPointer(false), }, ExpectedError: "model.user.is_valid.pwd_uppercase.app_error", }, "MissingNumber": { Password: "asasdasdsadASD!@#", Settings: &model.PasswordSettings{ - Number: model.NewBool(true), - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Symbol: model.NewBool(false), + Number: model.NewPointer(true), + Lowercase: model.NewPointer(false), + Uppercase: model.NewPointer(false), + Symbol: model.NewPointer(false), }, ExpectedError: "model.user.is_valid.pwd_number.app_error", }, "MissingSymbol": { Password: "asdasdasdasdasdASD123", Settings: &model.PasswordSettings{ - Symbol: model.NewBool(true), - Lowercase: model.NewBool(false), - Uppercase: model.NewBool(false), - Number: model.NewBool(false), + Symbol: model.NewPointer(true), + Lowercase: model.NewPointer(false), + Uppercase: model.NewPointer(false), + Number: model.NewPointer(false), }, ExpectedError: "model.user.is_valid.pwd_symbol.app_error", }, "MissingMultiple": { Password: "asdasdasdasdasdasd", Settings: &model.PasswordSettings{ - Lowercase: model.NewBool(true), - Uppercase: model.NewBool(true), - Number: model.NewBool(true), - Symbol: model.NewBool(true), + Lowercase: model.NewPointer(true), + Uppercase: model.NewPointer(true), + Number: model.NewPointer(true), + Symbol: model.NewPointer(true), }, ExpectedError: "model.user.is_valid.pwd_lowercase_uppercase_number_symbol.app_error", }, "Everything": { Password: "asdASD!@#123", Settings: &model.PasswordSettings{ - Lowercase: model.NewBool(true), - Uppercase: model.NewBool(true), - Number: model.NewBool(true), - Symbol: model.NewBool(true), + Lowercase: model.NewPointer(true), + Uppercase: model.NewPointer(true), + Number: model.NewPointer(true), + Symbol: model.NewPointer(true), }, }, } { diff --git a/server/channels/app/webhook_test.go b/server/channels/app/webhook_test.go index afae9655cf..1bb767207d 100644 --- a/server/channels/app/webhook_test.go +++ b/server/channels/app/webhook_test.go @@ -397,19 +397,19 @@ func TestCreateWebhookPostWithPriority(t *testing.T) { testConditions := []model.PostPriority{ { - Priority: model.NewString("high"), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer("high"), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, { - Priority: model.NewString(""), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(""), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, { - Priority: model.NewString("urgent"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("urgent"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -917,7 +917,7 @@ func TestDoOutgoingWebhookRequest(t *testing.T) { defer th.TearDown() th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewString("127.0.0.1") + cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewPointer("127.0.0.1") *cfg.ServiceSettings.EnableOutgoingWebhooks = true }) @@ -979,7 +979,7 @@ func TestDoOutgoingWebhookRequest(t *testing.T) { defer close(releaseHandler) th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1) + cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1)) }) _, err := th.App.doOutgoingWebhookRequest(server.URL, strings.NewReader(""), "application/json", nil) @@ -996,7 +996,7 @@ func TestDoOutgoingWebhookRequest(t *testing.T) { defer server.Close() th.App.UpdateConfig(func(cfg *model.Config) { - cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(2) + cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(2)) }) resp, err := th.App.doOutgoingWebhookRequest(server.URL, strings.NewReader(""), "application/json", nil) diff --git a/server/channels/jobs/schedulers_test.go b/server/channels/jobs/schedulers_test.go index 076a864422..ddfb5323d9 100644 --- a/server/channels/jobs/schedulers_test.go +++ b/server/channels/jobs/schedulers_test.go @@ -54,10 +54,10 @@ func TestScheduler(t *testing.T) { Cfg: &model.Config{ // mock config DataRetentionSettings: model.DataRetentionSettings{ - EnableMessageDeletion: model.NewBool(true), + EnableMessageDeletion: model.NewPointer(true), }, MessageExportSettings: model.MessageExportSettings{ - EnableExport: model.NewBool(true), + EnableExport: model.NewPointer(true), }, }, }, diff --git a/server/channels/store/localcachelayer/main_test.go b/server/channels/store/localcachelayer/main_test.go index f988710e6e..b3d771e5ce 100644 --- a/server/channels/store/localcachelayer/main_test.go +++ b/server/channels/store/localcachelayer/main_test.go @@ -145,7 +145,7 @@ func getMockStore(t *testing.T) *mocks.Store { fakeUser := []*model.User{{ Id: "123", - AuthData: model.NewString("authData"), + AuthData: model.NewPointer("authData"), AuthService: "authService", }} mockUserStore := mocks.UserStore{} @@ -164,7 +164,7 @@ func getMockStore(t *testing.T) *mocks.Store { fakeUser[0], { Id: "456", - AuthData: model.NewString("authData"), + AuthData: model.NewPointer("authData"), AuthService: "authService", }, } diff --git a/server/channels/store/localcachelayer/user_layer_test.go b/server/channels/store/localcachelayer/user_layer_test.go index ca323542aa..5c14e47550 100644 --- a/server/channels/store/localcachelayer/user_layer_test.go +++ b/server/channels/store/localcachelayer/user_layer_test.go @@ -25,7 +25,7 @@ func TestUserStoreCache(t *testing.T) { fakeUserIds := []string{"123"} fakeUser := []*model.User{{ Id: "123", - AuthData: model.NewString("authData"), + AuthData: model.NewPointer("authData"), AuthService: "authService", }} @@ -231,7 +231,7 @@ func TestUserStoreGetCache(t *testing.T) { fakeUserId := "123" fakeUser := &model.User{ Id: "123", - AuthData: model.NewString("authData"), + AuthData: model.NewPointer("authData"), AuthService: "authService", } t.Run("first call not cached, second cached and returning same data", func(t *testing.T) { @@ -301,12 +301,12 @@ func TestUserStoreGetCache(t *testing.T) { func TestUserStoreGetManyCache(t *testing.T) { fakeUser := &model.User{ Id: "123", - AuthData: model.NewString("authData"), + AuthData: model.NewPointer("authData"), AuthService: "authService", } otherFakeUser := &model.User{ Id: "456", - AuthData: model.NewString("authData"), + AuthData: model.NewPointer("authData"), AuthService: "authService", } t.Run("first call not cached, second cached and returning same data", func(t *testing.T) { diff --git a/server/channels/store/searchlayer/layer_test.go b/server/channels/store/searchlayer/layer_test.go index 74c5153c81..fa0a1b0b78 100644 --- a/server/channels/store/searchlayer/layer_test.go +++ b/server/channels/store/searchlayer/layer_test.go @@ -33,7 +33,7 @@ func TestUpdateConfigRace(t *testing.T) { cfg := &model.Config{} cfg.SetDefaults() - cfg.ClusterSettings.GossipPort = model.NewInt(9999) + cfg.ClusterSettings.GossipPort = model.NewPointer(9999) searchEngine := searchengine.NewBroker(cfg) layer := searchlayer.NewSearchLayer(&testlib.TestStore{Store: store}, searchEngine, cfg) var wg sync.WaitGroup diff --git a/server/channels/store/sqlstore/channel_member_history_store.go b/server/channels/store/sqlstore/channel_member_history_store.go index f17d935518..7d877e6c5e 100644 --- a/server/channels/store/sqlstore/channel_member_history_store.go +++ b/server/channels/store/sqlstore/channel_member_history_store.go @@ -153,7 +153,7 @@ func (s SqlChannelMemberHistoryStore) getFromChannelMembersTable(startTime int64 // we have to fill in the join/leave times, because that data doesn't exist in the channel members table for _, channelMemberHistory := range histories { channelMemberHistory.JoinTime = startTime - channelMemberHistory.LeaveTime = model.NewInt64(endTime) + channelMemberHistory.LeaveTime = model.NewPointer(endTime) } return histories, nil } diff --git a/server/channels/store/sqlstore/channel_store.go b/server/channels/store/sqlstore/channel_store.go index fc87d3005b..805406ddad 100644 --- a/server/channels/store/sqlstore/channel_store.go +++ b/server/channels/store/sqlstore/channel_store.go @@ -593,7 +593,7 @@ func (s SqlChannelStore) CreateDirectChannel(rctx request.CTX, user *model.User, channel.Header = "" channel.Type = model.ChannelTypeDirect - channel.Shared = model.NewBool(user.IsRemote() || otherUser.IsRemote()) + channel.Shared = model.NewPointer(user.IsRemote() || otherUser.IsRemote()) channel.CreatorId = user.Id cm1 := &model.ChannelMember{ diff --git a/server/channels/store/sqlstore/group_store.go b/server/channels/store/sqlstore/group_store.go index 4286bd6eb4..ac4c5ae565 100644 --- a/server/channels/store/sqlstore/group_store.go +++ b/server/channels/store/sqlstore/group_store.go @@ -1157,7 +1157,7 @@ type groupWithSchemeAdmin struct { func (g groupWithSchemeAdmin) ToModel() *model.GroupWithSchemeAdmin { if g.SyncableSchemeAdmin == nil { - g.SyncableSchemeAdmin = model.NewBool(false) + g.SyncableSchemeAdmin = model.NewPointer(false) } res := &model.GroupWithSchemeAdmin{ Group: *g.group.ToModel(), diff --git a/server/channels/store/sqlstore/integrity_test.go b/server/channels/store/sqlstore/integrity_test.go index beb7967213..63f3ffb68c 100644 --- a/server/channels/store/sqlstore/integrity_test.go +++ b/server/channels/store/sqlstore/integrity_test.go @@ -856,7 +856,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) { ChildId: &channel.Id, }, data.Records[0]) require.Equal(t, model.OrphanedRecord{ - ParentId: model.NewString("test"), + ParentId: model.NewPointer("test"), ChildId: &direct.Id, }, data.Records[1]) dbmap.Exec(`DELETE FROM Channels WHERE Id=?`, channel.Id) diff --git a/server/channels/store/sqlstore/post_store.go b/server/channels/store/sqlstore/post_store.go index 519c09d527..c543487ebe 100644 --- a/server/channels/store/sqlstore/post_store.go +++ b/server/channels/store/sqlstore/post_store.go @@ -1156,7 +1156,7 @@ func (s *SqlPostStore) prepareThreadedResponse(posts []*postWithExtra, extended, processPost := func(p *postWithExtra) error { p.Post.ReplyCount = p.ThreadReplyCount if p.IsFollowing != nil { - p.Post.IsFollowing = model.NewBool(*p.IsFollowing) + p.Post.IsFollowing = model.NewPointer(*p.IsFollowing) } for _, userID := range p.ThreadParticipants { participant, ok := usersMap[userID] diff --git a/server/channels/store/sqlstore/retention_policy_store.go b/server/channels/store/sqlstore/retention_policy_store.go index b10a87f221..7b643bd4da 100644 --- a/server/channels/store/sqlstore/retention_policy_store.go +++ b/server/channels/store/sqlstore/retention_policy_store.go @@ -462,7 +462,7 @@ func (s *SqlRetentionPolicyStore) GetChannels(policyId string, offset, limit int } for _, channel := range channels { - channel.PolicyID = model.NewString(policyId) + channel.PolicyID = model.NewPointer(policyId) } return channels, nil diff --git a/server/channels/store/sqlstore/store_test.go b/server/channels/store/sqlstore/store_test.go index 8cd45490be..ef739394c2 100644 --- a/server/channels/store/sqlstore/store_test.go +++ b/server/channels/store/sqlstore/store_test.go @@ -537,8 +537,8 @@ func TestIsBinaryParamEnabled(t *testing.T) { { store: SqlStore{ settings: &model.SqlSettings{ - DriverName: model.NewString(model.DatabaseDriverPostgres), - DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"), + DriverName: model.NewPointer(model.DatabaseDriverPostgres), + DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"), }, }, expected: true, @@ -546,8 +546,8 @@ func TestIsBinaryParamEnabled(t *testing.T) { { store: SqlStore{ settings: &model.SqlSettings{ - DriverName: model.NewString(model.DatabaseDriverMysql), - DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"), + DriverName: model.NewPointer(model.DatabaseDriverMysql), + DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"), }, }, expected: false, @@ -555,8 +555,8 @@ func TestIsBinaryParamEnabled(t *testing.T) { { store: SqlStore{ settings: &model.SqlSettings{ - DriverName: model.NewString(model.DatabaseDriverPostgres), - DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable&binary_parameters=yes"), + DriverName: model.NewPointer(model.DatabaseDriverPostgres), + DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable&binary_parameters=yes"), }, }, expected: true, @@ -564,8 +564,8 @@ func TestIsBinaryParamEnabled(t *testing.T) { { store: SqlStore{ settings: &model.SqlSettings{ - DriverName: model.NewString(model.DatabaseDriverPostgres), - DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable"), + DriverName: model.NewPointer(model.DatabaseDriverPostgres), + DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable"), }, }, expected: false, @@ -760,9 +760,9 @@ func TestReplicaLagQuery(t *testing.T) { } settings.ReplicaLagSettings = []*model.ReplicaLagSettings{{ - DataSource: model.NewString(*settings.DataSource), - QueryAbsoluteLag: model.NewString(query), - QueryTimeLag: model.NewString(query), + DataSource: model.NewPointer(*settings.DataSource), + QueryAbsoluteLag: model.NewPointer(query), + QueryTimeLag: model.NewPointer(query), }} mockMetrics := &mocks.MetricsInterface{} diff --git a/server/channels/store/sqlstore/team_store.go b/server/channels/store/sqlstore/team_store.go index f3da855233..92674434c1 100644 --- a/server/channels/store/sqlstore/team_store.go +++ b/server/channels/store/sqlstore/team_store.go @@ -546,16 +546,16 @@ func (s SqlTeamStore) SearchAllPaged(opts *model.TeamSearch) ([]*model.Team, int // SearchOpen returns from the database a list of public teams that match the Name or DisplayName // passed as the term search parameter. func (s SqlTeamStore) SearchOpen(opts *model.TeamSearch) ([]*model.Team, error) { - opts.TeamType = model.NewString("O") - opts.AllowOpenInvite = model.NewBool(true) + opts.TeamType = model.NewPointer("O") + opts.AllowOpenInvite = model.NewPointer(true) return s.SearchAll(opts) } // SearchPrivate returns from the database a list of private teams that match the Name or DisplayName // passed as the term search parameter. func (s SqlTeamStore) SearchPrivate(opts *model.TeamSearch) ([]*model.Team, error) { - opts.TeamType = model.NewString("O") - opts.AllowOpenInvite = model.NewBool(false) + opts.TeamType = model.NewPointer("O") + opts.AllowOpenInvite = model.NewPointer(false) return s.SearchAll(opts) } diff --git a/server/channels/store/storetest/channel_member_history_store.go b/server/channels/store/storetest/channel_member_history_store.go index 628d2a156c..4d9f7dec66 100644 --- a/server/channels/store/storetest/channel_member_history_store.go +++ b/server/channels/store/storetest/channel_member_history_store.go @@ -377,7 +377,7 @@ func testPermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx request.CTX channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{channel.Id}, }) diff --git a/server/channels/store/storetest/channel_store.go b/server/channels/store/storetest/channel_store.go index 446177b866..8f86b29426 100644 --- a/server/channels/store/storetest/channel_store.go +++ b/server/channels/store/storetest/channel_store.go @@ -3858,10 +3858,10 @@ func testChannelStoreGetAllChannels(t *testing.T, rctx request.CTX, ss store.Sto require.NoError(t, nErr) group := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, err = ss.Group().Create(group) require.NoError(t, err) @@ -3949,7 +3949,7 @@ func testChannelStoreGetAllChannels(t *testing.T, rctx request.CTX, ss store.Sto policy, nErr := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{c1.Id}, }) @@ -4768,9 +4768,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) { CreateAt: 1000, Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(false), }, }, }) @@ -4782,9 +4782,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) { CreateAt: 1001, Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(false), }, }, }) @@ -4803,9 +4803,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) { CreateAt: 1003, Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(false), }, }, }) @@ -5215,10 +5215,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store) var memberCounts []*model.ChannelMemberCountByGroup teamId := model.NewId() g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, err := ss.Group().Create(g1) require.NoError(t, err) @@ -5287,10 +5287,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store) }) g2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, err = ss.Group().Create(g2) require.NoError(t, err) @@ -5326,10 +5326,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store) } g3 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, err = ss.Group().Create(g3) @@ -6379,7 +6379,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store. DisplayName: "A5 ChannelC", Name: NewTestId(), Type: model.ChannelTypePrivate, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } _, nErr = ss.Channel().Save(rctx, &o5, -1) require.NoError(t, nErr) @@ -6403,10 +6403,10 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store. require.NoError(t, nErr) group := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, err = ss.Group().Create(group) require.NoError(t, err) @@ -6486,7 +6486,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store. _, nErr = ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{o14.Id}, }) @@ -6518,24 +6518,24 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store. {"exclude defaults search 'off'", "off-", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeChannelNames: []string{"off-topic"}}, model.ChannelList{&o7, &o8}, 0}, {"exclude defaults search 'town'", "town", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeChannelNames: []string{"town-square"}}, model.ChannelList{}, 0}, {"exclude by group association", "off-", store.ChannelSearchOpts{IncludeDeleted: false, NotAssociatedToGroup: group.Id}, model.ChannelList{&o6, &o8}, 0}, - {"paginate includes count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewInt(100)}, model.ChannelList{&o6, &o7, &o8}, 3}, - {"paginate, page 2 correct entries and count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewInt(2), Page: model.NewInt(1)}, model.ChannelList{&o8}, 3}, + {"paginate includes count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewPointer(100)}, model.ChannelList{&o6, &o7, &o8}, 3}, + {"paginate, page 2 correct entries and count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewPointer(2), Page: model.NewPointer(1)}, model.ChannelList{&o8}, 3}, {"Filter private", "", store.ChannelSearchOpts{IncludeDeleted: false, Private: true}, model.ChannelList{&o4, &o5, &o8}, 3}, - {"Filter public", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o6, &o7}, 10}, - {"Filter public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13}, - {"Filter public and private and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 14}, - {"Filter group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, GroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o5}, 1}, - {"Filter exclude group constrained and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, ExcludeGroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 13}, - {"Filter private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeGroupConstrained: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o4, &o8}, 2}, + {"Filter public", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o6, &o7}, 10}, + {"Filter public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13}, + {"Filter public and private and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 14}, + {"Filter group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, GroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o5}, 1}, + {"Filter exclude group constrained and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, ExcludeGroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 13}, + {"Filter private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeGroupConstrained: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o4, &o8}, 2}, {"Exclude policy constrained", "", store.ChannelSearchOpts{ExcludePolicyConstrained: true}, model.ChannelList{&o1, &o2, &o3, &o4, &o5, &o6, &o7, &o8, &o9, &o10, &o11, &o12}, 0}, - {"Filter team 2", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o2, &o14}, 2}, - {"Filter team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{}, 0}, - {"Filter team 1 and team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o4, &o5, &o8}, 3}, - {"Filter team 1 and team 2, public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13}, - {"Filter team 1 and team 2, public and private and group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, GroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o5}, 1}, - {"Filter team 1 and team 2, public and private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, ExcludeGroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 12}, - {"Filter deleted returns only deleted channels", "", store.ChannelSearchOpts{Deleted: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o13}, 1}, - {"Search ChannelA by id", o1.Id, store.ChannelSearchOpts{IncludeDeleted: false, Page: model.NewInt(0), PerPage: model.NewInt(5), IncludeSearchById: true}, model.ChannelList{&o1}, 1}, + {"Filter team 2", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o2, &o14}, 2}, + {"Filter team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{}, 0}, + {"Filter team 1 and team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o4, &o5, &o8}, 3}, + {"Filter team 1 and team 2, public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13}, + {"Filter team 1 and team 2, public and private and group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, GroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o5}, 1}, + {"Filter team 1 and team 2, public and private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, ExcludeGroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 12}, + {"Filter deleted returns only deleted channels", "", store.ChannelSearchOpts{Deleted: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o13}, 1}, + {"Search ChannelA by id", o1.Id, store.ChannelSearchOpts{IncludeDeleted: false, Page: model.NewPointer(0), PerPage: model.NewPointer(5), IncludeSearchById: true}, model.ChannelList{&o1}, 1}, } for _, testCase := range testCases { @@ -7929,7 +7929,7 @@ func testGroupSyncedChannelCount(t *testing.T, rctx request.CTX, ss store.Store) DisplayName: model.NewId(), Name: model.NewId(), Type: model.ChannelTypePrivate, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), }, 999) require.NoError(t, nErr) require.True(t, channel1.IsGroupConstrained()) @@ -7948,7 +7948,7 @@ func testGroupSyncedChannelCount(t *testing.T, rctx request.CTX, ss store.Store) require.NoError(t, err) require.GreaterOrEqual(t, count, int64(1)) - channel2.GroupConstrained = model.NewBool(true) + channel2.GroupConstrained = model.NewPointer(true) channel2, err = ss.Channel().Update(rctx, channel2) require.NoError(t, err) require.True(t, channel2.IsGroupConstrained()) diff --git a/server/channels/store/storetest/group_store.go b/server/channels/store/storetest/group_store.go index 491ddc5fce..8bb0d465f0 100644 --- a/server/channels/store/storetest/group_store.go +++ b/server/channels/store/storetest/group_store.go @@ -100,11 +100,11 @@ func TestGroupStore(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupStoreCreate(t *testing.T, rctx request.CTX, ss store.Store) { // Save a new group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } // Happy path @@ -121,10 +121,10 @@ func testGroupStoreCreate(t *testing.T, rctx request.CTX, ss store.Store) { // Requires display name g2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "", Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } data, err := ss.Group().Create(g2) require.Nil(t, data) @@ -135,10 +135,10 @@ func testGroupStoreCreate(t *testing.T, rctx request.CTX, ss store.Store) { // Won't accept a duplicate name g4 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } _, err = ss.Group().Create(g4) require.NoError(t, err) @@ -146,7 +146,7 @@ func testGroupStoreCreate(t *testing.T, rctx request.CTX, ss store.Store) { Name: g4.Name, DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } data, err = ss.Group().Create(g4b) require.Nil(t, data) @@ -155,17 +155,17 @@ func testGroupStoreCreate(t *testing.T, rctx request.CTX, ss store.Store) { // Fields cannot be greater than max values g5 := &model.Group{ - Name: model.NewString(strings.Repeat("x", model.GroupNameMaxLength)), + Name: model.NewPointer(strings.Repeat("x", model.GroupNameMaxLength)), DisplayName: strings.Repeat("x", model.GroupDisplayNameMaxLength), Description: strings.Repeat("x", model.GroupDescriptionMaxLength), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } require.Nil(t, g5.IsValidForCreate()) - g5.Name = model.NewString(*g5.Name + "x") + g5.Name = model.NewPointer(*g5.Name + "x") require.Equal(t, g5.IsValidForCreate().Id, "model.group.name.invalid_length.app_error") - g5.Name = model.NewString(model.NewId()) + g5.Name = model.NewPointer(model.NewId()) require.Nil(t, g5.IsValidForCreate()) g5.DisplayName = g5.DisplayName + "x" @@ -180,21 +180,21 @@ func testGroupStoreCreate(t *testing.T, rctx request.CTX, ss store.Store) { // Must use a valid type g6 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSource("fake"), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } require.Equal(t, g6.IsValidForCreate().Id, "model.group.source.app_error") //must use valid characters g7 := &model.Group{ - Name: model.NewString("%^#@$$"), + Name: model.NewPointer("%^#@$$"), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } require.Equal(t, g7.IsValidForCreate().Id, "model.group.name.invalid_chars.app_error") } @@ -217,11 +217,11 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) require.NoError(t, nErr) g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceCustom, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } // Save a new group @@ -241,16 +241,16 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) require.NotZero(t, d1.CreateAt) require.NotZero(t, d1.UpdateAt) require.Zero(t, d1.DeleteAt) - require.Equal(t, *model.NewInt64(2), int64(*d1.MemberCount)) + require.Equal(t, *model.NewPointer(2), *d1.MemberCount) // Requires display name g2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "", Source: model.GroupSourceCustom, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids2 := &model.GroupWithUserIds{ @@ -266,10 +266,10 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) // Won't accept a duplicate name g4 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceCustom, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids4 := &model.GroupWithUserIds{ Group: *g4, @@ -281,7 +281,7 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) Name: g4.Name, DisplayName: model.NewId(), Source: model.GroupSourceCustom, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids4b := &model.GroupWithUserIds{ Group: *g4b, @@ -294,20 +294,20 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) // Fields cannot be greater than max values g5 := &model.Group{ - Name: model.NewString(strings.Repeat("x", model.GroupNameMaxLength)), + Name: model.NewPointer(strings.Repeat("x", model.GroupNameMaxLength)), DisplayName: strings.Repeat("x", model.GroupDisplayNameMaxLength), Description: strings.Repeat("x", model.GroupDescriptionMaxLength), Source: model.GroupSourceCustom, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids5 := &model.GroupWithUserIds{ Group: *g5, } require.Nil(t, guids5.IsValidForCreate()) - guids5.Name = model.NewString(*guids5.Name + "x") + guids5.Name = model.NewPointer(*guids5.Name + "x") require.Equal(t, guids5.IsValidForCreate().Id, "model.group.name.invalid_length.app_error") - guids5.Name = model.NewString(model.NewId()) + guids5.Name = model.NewPointer(model.NewId()) require.Nil(t, guids5.IsValidForCreate()) guids5.DisplayName = guids5.DisplayName + "x" @@ -322,11 +322,11 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) // Must use a valid type g6 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSource("fake"), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids6 := &model.GroupWithUserIds{ Group: *g6, @@ -335,11 +335,11 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) //must use valid characters g7 := &model.Group{ - Name: model.NewString("%^#@$$"), + Name: model.NewPointer("%^#@$$"), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceCustom, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids7 := &model.GroupWithUserIds{ Group: *g7, @@ -348,11 +348,11 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) // Invalid user ids g8 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceCustom, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids8 := &model.GroupWithUserIds{ Group: *g8, @@ -367,11 +367,11 @@ func testGroupCreateWithUserIds(t *testing.T, rctx request.CTX, ss store.Store) func testGroupStoreGet(t *testing.T, rctx request.CTX, ss store.Store) { // Create a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } d1, err := ss.Group().Create(g1) require.NoError(t, err) @@ -399,11 +399,11 @@ func testGroupStoreGet(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupStoreGetByName(t *testing.T, rctx request.CTX, ss store.Store) { // Create a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } g1Opts := model.GroupSearchOpts{ FilterAllowReference: false, @@ -438,11 +438,11 @@ func testGroupStoreGetByIDs(t *testing.T, rctx request.CTX, ss store.Store) { for i := 0; i < 2; i++ { group := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(group) require.NoError(t, err) @@ -468,11 +468,11 @@ func testGroupStoreGetByIDs(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupStoreGetByRemoteID(t *testing.T, rctx request.CTX, ss store.Store) { // Create a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } d1, err := ss.Group().Create(g1) require.NoError(t, err) @@ -505,11 +505,11 @@ func testGroupStoreGetAllByType(t *testing.T, rctx request.CTX, ss store.Store) // Create groups for i := 0; i < numGroups; i++ { g := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } groups = append(groups, g) _, err := ss.Group().Create(g) @@ -535,21 +535,21 @@ func testGroupStoreGetAllByType(t *testing.T, rctx request.CTX, ss store.Store) func testGroupStoreGetByUser(t *testing.T, rctx request.CTX, ss store.Store) { // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } g1, err := ss.Group().Create(g1) require.NoError(t, err) g2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } g2, err = ss.Group().Create(g2) require.NoError(t, err) @@ -605,11 +605,11 @@ func testGroupStoreGetByUser(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) { // Save a new group g1 := &model.Group{ - Name: model.NewString("g1-test"), + Name: model.NewPointer("g1-test"), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } // Create a group @@ -619,10 +619,10 @@ func testGroupStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) { // Update happy path g1Update := &model.Group{} *g1Update = *g1 - g1Update.Name = model.NewString(model.NewId()) + g1Update.Name = model.NewPointer(model.NewId()) g1Update.DisplayName = model.NewId() g1Update.Description = model.NewId() - g1Update.RemoteId = model.NewString(model.NewId()) + g1Update.RemoteId = model.NewPointer(model.NewId()) ud1, err := ss.Group().Update(g1Update) require.NoError(t, err) @@ -641,10 +641,10 @@ func testGroupStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) { // Requires display name data, err := ss.Group().Update(&model.Group{ Id: d1.Id, - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "", Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.Nil(t, data) require.Error(t, err) @@ -654,11 +654,11 @@ func testGroupStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) { // Create another Group g2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } d2, err := ss.Group().Create(g2) require.NoError(t, err) @@ -670,7 +670,7 @@ func testGroupStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) { DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.Error(t, err) require.Contains(t, err.Error(), "unique constraint: Name") @@ -698,11 +698,11 @@ func testGroupStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupStoreDelete(t *testing.T, rctx request.CTX, ss store.Store) { // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } d1, err := ss.Group().Create(g1) @@ -747,11 +747,11 @@ func testGroupStoreDelete(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupStoreRestore(t *testing.T, rctx request.CTX, ss store.Store) { // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } d1, err := ss.Group().Create(g1) @@ -800,11 +800,11 @@ func testGroupStoreRestore(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupGetMemberUsers(t *testing.T, rctx request.CTX, ss store.Store) { // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -852,11 +852,11 @@ func testGroupGetMemberUsers(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupGetMemberUsersPage(t *testing.T, rctx request.CTX, ss store.Store) { // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -926,11 +926,11 @@ func testGroupGetMemberUsersPage(t *testing.T, rctx request.CTX, ss store.Store) func testGroupGetMemberUsersSortedPage(t *testing.T, rctx request.CTX, ss store.Store) { // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1019,11 +1019,11 @@ func testGroupGetMemberUsersInTeam(t *testing.T, rctx request.CTX, ss store.Stor // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1105,11 +1105,11 @@ func testGroupGetMemberUsersNotInChannel(t *testing.T, rctx request.CTX, ss stor // Save a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1232,10 +1232,10 @@ func testGroupGetMemberUsersNotInChannel(t *testing.T, rctx request.CTX, ss stor func testUpsertMember(t *testing.T, rctx request.CTX, ss store.Store) { // Create group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1293,10 +1293,10 @@ func testUpsertMember(t *testing.T, rctx request.CTX, ss store.Store) { func testUpsertMembers(t *testing.T, rctx request.CTX, ss store.Store) { // Create group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1359,10 +1359,10 @@ func testUpsertMembers(t *testing.T, rctx request.CTX, ss store.Store) { func testGroupDeleteMember(t *testing.T, rctx request.CTX, ss store.Store) { // Create group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1411,10 +1411,10 @@ func testGroupDeleteMembers(t *testing.T, rctx request.CTX, ss store.Store) { require.NoError(t, nErr) // Create group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } guids := &model.GroupWithUserIds{ Group: *g1, @@ -1451,10 +1451,10 @@ func testGroupPermanentDeleteMembersByUser(t *testing.T, rctx request.CTX, ss st for i := 0; i < numberOfGroups; i++ { g = &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g) groups = append(groups, group) @@ -1489,10 +1489,10 @@ func testCreateGroupSyncable(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1525,11 +1525,11 @@ func testCreateGroupSyncable(t *testing.T, rctx request.CTX, ss store.Store) { func testGetGroupSyncable(t *testing.T, rctx request.CTX, ss store.Store) { // Create a group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1569,11 +1569,11 @@ func testGetAllGroupSyncablesByGroup(t *testing.T, rctx request.CTX, ss store.St // Create group g := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g) require.NoError(t, err) @@ -1626,10 +1626,10 @@ func testGetAllGroupSyncablesByGroup(t *testing.T, rctx request.CTX, ss store.St func testUpdateGroupSyncable(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1694,10 +1694,10 @@ func testUpdateGroupSyncable(t *testing.T, rctx request.CTX, ss store.Store) { func testDeleteGroupSyncable(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -1750,9 +1750,9 @@ func testDeleteGroupSyncable(t *testing.T, rctx request.CTX, ss store.Store) { func testTeamMembersToAdd(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group group, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "TeamMembersToAdd Test Group", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) require.NoError(t, err) @@ -1928,17 +1928,17 @@ func testTeamMembersToAdd(t *testing.T, rctx request.CTX, ss store.Store) { func testTeamMembersToAddSingleTeam(t *testing.T, rctx request.CTX, ss store.Store) { group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "TeamMembersToAdd Test Group", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) require.NoError(t, err) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "TeamMembersToAdd Test Group", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) require.NoError(t, err) @@ -2019,9 +2019,9 @@ func testTeamMembersToAddSingleTeam(t *testing.T, rctx request.CTX, ss store.Sto func testChannelMembersToAdd(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group group, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "ChannelMembersToAdd Test Group", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) require.NoError(t, err) @@ -2195,17 +2195,17 @@ func testChannelMembersToAdd(t *testing.T, rctx request.CTX, ss store.Store) { func testChannelMembersToAddSingleChannel(t *testing.T, rctx request.CTX, ss store.Store) { group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "TeamMembersToAdd Test Group", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) require.NoError(t, err) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "TeamMembersToAdd Test Group", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) require.NoError(t, err) @@ -2379,7 +2379,7 @@ func testTeamMembersToRemoveSingleTeam(t *testing.T, rctx request.CTX, ss store. Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TeamOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } team1, nErr := ss.Team().Save(team1) require.NoError(t, nErr) @@ -2393,7 +2393,7 @@ func testTeamMembersToRemoveSingleTeam(t *testing.T, rctx request.CTX, ss store. Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TeamOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } team2, nErr = ss.Team().Save(team2) require.NoError(t, nErr) @@ -2526,7 +2526,7 @@ func testChannelMembersToRemoveSingleChannel(t *testing.T, rctx request.CTX, ss DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Type: model.ChannelTypeOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } channel1, nErr := ss.Channel().Save(rctx, channel1, 999) require.NoError(t, nErr) @@ -2535,7 +2535,7 @@ func testChannelMembersToRemoveSingleChannel(t *testing.T, rctx request.CTX, ss DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Type: model.ChannelTypeOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } channel2, nErr = ss.Channel().Save(rctx, channel2, 999) require.NoError(t, nErr) @@ -2583,9 +2583,9 @@ type removalsData struct { func pendingMemberRemovalsDataSetup(t *testing.T, rctx request.CTX, ss store.Store) *removalsData { // create group group, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "Pending[Channel|Team]MemberRemovals Test Group", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, }) require.NoError(t, err) @@ -2628,7 +2628,7 @@ func pendingMemberRemovalsDataSetup(t *testing.T, rctx request.CTX, ss store.Sto DisplayName: "A Name", Name: model.NewId(), Type: model.ChannelTypePrivate, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } channelConstrained, nErr = ss.Channel().Save(rctx, channelConstrained, 9999) require.NoError(t, nErr) @@ -2652,7 +2652,7 @@ func pendingMemberRemovalsDataSetup(t *testing.T, rctx request.CTX, ss store.Sto Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TeamInvite, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } teamConstrained, nErr = ss.Team().Save(teamConstrained) require.NoError(t, nErr) @@ -2746,27 +2746,27 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { // Create Groups 1, 2 and a deleted group group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-1", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) require.NoError(t, err) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-2", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: false, }) require.NoError(t, err) deletedGroup, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-deleted", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, DeleteAt: 1, @@ -2796,9 +2796,9 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group3 group3, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-3", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) @@ -2839,14 +2839,14 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { require.NoError(t, err) group1WithMemberCount := *group1 - group1WithMemberCount.MemberCount = model.NewInt(1) + group1WithMemberCount.MemberCount = model.NewPointer(1) group2WithMemberCount := *group2 - group2WithMemberCount.MemberCount = model.NewInt(0) + group2WithMemberCount.MemberCount = model.NewPointer(0) - group1WSA := &model.GroupWithSchemeAdmin{Group: *group1, SchemeAdmin: model.NewBool(false)} - group2WSA := &model.GroupWithSchemeAdmin{Group: *group2, SchemeAdmin: model.NewBool(false)} - group3WSA := &model.GroupWithSchemeAdmin{Group: *group3, SchemeAdmin: model.NewBool(false)} + group1WSA := &model.GroupWithSchemeAdmin{Group: *group1, SchemeAdmin: model.NewPointer(false)} + group2WSA := &model.GroupWithSchemeAdmin{Group: *group2, SchemeAdmin: model.NewPointer(false)} + group3WSA := &model.GroupWithSchemeAdmin{Group: *group3, SchemeAdmin: model.NewPointer(false)} testCases := []struct { Name string @@ -2864,7 +2864,7 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 60, Result: []*model.GroupWithSchemeAdmin{group1WSA, group2WSA}, - TotalCount: model.NewInt64(2), + TotalCount: model.NewPointer(int64(2)), }, { Name: "Get first Group for Channel1 with page 0 with 1 element", @@ -2897,7 +2897,7 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 60, Result: []*model.GroupWithSchemeAdmin{}, - TotalCount: model.NewInt64(0), + TotalCount: model.NewPointer(int64(0)), }, { Name: "Get group matching name", @@ -2906,7 +2906,7 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 100, Result: []*model.GroupWithSchemeAdmin{group1WSA}, - TotalCount: model.NewInt64(1), + TotalCount: model.NewPointer(int64(1)), }, { Name: "Get group matching display name", @@ -2915,7 +2915,7 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 100, Result: []*model.GroupWithSchemeAdmin{group1WSA}, - TotalCount: model.NewInt64(1), + TotalCount: model.NewPointer(int64(1)), }, { Name: "Get group matching multiple display names", @@ -2924,7 +2924,7 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 100, Result: []*model.GroupWithSchemeAdmin{group1WSA, group2WSA}, - TotalCount: model.NewInt64(2), + TotalCount: model.NewPointer(int64(2)), }, { Name: "Include member counts", @@ -2933,8 +2933,8 @@ func testGetGroupsByChannel(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 2, Result: []*model.GroupWithSchemeAdmin{ - {Group: group1WithMemberCount, SchemeAdmin: model.NewBool(false)}, - {Group: group2WithMemberCount, SchemeAdmin: model.NewBool(false)}, + {Group: group1WithMemberCount, SchemeAdmin: model.NewPointer(false)}, + {Group: group2WithMemberCount, SchemeAdmin: model.NewPointer(false)}, }, }, { @@ -2994,27 +2994,27 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, rctx request.CTX, ss // Create Groups 1, 2 and a deleted group group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-1", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: false, }) require.NoError(t, err) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-2", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) require.NoError(t, err) deletedGroup, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-deleted", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, DeleteAt: 1, @@ -3044,9 +3044,9 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, rctx request.CTX, ss // Create Group3 group3, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-3", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) @@ -3087,17 +3087,17 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, rctx request.CTX, ss require.NoError(t, err) group1WithMemberCount := *group1 - group1WithMemberCount.MemberCount = model.NewInt(1) + group1WithMemberCount.MemberCount = model.NewPointer(1) group2WithMemberCount := *group2 - group2WithMemberCount.MemberCount = model.NewInt(0) + group2WithMemberCount.MemberCount = model.NewPointer(0) group3WithMemberCount := *group3 - group3WithMemberCount.MemberCount = model.NewInt(0) + group3WithMemberCount.MemberCount = model.NewPointer(0) - group1WSA := &model.GroupWithSchemeAdmin{Group: *group1, SchemeAdmin: model.NewBool(false)} - group2WSA := &model.GroupWithSchemeAdmin{Group: *group2, SchemeAdmin: model.NewBool(false)} - group3WSA := &model.GroupWithSchemeAdmin{Group: *group3, SchemeAdmin: model.NewBool(false)} + group1WSA := &model.GroupWithSchemeAdmin{Group: *group1, SchemeAdmin: model.NewPointer(false)} + group2WSA := &model.GroupWithSchemeAdmin{Group: *group2, SchemeAdmin: model.NewPointer(false)} + group3WSA := &model.GroupWithSchemeAdmin{Group: *group3, SchemeAdmin: model.NewPointer(false)} testCases := []struct { Name string @@ -3171,11 +3171,11 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, rctx request.CTX, ss PerPage: 10, Result: map[string][]*model.GroupWithSchemeAdmin{ channel1.Id: { - {Group: group1WithMemberCount, SchemeAdmin: model.NewBool(false)}, - {Group: group2WithMemberCount, SchemeAdmin: model.NewBool(false)}, + {Group: group1WithMemberCount, SchemeAdmin: model.NewPointer(false)}, + {Group: group2WithMemberCount, SchemeAdmin: model.NewPointer(false)}, }, channel2.Id: { - {Group: group3WithMemberCount, SchemeAdmin: model.NewBool(false)}, + {Group: group3WithMemberCount, SchemeAdmin: model.NewPointer(false)}, }, }, }, @@ -3227,27 +3227,27 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { // Create Groups 1, 2 and a deleted group group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-1", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: false, }) require.NoError(t, err) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-2", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) require.NoError(t, err) deletedGroup, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-deleted", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, DeleteAt: 1, @@ -3281,9 +3281,9 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group3 group3, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-3", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) @@ -3327,14 +3327,14 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { require.NoError(t, err) group1WithMemberCount := *group1 - group1WithMemberCount.MemberCount = model.NewInt(1) + group1WithMemberCount.MemberCount = model.NewPointer(1) group2WithMemberCount := *group2 - group2WithMemberCount.MemberCount = model.NewInt(0) + group2WithMemberCount.MemberCount = model.NewPointer(0) - group1WSA := &model.GroupWithSchemeAdmin{Group: *group1, SchemeAdmin: model.NewBool(false)} - group2WSA := &model.GroupWithSchemeAdmin{Group: *group2, SchemeAdmin: model.NewBool(false)} - group3WSA := &model.GroupWithSchemeAdmin{Group: *group3, SchemeAdmin: model.NewBool(false)} + group1WSA := &model.GroupWithSchemeAdmin{Group: *group1, SchemeAdmin: model.NewPointer(false)} + group2WSA := &model.GroupWithSchemeAdmin{Group: *group2, SchemeAdmin: model.NewPointer(false)} + group3WSA := &model.GroupWithSchemeAdmin{Group: *group3, SchemeAdmin: model.NewPointer(false)} testCases := []struct { Name string @@ -3352,7 +3352,7 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 60, Result: []*model.GroupWithSchemeAdmin{group1WSA, group2WSA}, - TotalCount: model.NewInt64(2), + TotalCount: model.NewPointer(int64(2)), }, { Name: "Get first Group for Team1 with page 0 with 1 element", @@ -3377,7 +3377,7 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 60, Result: []*model.GroupWithSchemeAdmin{group3WSA}, - TotalCount: model.NewInt64(1), + TotalCount: model.NewPointer(int64(1)), }, { Name: "Get empty Groups for a fake id", @@ -3386,7 +3386,7 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 60, Result: []*model.GroupWithSchemeAdmin{}, - TotalCount: model.NewInt64(0), + TotalCount: model.NewPointer(int64(0)), }, { Name: "Get group matching name", @@ -3395,7 +3395,7 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 100, Result: []*model.GroupWithSchemeAdmin{group1WSA}, - TotalCount: model.NewInt64(1), + TotalCount: model.NewPointer(int64(1)), }, { Name: "Get group matching display name", @@ -3404,7 +3404,7 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 100, Result: []*model.GroupWithSchemeAdmin{group1WSA}, - TotalCount: model.NewInt64(1), + TotalCount: model.NewPointer(int64(1)), }, { Name: "Get group matching multiple display names", @@ -3413,7 +3413,7 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 100, Result: []*model.GroupWithSchemeAdmin{group1WSA, group2WSA}, - TotalCount: model.NewInt64(2), + TotalCount: model.NewPointer(int64(2)), }, { Name: "Include member counts", @@ -3422,8 +3422,8 @@ func testGetGroupsByTeam(t *testing.T, rctx request.CTX, ss store.Store) { Page: 0, PerPage: 2, Result: []*model.GroupWithSchemeAdmin{ - {Group: group1WithMemberCount, SchemeAdmin: model.NewBool(false)}, - {Group: group2WithMemberCount, SchemeAdmin: model.NewBool(false)}, + {Group: group1WithMemberCount, SchemeAdmin: model.NewPointer(false)}, + {Group: group2WithMemberCount, SchemeAdmin: model.NewPointer(false)}, }, }, { @@ -3467,7 +3467,7 @@ func testGetGroups(t *testing.T, rctx request.CTX, ss store.Store) { Name: NewTestId(), Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TeamOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } team1, err := ss.Team().Save(team1) require.NoError(t, err) @@ -3486,27 +3486,27 @@ func testGetGroups(t *testing.T, rctx request.CTX, ss store.Store) { // Create Groups 1 and 2 group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: "group-1", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) require.NoError(t, err) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId() + "-group-2"), + Name: model.NewPointer(model.NewId() + "-group-2"), DisplayName: "group-2", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: false, }) require.NoError(t, err) deletedGroup, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId() + "-group-deleted"), + Name: model.NewPointer(model.NewId() + "-group-deleted"), DisplayName: "group-deleted", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: false, DeleteAt: 1, @@ -3560,9 +3560,9 @@ func testGetGroups(t *testing.T, rctx request.CTX, ss store.Store) { // Create Group3 group3, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId() + "-group-3"), + Name: model.NewPointer(model.NewId() + "-group-3"), DisplayName: "group-3", - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), Source: model.GroupSourceLdap, AllowReference: true, }) @@ -4010,7 +4010,7 @@ func testTeamMembersMinusGroupMembers(t *testing.T, rctx request.CTX, ss store.S Name: NewTestId(), Email: model.NewId() + "@simulator.amazonses.com", Type: model.TeamOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } team, err := ss.Team().Save(team) require.NoError(t, err) @@ -4042,11 +4042,11 @@ func testTeamMembersMinusGroupMembers(t *testing.T, rctx request.CTX, ss store.S for i := 0; i < numberOfGroups; i++ { group := &model.Group{ - Name: model.NewString(fmt.Sprintf("n_%d_%s", i, model.NewId())), + Name: model.NewPointer(fmt.Sprintf("n_%d_%s", i, model.NewId())), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(group) require.NoError(t, err) @@ -4162,7 +4162,7 @@ func testChannelMembersMinusGroupMembers(t *testing.T, rctx request.CTX, ss stor DisplayName: "A Name", Name: model.NewId(), Type: model.ChannelTypePrivate, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), } channel, err := ss.Channel().Save(rctx, channel, 9999) require.NoError(t, err) @@ -4205,11 +4205,11 @@ func testChannelMembersMinusGroupMembers(t *testing.T, rctx request.CTX, ss stor for i := 0; i < numberOfGroups; i++ { group := &model.Group{ - Name: model.NewString(fmt.Sprintf("n_%d_%s", i, model.NewId())), + Name: model.NewPointer(fmt.Sprintf("n_%d_%s", i, model.NewId())), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(group) require.NoError(t, err) @@ -4315,11 +4315,11 @@ func testChannelMembersMinusGroupMembers(t *testing.T, rctx request.CTX, ss stor func groupTestGetMemberCount(t *testing.T, rctx request.CTX, ss store.Store) { group := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(group) require.NoError(t, err) @@ -4360,11 +4360,11 @@ func groupTestAdminRoleGroupsForSyncableMemberChannel(t *testing.T, rctx request require.NoError(t, err) group1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group1, err = ss.Group().Create(group1) require.NoError(t, err) @@ -4373,11 +4373,11 @@ func groupTestAdminRoleGroupsForSyncableMemberChannel(t *testing.T, rctx request require.NoError(t, err) group2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group2, err = ss.Group().Create(group2) require.NoError(t, err) @@ -4448,11 +4448,11 @@ func groupTestAdminRoleGroupsForSyncableMemberTeam(t *testing.T, rctx request.CT require.NoError(t, err) group1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group1, err = ss.Group().Create(group1) require.NoError(t, err) @@ -4461,11 +4461,11 @@ func groupTestAdminRoleGroupsForSyncableMemberTeam(t *testing.T, rctx request.CT require.NoError(t, err) group2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group2, err = ss.Group().Create(group2) require.NoError(t, err) @@ -4549,11 +4549,11 @@ func groupTestPermittedSyncableAdminsTeam(t *testing.T, rctx request.CTX, ss sto require.NoError(t, err) group1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group1, err = ss.Group().Create(group1) require.NoError(t, err) @@ -4564,11 +4564,11 @@ func groupTestPermittedSyncableAdminsTeam(t *testing.T, rctx request.CTX, ss sto require.NoError(t, err) group2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group2, err = ss.Group().Create(group2) require.NoError(t, err) @@ -4655,11 +4655,11 @@ func groupTestPermittedSyncableAdminsChannel(t *testing.T, rctx request.CTX, ss require.NoError(t, err) group1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group1, err = ss.Group().Create(group1) require.NoError(t, err) @@ -4670,11 +4670,11 @@ func groupTestPermittedSyncableAdminsChannel(t *testing.T, rctx request.CTX, ss require.NoError(t, err) group2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, Description: model.NewId(), - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group2, err = ss.Group().Create(group2) require.NoError(t, err) @@ -4955,10 +4955,10 @@ func groupTestpUpdateMembersRoleChannel(t *testing.T, rctx request.CTX, ss store func groupTestGroupCount(t *testing.T, rctx request.CTX, ss store.Store) { group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group1.Id) @@ -4968,10 +4968,10 @@ func groupTestGroupCount(t *testing.T, rctx request.CTX, ss store.Store) { require.GreaterOrEqual(t, count, int64(1)) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group2.Id) @@ -4995,19 +4995,19 @@ func groupTestGroupTeamCount(t *testing.T, rctx request.CTX, ss store.Store) { defer ss.Team().PermanentDelete(team.Id) group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group1.Id) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group2.Id) @@ -5040,19 +5040,19 @@ func groupTestGroupChannelCount(t *testing.T, rctx request.CTX, ss store.Store) defer ss.Channel().Delete(channel.Id, 0) group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group1.Id) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group2.Id) @@ -5090,10 +5090,10 @@ func groupTestGroupMemberCount(t *testing.T, rctx request.CTX, ss store.Store) { require.NoError(t, err) group, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group.Id) @@ -5117,19 +5117,19 @@ func groupTestGroupMemberCount(t *testing.T, rctx request.CTX, ss store.Store) { func groupTestDistinctGroupMemberCount(t *testing.T, rctx request.CTX, ss store.Store) { group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group1.Id) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group2.Id) @@ -5178,10 +5178,10 @@ func groupTestGroupCountWithAllowReference(t *testing.T, rctx request.CTX, ss st require.NoError(t, err) group1, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) require.NoError(t, err) defer ss.Group().Delete(group1.Id) @@ -5191,10 +5191,10 @@ func groupTestGroupCountWithAllowReference(t *testing.T, rctx request.CTX, ss st require.Equal(t, count, initialCount) group2, err := ss.Group().Create(&model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), AllowReference: true, }) require.NoError(t, err) @@ -5207,11 +5207,11 @@ func groupTestGroupCountWithAllowReference(t *testing.T, rctx request.CTX, ss st func groupTestGetMember(t *testing.T, rctx request.CTX, ss store.Store) { g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -5244,11 +5244,11 @@ func groupTestGetMember(t *testing.T, rctx request.CTX, ss store.Store) { func groupTestGetNonMemberUsersPage(t *testing.T, rctx request.CTX, ss store.Store) { g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } group, err := ss.Group().Create(g1) require.NoError(t, err) @@ -5293,21 +5293,21 @@ func groupTestDistinctGroupMemberCountForSource(t *testing.T, rctx request.CTX, // create 2 groups, 1 custom and 1 ldap g1 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceCustom, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } customGroup, err := ss.Group().Create(g1) require.NoError(t, err) g2 := &model.Group{ - Name: model.NewString(model.NewId()), + Name: model.NewPointer(model.NewId()), DisplayName: model.NewId(), Description: model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), } ldapGroup, err := ss.Group().Create(g2) require.NoError(t, err) diff --git a/server/channels/store/storetest/post_acknowledgements_store.go b/server/channels/store/storetest/post_acknowledgements_store.go index ec02cb708c..d0a6338fc9 100644 --- a/server/channels/store/storetest/post_acknowledgements_store.go +++ b/server/channels/store/storetest/post_acknowledgements_store.go @@ -28,9 +28,9 @@ func testPostAcknowledgementsStoreSave(t *testing.T, rctx request.CTX, ss store. p1.Message = NewTestId() p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, } post, err := ss.Post().Save(rctx, &p1) @@ -73,9 +73,9 @@ func testPostAcknowledgementsStoreGetForPost(t *testing.T, rctx request.CTX, ss p1.Message = NewTestId() p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, } _, err := ss.Post().Save(rctx, &p1) @@ -124,9 +124,9 @@ func testPostAcknowledgementsStoreGetForPosts(t *testing.T, rctx request.CTX, ss p1.Message = NewTestId() p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, } p2 := model.Post{} @@ -135,9 +135,9 @@ func testPostAcknowledgementsStoreGetForPosts(t *testing.T, rctx request.CTX, ss p2.Message = NewTestId() p2.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(""), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(""), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, } _, errIdx, err := ss.Post().SaveMultiple([]*model.Post{&p1, &p2}) diff --git a/server/channels/store/storetest/post_persistent_notification_store.go b/server/channels/store/storetest/post_persistent_notification_store.go index cbc388a580..8fce4f2f17 100644 --- a/server/channels/store/storetest/post_persistent_notification_store.go +++ b/server/channels/store/storetest/post_persistent_notification_store.go @@ -28,9 +28,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s p1.CreateAt = 10 p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -41,9 +41,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s p2.CreateAt = 20 p2.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(true), }, } @@ -62,9 +62,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s p4.CreateAt = 40 p4.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(false), }, } @@ -75,9 +75,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s p5.CreateAt = 50 p5.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -150,9 +150,9 @@ func testPostPersistentNotificationStoreUpdateLastSentAt(t *testing.T, rctx requ p1.CreateAt = 10 p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -203,9 +203,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p1.CreateAt = 10 p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -216,9 +216,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p2.CreateAt = 20 p2.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(true), }, } @@ -229,9 +229,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p3.CreateAt = 30 p3.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -263,9 +263,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p1.CreateAt = 10 p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -276,9 +276,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p2.CreateAt = 20 p2.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(true), }, } @@ -289,9 +289,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p3.CreateAt = 30 p3.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -302,9 +302,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p4.CreateAt = 40 p4.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -315,9 +315,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p5.CreateAt = 50 p5.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -367,9 +367,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p1.CreateAt = 10 p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -380,9 +380,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p2.CreateAt = 20 p2.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(true), }, } @@ -393,9 +393,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p3.CreateAt = 30 p3.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -406,9 +406,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p4.CreateAt = 40 p4.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } @@ -419,9 +419,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s p5.CreateAt = 50 p5.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } diff --git a/server/channels/store/storetest/post_priority_store.go b/server/channels/store/storetest/post_priority_store.go index 61bf4dcf69..33e402a983 100644 --- a/server/channels/store/storetest/post_priority_store.go +++ b/server/channels/store/storetest/post_priority_store.go @@ -28,9 +28,9 @@ func testPostPriorityStoreGetForPost(t *testing.T, rctx request.CTX, ss store.St p1.Message = NewTestId() p1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, } @@ -40,9 +40,9 @@ func testPostPriorityStoreGetForPost(t *testing.T, rctx request.CTX, ss store.St p2.Message = NewTestId() p2.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(true), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(true), }, } diff --git a/server/channels/store/storetest/post_store.go b/server/channels/store/storetest/post_store.go index 684717a02c..41fbf6adef 100644 --- a/server/channels/store/storetest/post_store.go +++ b/server/channels/store/storetest/post_store.go @@ -249,9 +249,9 @@ func testPostStoreSave(t *testing.T, rctx request.CTX, ss store.Store) { o1.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString("important"), - RequestedAck: model.NewBool(true), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer("important"), + RequestedAck: model.NewPointer(true), + PersistentNotifications: model.NewPointer(false), }, } @@ -4061,7 +4061,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store. channelPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{channel.Id}, }) @@ -4090,7 +4090,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store. teamPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(20), + PostDurationDays: model.NewPointer(int64(20)), }, TeamIDs: []string{team.Id}, }) @@ -4150,7 +4150,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store. channelPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{c1.Id}, }) @@ -4159,7 +4159,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store. teamPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, TeamIDs: []string{team.Id}, }) @@ -4662,7 +4662,7 @@ func testHasAutoResponsePostByUserSince(t *testing.T, rctx request.CTX, ss store func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) { // create some posts. channelID := model.NewId() - remoteID := model.NewString(model.NewId()) + remoteID := model.NewPointer(model.NewId()) first := model.GetMillis() data := []*model.Post{ @@ -4681,7 +4681,7 @@ func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Sto for i, p := range data { p.UpdateAt = first + (int64(i) * 300000) if p.RemoteId == nil { - p.RemoteId = model.NewString(model.NewId()) + p.RemoteId = model.NewPointer(model.NewId()) } _, err := ss.Post().Save(rctx, p) require.NoError(t, err, "couldn't save post") @@ -4765,7 +4765,7 @@ func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Sto func testGetPostsSinceCreateForSync(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) { // create some posts. channelID := model.NewId() - remoteID := model.NewString(model.NewId()) + remoteID := model.NewPointer(model.NewId()) first := model.GetMillis() data := []*model.Post{ @@ -4784,7 +4784,7 @@ func testGetPostsSinceCreateForSync(t *testing.T, rctx request.CTX, ss store.Sto for i, p := range data { p.CreateAt = first + (int64(i) * 300000) if p.RemoteId == nil { - p.RemoteId = model.NewString(model.NewId()) + p.RemoteId = model.NewPointer(model.NewId()) } _, err := ss.Post().Save(rctx, p) require.NoError(t, err, "couldn't save post") diff --git a/server/channels/store/storetest/reaction_store.go b/server/channels/store/storetest/reaction_store.go index 33492f684d..6b1ba3bf98 100644 --- a/server/channels/store/storetest/reaction_store.go +++ b/server/channels/store/storetest/reaction_store.go @@ -982,7 +982,7 @@ func testReactionGetSingle(t *testing.T, rctx request.CTX, ss store.Store) { UserId: testUserID, PostId: post.Id, EmojiName: testEmojiName, - RemoteId: model.NewString(testRemoteID), + RemoteId: model.NewPointer(testRemoteID), } _, nErr := ss.Reaction().Save(reaction) @@ -1007,7 +1007,7 @@ func testReactionGetSingle(t *testing.T, rctx request.CTX, ss store.Store) { UserId: testUserID, PostId: post.Id, EmojiName: testEmojiName, - RemoteId: model.NewString(testRemoteID), + RemoteId: model.NewPointer(testRemoteID), } _, nErr := ss.Reaction().Save(reaction) diff --git a/server/channels/store/storetest/retention_policy_store.go b/server/channels/store/storetest/retention_policy_store.go index 92539a486f..0a46c0b0a7 100644 --- a/server/channels/store/storetest/retention_policy_store.go +++ b/server/channels/store/storetest/retention_policy_store.go @@ -174,7 +174,7 @@ func createRetentionPolicyWithTeamAndChannelIds(displayName string, teamIDs, cha return &model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: displayName, - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, TeamIDs: teamIDs, ChannelIDs: channelIDs, @@ -254,7 +254,7 @@ func testRetentionPolicyStorePatch(t *testing.T, rctx request.CTX, ss store.Stor patch := &model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ ID: policy.ID, - PostDurationDays: model.NewInt64(10000), + PostDurationDays: model.NewPointer(int64(10000)), }, } _, err := ss.RetentionPolicy().Patch(patch) @@ -264,7 +264,7 @@ func testRetentionPolicyStorePatch(t *testing.T, rctx request.CTX, ss store.Stor checkRetentionPolicyLikeThisExists(t, ss, expected) // Store a negative value (= infinity) - patch.PostDurationDays = model.NewInt64(-1) + patch.PostDurationDays = model.NewPointer(int64(-1)) _, err = ss.RetentionPolicy().Patch(patch) require.NoError(t, err) expected = copyRetentionPolicyWithTeamAndChannelIds(policy) diff --git a/server/channels/store/storetest/settings.go b/server/channels/store/storetest/settings.go index de30ef3544..9263930852 100644 --- a/server/channels/store/storetest/settings.go +++ b/server/channels/store/storetest/settings.go @@ -172,8 +172,8 @@ func databaseSettings(driver, dataSource string) *model.SqlSettings { ConnMaxLifetimeMilliseconds: new(int), ConnMaxIdleTimeMilliseconds: new(int), MaxOpenConns: new(int), - Trace: model.NewBool(false), - AtRestEncryptKey: model.NewString(model.NewRandomString(32)), + Trace: model.NewPointer(false), + AtRestEncryptKey: model.NewPointer(model.NewRandomString(32)), QueryTimeout: new(int), MigrationsStatementTimeoutSeconds: new(int), } @@ -261,7 +261,7 @@ func MakeSqlSettings(driver string, withReplica bool) *model.SqlSettings { } log("Created temporary " + driver + " database " + dbName) - settings.ReplicaMonitorIntervalSeconds = model.NewInt(5) + settings.ReplicaMonitorIntervalSeconds = model.NewPointer(5) return settings } diff --git a/server/channels/store/storetest/shared_channel_store.go b/server/channels/store/storetest/shared_channel_store.go index b46d3706e9..4c2a4af972 100644 --- a/server/channels/store/storetest/shared_channel_store.go +++ b/server/channels/store/storetest/shared_channel_store.go @@ -869,7 +869,7 @@ func createSharedTestChannel(ss store.Store, rctx request.CTX, name string, shar Header: name + " header", Purpose: name + "purpose", CreatorId: model.NewId(), - Shared: model.NewBool(shared), + Shared: model.NewPointer(shared), } channel, err := ss.Channel().Save(rctx, channel, 10000) if err != nil { diff --git a/server/channels/store/storetest/team_store.go b/server/channels/store/storetest/team_store.go index 6d5a008936..499923afb1 100644 --- a/server/channels/store/storetest/team_store.go +++ b/server/channels/store/storetest/team_store.go @@ -276,7 +276,7 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) { g.Email = MakeEmail() g.Type = model.TeamOpen g.AllowOpenInvite = false - g.GroupConstrained = model.NewBool(true) + g.GroupConstrained = model.NewPointer(true) _, err = ss.Team().Save(&g) require.NoError(t, err) @@ -294,7 +294,7 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) { _, err = ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(20), + PostDurationDays: model.NewPointer(int64(20)), }, TeamIDs: []string{q.Id}, }) @@ -368,55 +368,55 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) { }, { "Search for all 3 teams filter by allow open invite", - &model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(true)}, + &model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(true)}, 1, []string{o.Id}, }, { "Search for all 3 teams filter by allow open invite = false", - &model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(false)}, + &model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(false)}, 1, []string{p.Id}, }, { "Search for all 3 teams filter by group constrained", - &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(true)}, + &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(true)}, 1, []string{g.Id}, }, { "Search for all 3 teams filter by group constrained = false", - &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false)}, + &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false)}, 2, []string{o.Id, p.Id}, }, { "Search for all 3 teams filter by allow open invite and include group constrained", - &model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(true), GroupConstrained: model.NewBool(true)}, + &model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(true), GroupConstrained: model.NewPointer(true)}, 2, []string{o.Id, g.Id}, }, { "Search for all 3 teams filter by group constrained and not open invite", - &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(true), AllowOpenInvite: model.NewBool(false)}, + &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(true), AllowOpenInvite: model.NewPointer(false)}, 2, []string{g.Id, p.Id}, }, { "Search for all 3 teams filter by group constrained false and open invite", - &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false), AllowOpenInvite: model.NewBool(true)}, + &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false), AllowOpenInvite: model.NewPointer(true)}, 2, []string{o.Id, p.Id}, }, { "Search for all 3 teams filter by group constrained false and open invite false", - &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false), AllowOpenInvite: model.NewBool(false)}, + &model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false), AllowOpenInvite: model.NewPointer(false)}, 2, []string{p.Id, o.Id}, }, { "Search for teams which are not part of a data retention policy", - &model.TeamSearch{Term: "", ExcludePolicyConstrained: model.NewBool(true)}, + &model.TeamSearch{Term: "", ExcludePolicyConstrained: model.NewPointer(true)}, 3, []string{o.Id, p.Id, g.Id}, }, @@ -700,7 +700,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) { policy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, TeamIDs: []string{o.Id}, }) @@ -720,7 +720,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) { require.True(t, found) // With ExcludePolicyConstrained - teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{ExcludePolicyConstrained: model.NewBool(true)}) + teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{ExcludePolicyConstrained: model.NewPointer(true)}) require.NoError(t, err) found = false for _, team := range teams { @@ -732,7 +732,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) { require.False(t, found) // With policy ID - teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{IncludePolicyID: model.NewBool(true)}) + teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{IncludePolicyID: model.NewPointer(true)}) require.NoError(t, err) found = false for _, team := range teams { @@ -826,7 +826,7 @@ func testGetAllTeamPageListing(t *testing.T, rctx request.CTX, ss store.Store) { _, err = ss.Team().Save(&o4) require.NoError(t, err) - opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(true)} + opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(true)} teams, err := ss.Team().GetAllPage(0, 10, opts) require.NoError(t, err) @@ -946,7 +946,7 @@ func testGetAllPrivateTeamPageListing(t *testing.T, rctx request.CTX, ss store.S _, err = ss.Team().Save(&o4) require.NoError(t, err) - opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(false)} + opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(false)} teams, listErr := ss.Team().GetAllPage(0, 10, opts) require.NoError(t, listErr) @@ -1021,7 +1021,7 @@ func testGetAllPublicTeamPageListing(t *testing.T, rctx request.CTX, ss store.St _, err = ss.Team().Save(&o4) require.NoError(t, err) - opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(true)} + opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(true)} teams, err := ss.Team().GetAllPage(0, 10, opts) assert.NoError(t, err) @@ -1096,7 +1096,7 @@ func testPublicTeamCount(t *testing.T, rctx request.CTX, ss store.Store) { _, err = ss.Team().Save(&o3) require.NoError(t, err) - teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewBool(true)}) + teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewPointer(true)}) require.NoError(t, err) require.Equal(t, int64(2), teamCount, "should only be 1 team") } @@ -1131,7 +1131,7 @@ func testPrivateTeamCount(t *testing.T, rctx request.CTX, ss store.Store) { _, err = ss.Team().Save(&o3) require.NoError(t, err) - teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewBool(false)}) + teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewPointer(false)}) require.NoError(t, err) require.Equal(t, int64(2), teamCount, "should only be 1 team") } @@ -1161,7 +1161,7 @@ func testTeamCount(t *testing.T, rctx request.CTX, ss store.Store) { require.NoError(t, err) // get the count of teams including deleted - countIncludingDeleted, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{IncludeDeleted: model.NewBool(true)}) + countIncludingDeleted, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{IncludeDeleted: model.NewPointer(true)}) require.NoError(t, err) // count including deleted should be one greater than not including deleted @@ -3589,7 +3589,7 @@ func testGroupSyncedTeamCount(t *testing.T, rctx request.CTX, ss store.Store) { Name: NewTestId(), Email: MakeEmail(), Type: model.TeamInvite, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), }) require.NoError(t, err) require.True(t, team1.IsGroupConstrained()) @@ -3609,7 +3609,7 @@ func testGroupSyncedTeamCount(t *testing.T, rctx request.CTX, ss store.Store) { require.NoError(t, err) require.GreaterOrEqual(t, count, int64(1)) - team2.GroupConstrained = model.NewBool(true) + team2.GroupConstrained = model.NewPointer(true) team2, err = ss.Team().Update(team2) require.NoError(t, err) require.True(t, team2.IsGroupConstrained()) diff --git a/server/channels/store/storetest/thread_store.go b/server/channels/store/storetest/thread_store.go index 554dc84c89..2497a6517c 100644 --- a/server/channels/store/storetest/thread_store.go +++ b/server/channels/store/storetest/thread_store.go @@ -64,9 +64,9 @@ func testThreadStorePopulation(t *testing.T, rctx request.CTX, ss store.Store) { if urgent { o.Metadata = &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(false), }, } } @@ -520,7 +520,7 @@ func testThreadStorePermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{channel.Id}, }) @@ -542,7 +542,7 @@ func testThreadStorePermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx teamPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(20), + PostDurationDays: model.NewPointer(int64(20)), }, TeamIDs: []string{team.Id}, }) @@ -607,7 +607,7 @@ func testThreadStorePermanentDeleteBatchThreadMembershipsForRetentionPolicies(t channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(30), + PostDurationDays: model.NewPointer(int64(30)), }, ChannelIDs: []string{channel.Id}, }) @@ -626,7 +626,7 @@ func testThreadStorePermanentDeleteBatchThreadMembershipsForRetentionPolicies(t teamPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "DisplayName", - PostDurationDays: model.NewInt64(20), + PostDurationDays: model.NewPointer(int64(20)), }, TeamIDs: []string{team.Id}, }) @@ -739,9 +739,9 @@ func testGetTeamsUnreadForUser(t *testing.T, rctx request.CTX, ss store.Store) { Message: model.NewRandomString(10), Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(false), }, }, }) @@ -881,9 +881,9 @@ func testVarious(t *testing.T, rctx request.CTX, ss store.Store) { Message: model.NewRandomString(10), Metadata: &model.PostMetadata{ Priority: &model.PostPriority{ - Priority: model.NewString(model.PostPriorityUrgent), - RequestedAck: model.NewBool(false), - PersistentNotifications: model.NewBool(false), + Priority: model.NewPointer(model.PostPriorityUrgent), + RequestedAck: model.NewPointer(false), + PersistentNotifications: model.NewPointer(false), }, }, }) diff --git a/server/channels/store/storetest/user_store.go b/server/channels/store/storetest/user_store.go index ff89476acc..65013b41ee 100644 --- a/server/channels/store/storetest/user_store.go +++ b/server/channels/store/storetest/user_store.go @@ -1605,10 +1605,10 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, rctx request.CTX, ss sto // create a group group, err := ss.Group().Create(&model.Group{ - Name: model.NewString("n_" + model.NewId()), + Name: model.NewPointer("n_" + model.NewId()), DisplayName: "dn_" + model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString("ri_" + model.NewId()), + RemoteId: model.NewPointer("ri_" + model.NewId()), }) require.NoError(t, err) @@ -2357,7 +2357,7 @@ func testUserStoreResetAuthDataToEmailForUsers(t *testing.T, rctx request.CTX, s resetAuthDataToID := func() { _, err = ss.User().UpdateAuthData( - user.Id, model.UserAuthServiceSaml, model.NewString("some-id"), "", false) + user.Id, model.UserAuthServiceSaml, model.NewPointer("some-id"), "", false) require.NoError(t, err) } resetAuthDataToID() @@ -3694,28 +3694,28 @@ func testUserStoreSearchInGroup(t *testing.T, rctx request.CTX, ss store.Store) defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, u3.Id)) }() // The users returned from the database will have AuthData as an empty string. - nilAuthData := model.NewString("") + nilAuthData := model.NewPointer("") u1.AuthData = nilAuthData u2.AuthData = nilAuthData u3.AuthData = nilAuthData g1 := &model.Group{ - Name: model.NewString(NewTestId()), + Name: model.NewPointer(NewTestId()), DisplayName: NewTestId(), Description: NewTestId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(NewTestId()), + RemoteId: model.NewPointer(NewTestId()), } _, err = ss.Group().Create(g1) require.NoError(t, err) g2 := &model.Group{ - Name: model.NewString(NewTestId()), + Name: model.NewPointer(NewTestId()), DisplayName: NewTestId(), Description: NewTestId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString(NewTestId()), + RemoteId: model.NewPointer(NewTestId()), } _, err = ss.Group().Create(g2) require.NoError(t, err) @@ -3837,28 +3837,28 @@ func testUserStoreSearchNotInGroup(t *testing.T, rctx request.CTX, ss store.Stor defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, u3.Id)) }() // The users returned from the database will have AuthData as an empty string. - nilAuthData := model.NewString("") + nilAuthData := model.NewPointer("") u1.AuthData = nilAuthData u2.AuthData = nilAuthData u3.AuthData = nilAuthData g1 := &model.Group{ - Name: model.NewString(NewTestId()), + Name: model.NewPointer(NewTestId()), DisplayName: NewTestId(), Description: NewTestId(), Source: model.GroupSourceCustom, - RemoteId: model.NewString(NewTestId()), + RemoteId: model.NewPointer(NewTestId()), } _, err = ss.Group().Create(g1) require.NoError(t, err) g2 := &model.Group{ - Name: model.NewString(NewTestId()), + Name: model.NewPointer(NewTestId()), DisplayName: NewTestId(), Description: NewTestId(), Source: model.GroupSourceCustom, - RemoteId: model.NewString(NewTestId()), + RemoteId: model.NewPointer(NewTestId()), } _, err = ss.Group().Create(g2) require.NoError(t, err) @@ -4764,10 +4764,10 @@ func testUserStoreGetProfilesNotInTeam(t *testing.T, rctx request.CTX, ss store. // create a group group, err := ss.Group().Create(&model.Group{ - Name: model.NewString("n_" + model.NewId()), + Name: model.NewPointer("n_" + model.NewId()), DisplayName: "dn_" + model.NewId(), Source: model.GroupSourceLdap, - RemoteId: model.NewString("ri_" + model.NewId()), + RemoteId: model.NewPointer("ri_" + model.NewId()), }) require.NoError(t, err) @@ -5084,10 +5084,10 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, rctx request.CTX, ss store.Sto var group *model.Group group, err = ss.Group().Create(&model.Group{ - Name: model.NewString("n_" + id), + Name: model.NewPointer("n_" + id), DisplayName: "dn_" + id, Source: model.GroupSourceLdap, - RemoteId: model.NewString("ri_" + id), + RemoteId: model.NewPointer("ri_" + id), }) require.NoError(t, err) require.NotNil(t, group) @@ -5123,7 +5123,7 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, rctx request.CTX, ss store.Sto requireNUsers(1) // update team to be group-constrained - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) team, err = ss.Team().Update(team) require.NoError(t, err) @@ -5205,10 +5205,10 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, rctx request.CTX, ss store. id = model.NewId() var group *model.Group group, err = ss.Group().Create(&model.Group{ - Name: model.NewString("n_" + id), + Name: model.NewPointer("n_" + id), DisplayName: "dn_" + id, Source: model.GroupSourceLdap, - RemoteId: model.NewString("ri_" + id), + RemoteId: model.NewPointer("ri_" + id), }) require.NoError(t, err) require.NotNil(t, group) @@ -5244,7 +5244,7 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, rctx request.CTX, ss store. requireNUsers(1) // update team to be group-constrained - channel.GroupConstrained = model.NewBool(true) + channel.GroupConstrained = model.NewPointer(true) _, nErr = ss.Channel().Update(rctx, channel) require.NoError(t, nErr) diff --git a/server/channels/web/handlers_test.go b/server/channels/web/handlers_test.go index 38fc5a900d..37fe2b21b3 100644 --- a/server/channels/web/handlers_test.go +++ b/server/channels/web/handlers_test.go @@ -970,7 +970,7 @@ func TestHandlerServeHTTPBasicSecurityChecks(t *testing.T) { mockStore.On("GetDBSchemaVersion").Return(1, nil) th.App.UpdateConfig(func(config *model.Config) { - config.ServiceSettings.MaximumURLLength = model.NewInt(10) + config.ServiceSettings.MaximumURLLength = model.NewPointer(10) }) web := New(th.Server) @@ -1002,7 +1002,7 @@ func TestHandlerServeHTTPBasicSecurityChecks(t *testing.T) { mockStore.On("GetDBSchemaVersion").Return(1, nil) th.App.UpdateConfig(func(config *model.Config) { - config.ServiceSettings.MaximumURLLength = model.NewInt(20) + config.ServiceSettings.MaximumURLLength = model.NewPointer(20) }) web := New(th.Server) @@ -1066,7 +1066,7 @@ func TestHandlerServeHTTPRequestPayloadLimit(t *testing.T) { mockStore.On("GetDBSchemaVersion").Return(1, nil) th.App.UpdateConfig(func(config *model.Config) { - config.ServiceSettings.MaximumPayloadSizeBytes = model.NewInt64(1) + config.ServiceSettings.MaximumPayloadSizeBytes = model.NewPointer(int64(1)) }) web := New(th.Server) diff --git a/server/cmd/mattermost/commands/export_test.go b/server/cmd/mattermost/commands/export_test.go index cca109331c..3d49b356b2 100644 --- a/server/cmd/mattermost/commands/export_test.go +++ b/server/cmd/mattermost/commands/export_test.go @@ -20,7 +20,7 @@ func TestMessageExportNotEnabled(t *testing.T) { defer th.TearDown() config := th.Config() - config.MessageExportSettings.EnableExport = model.NewBool(false) + config.MessageExportSettings.EnableExport = model.NewPointer(false) th.SetConfig(config) // should fail fast because the feature isn't enabled @@ -32,7 +32,7 @@ func TestMessageExportInvalidFormat(t *testing.T) { defer th.TearDown() config := th.Config() - config.MessageExportSettings.EnableExport = model.NewBool(true) + config.MessageExportSettings.EnableExport = model.NewPointer(true) th.SetConfig(config) // should fail fast because format isn't supported @@ -44,7 +44,7 @@ func TestMessageExportNegativeExportFrom(t *testing.T) { defer th.TearDown() config := th.Config() - config.MessageExportSettings.EnableExport = model.NewBool(true) + config.MessageExportSettings.EnableExport = model.NewPointer(true) th.SetConfig(config) // should fail fast because export from must be a valid timestamp @@ -56,7 +56,7 @@ func TestMessageExportNegativeTimeoutSeconds(t *testing.T) { defer th.TearDown() config := th.Config() - config.MessageExportSettings.EnableExport = model.NewBool(true) + config.MessageExportSettings.EnableExport = model.NewPointer(true) th.SetConfig(config) // should fail fast because timeout seconds must be a positive int diff --git a/server/cmd/mmctl/commands/config_test.go b/server/cmd/mmctl/commands/config_test.go index 02d88f7c18..6acb7c6f8a 100644 --- a/server/cmd/mmctl/commands/config_test.go +++ b/server/cmd/mmctl/commands/config_test.go @@ -896,8 +896,8 @@ func (s *MmctlUnitTestSuite) TestConfigMigrateCmd() { func TestCloudRestricted(t *testing.T) { cfg := &model.Config{ ServiceSettings: model.ServiceSettings{ - GoogleDeveloperKey: model.NewString("test"), - SiteURL: model.NewString("test"), + GoogleDeveloperKey: model.NewPointer("test"), + SiteURL: model.NewPointer("test"), }, } @@ -937,40 +937,40 @@ func TestSetConfigValue(t *testing.T) { path: "LogSettings.EnableConsole", args: []string{"true"}, config: &model.Config{LogSettings: model.LogSettings{ - EnableConsole: model.NewBool(false), + EnableConsole: model.NewPointer(false), }}, expectedConfig: &model.Config{LogSettings: model.LogSettings{ - EnableConsole: model.NewBool(true), + EnableConsole: model.NewPointer(true), }}, }, "string": { path: "LogSettings.ConsoleLevel", args: []string{"foo"}, config: &model.Config{LogSettings: model.LogSettings{ - ConsoleLevel: model.NewString("ConsoleLevel"), + ConsoleLevel: model.NewPointer("ConsoleLevel"), }}, expectedConfig: &model.Config{LogSettings: model.LogSettings{ - ConsoleLevel: model.NewString("foo"), + ConsoleLevel: model.NewPointer("foo"), }}, }, "int": { path: "LogSettings.MaxFieldSize", args: []string{"123"}, config: &model.Config{LogSettings: model.LogSettings{ - MaxFieldSize: model.NewInt(0), + MaxFieldSize: model.NewPointer(0), }}, expectedConfig: &model.Config{LogSettings: model.LogSettings{ - MaxFieldSize: model.NewInt(123), + MaxFieldSize: model.NewPointer(123), }}, }, "int64": { path: "ServiceSettings.TLSStrictTransportMaxAge", config: &model.Config{ServiceSettings: model.ServiceSettings{ - TLSStrictTransportMaxAge: model.NewInt64(0), + TLSStrictTransportMaxAge: model.NewPointer(int64(0)), }}, args: []string{"123"}, expectedConfig: &model.Config{ServiceSettings: model.ServiceSettings{ - TLSStrictTransportMaxAge: model.NewInt64(123), + TLSStrictTransportMaxAge: model.NewPointer(int64(123)), }}, }, "string slice": { diff --git a/server/cmd/mmctl/commands/group.go b/server/cmd/mmctl/commands/group.go index 5f3c48753a..c75414945f 100644 --- a/server/cmd/mmctl/commands/group.go +++ b/server/cmd/mmctl/commands/group.go @@ -184,7 +184,7 @@ func channelGroupEnableCmdF(c client.Client, cmd *cobra.Command, args []string) return errors.New("Channel '" + args[0] + "' has no groups associated. It cannot be group-constrained") } - channelPatch := model.ChannelPatch{GroupConstrained: model.NewBool(true)} + channelPatch := model.ChannelPatch{GroupConstrained: model.NewPointer(true)} if _, _, err = c.PatchChannel(context.TODO(), channel.Id, &channelPatch); err != nil { return err } @@ -198,7 +198,7 @@ func channelGroupDisableCmdF(c client.Client, cmd *cobra.Command, args []string) return errors.New("Unable to find channel '" + args[0] + "'") } - channelPatch := model.ChannelPatch{GroupConstrained: model.NewBool(false)} + channelPatch := model.ChannelPatch{GroupConstrained: model.NewPointer(false)} if _, _, err := c.PatchChannel(context.TODO(), channel.Id, &channelPatch); err != nil { return err } @@ -268,7 +268,7 @@ func teamGroupEnableCmdF(c client.Client, cmd *cobra.Command, args []string) err return errors.New("Team '" + args[0] + "' has no groups associated. It cannot be group-constrained") } - teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(true)} + teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(true)} if _, _, err = c.PatchTeam(context.TODO(), team.Id, &teamPatch); err != nil { return err } @@ -282,7 +282,7 @@ func teamGroupDisableCmdF(c client.Client, cmd *cobra.Command, args []string) er return errors.New("Unable to find team '" + args[0] + "'") } - teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(false)} + teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(false)} if _, _, err := c.PatchTeam(context.TODO(), team.Id, &teamPatch); err != nil { return err } diff --git a/server/cmd/mmctl/commands/group_e2e_test.go b/server/cmd/mmctl/commands/group_e2e_test.go index ce5b1749dc..6e849df17b 100644 --- a/server/cmd/mmctl/commands/group_e2e_test.go +++ b/server/cmd/mmctl/commands/group_e2e_test.go @@ -31,10 +31,10 @@ func (s *MmctlE2ETestSuite) TestChannelGroupEnableCmd() { id := model.NewId() group, appErr := s.th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) s.Require().Nil(appErr) defer func() { @@ -68,7 +68,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupEnableCmd() { err := channelGroupEnableCmdF(c, &cobra.Command{}, []string{s.th.BasicTeam.Name + ":" + channelName}) s.Require().NoError(err) - channel.GroupConstrained = model.NewBool(false) + channel.GroupConstrained = model.NewPointer(false) defer func() { _, err := s.th.App.UpdateChannel(s.th.Context, channel) s.Require().Nil(err) @@ -102,10 +102,10 @@ func (s *MmctlE2ETestSuite) TestChannelGroupDisableCmd() { id := model.NewId() group, appErr := s.th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) s.Require().Nil(appErr) defer func() { @@ -124,7 +124,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupDisableCmd() { s.Require().Nil(err) }() - channel.GroupConstrained = model.NewBool(true) + channel.GroupConstrained = model.NewPointer(true) defer func() { _, err := s.th.App.UpdateChannel(s.th.Context, channel) s.Require().Nil(err) @@ -145,7 +145,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupDisableCmd() { err := channelGroupDisableCmdF(c, &cobra.Command{}, []string{s.th.BasicTeam.Name + ":" + channelName}) s.Require().NoError(err) - channel.GroupConstrained = model.NewBool(true) + channel.GroupConstrained = model.NewPointer(true) defer func() { _, err := s.th.App.UpdateChannel(s.th.Context, channel) s.Require().Nil(err) @@ -194,7 +194,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupStatusCmd() { Name: channelName, DisplayName: "dn_" + channelName, Type: model.ChannelTypeOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), }, false) s.Require().Nil(appErr) defer func() { @@ -257,10 +257,10 @@ func (s *MmctlE2ETestSuite) TestChannelGroupListCmd() { id := model.NewId() group, appErr := s.th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) s.Require().Nil(appErr) defer func() { @@ -308,7 +308,7 @@ func (s *MmctlE2ETestSuite) TestTeamGroupDisableCmd() { team, _, cleanUpFn := createTestGroupTeam(s) defer cleanUpFn() - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) _, err := s.th.App.UpdateTeam(team) s.Require().Nil(err) @@ -327,7 +327,7 @@ func (s *MmctlE2ETestSuite) TestTeamGroupDisableCmd() { err := teamGroupDisableCmdF(c, &cobra.Command{}, []string{team.Name}) s.Require().NoError(err) - team.GroupConstrained = model.NewBool(true) + team.GroupConstrained = model.NewPointer(true) defer func() { _, err := s.th.App.UpdateTeam(team) s.Require().Nil(err) @@ -363,7 +363,7 @@ func (s *MmctlE2ETestSuite) TestTeamGroupEnableCmd() { err := teamGroupEnableCmdF(c, &cobra.Command{}, []string{team.Name}) s.Require().NoError(err) - team.GroupConstrained = model.NewBool(false) + team.GroupConstrained = model.NewPointer(false) defer func() { _, err := s.th.App.UpdateTeam(team) s.Require().Nil(err) @@ -473,17 +473,17 @@ func createTestGroupTeam(s *MmctlE2ETestSuite) (*model.Team, *model.Group, func( Name: teamName, DisplayName: "dn_" + teamName, Type: model.TeamOpen, - GroupConstrained: model.NewBool(true), + GroupConstrained: model.NewPointer(true), }) s.Require().Nil(appErr) id := model.NewId() group, appErr := s.th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceLdap, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) s.Require().Nil(appErr) @@ -515,10 +515,10 @@ func (s *MmctlE2ETestSuite) TestUserGroupRestoreCmd() { id := model.NewId() group, appErr := s.th.App.CreateGroup(&model.Group{ DisplayName: "dn_" + id, - Name: model.NewString("name" + id), + Name: model.NewPointer("name" + id), Source: model.GroupSourceCustom, Description: "description_" + id, - RemoteId: model.NewString(model.NewId()), + RemoteId: model.NewPointer(model.NewId()), }) s.Require().Nil(appErr) s.th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional, "ldap")) diff --git a/server/cmd/mmctl/commands/group_test.go b/server/cmd/mmctl/commands/group_test.go index 68ebc9a3df..a639da5e9a 100644 --- a/server/cmd/mmctl/commands/group_test.go +++ b/server/cmd/mmctl/commands/group_test.go @@ -154,7 +154,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupEnableCmd() { PerPage: 10, }, } - teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(true)} + teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(true)} s.client. EXPECT(). @@ -191,7 +191,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupEnableCmd() { PerPage: 10, }, } - teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(true)} + teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(true)} s.client. EXPECT(). @@ -223,7 +223,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupDisableCmd() { printer.Clean() teamArg := "example-team-id" mockTeam := model.Team{Id: teamArg} - teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(false)} + teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(false)} s.client. EXPECT(). @@ -269,7 +269,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupDisableCmd() { printer.Clean() teamArg := "example-team-id" mockTeam := model.Team{Id: teamArg} - teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(false)} + teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(false)} mockError := errors.New("patchteam error") s.client. @@ -302,7 +302,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { mockTeam := model.Team{Id: teamID} mockChannel := model.Channel{Id: channelID} - mockGroup := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewString(groupName)}} + mockGroup := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewPointer(groupName)}} mockGroups := []*model.GroupWithSchemeAdmin{mockGroup} groupOpts := &model.GroupSearchOpts{ @@ -348,8 +348,8 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { mockTeam := model.Team{Id: teamID} mockChannel := model.Channel{Id: channelID} mockGroups := []*model.GroupWithSchemeAdmin{ - {Group: model.Group{Name: model.NewString("group1")}}, - {Group: model.Group{Name: model.NewString("group2")}}, + {Group: model.Group{Name: model.NewPointer("group1")}}, + {Group: model.Group{Name: model.NewPointer("group2")}}, } groupOpts := &model.GroupSearchOpts{ @@ -761,7 +761,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupStatusCmd() { arg := teamID args := []string{arg} cmd := &cobra.Command{} - team := &model.Team{Id: teamID, GroupConstrained: model.NewBool(true)} + team := &model.Team{Id: teamID, GroupConstrained: model.NewPointer(true)} s.client. EXPECT(). @@ -784,7 +784,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupStatusCmd() { arg := teamID args := []string{arg} cmd := &cobra.Command{} - team := &model.Team{Id: teamID, GroupConstrained: model.NewBool(false)} + team := &model.Team{Id: teamID, GroupConstrained: model.NewPointer(false)} s.client. EXPECT(). @@ -872,7 +872,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() { cmd := &cobra.Command{} team := &model.Team{Id: teamID} - channel := &model.Channel{Id: channelID, GroupConstrained: model.NewBool(true)} + channel := &model.Channel{Id: channelID, GroupConstrained: model.NewPointer(true)} s.client. EXPECT(). @@ -904,7 +904,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() { cmd := &cobra.Command{} team := &model.Team{Id: teamID} - channel := &model.Channel{Id: channelID, GroupConstrained: model.NewBool(false)} + channel := &model.Channel{Id: channelID, GroupConstrained: model.NewPointer(false)} s.client. EXPECT(). @@ -968,7 +968,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { channelPart := "channel-id" mockChannel := model.Channel{Id: channelPart} channelArg := teamArg + ":" + channelPart - group := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewString("group-name")}} + group := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewPointer("group-name")}} mockGroups := []*model.GroupWithSchemeAdmin{group} groupOpts := &model.GroupSearchOpts{ PageOpts: &model.PageOpts{ @@ -997,7 +997,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewPointer(true)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1117,7 +1117,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { channelPart := "channel-id" mockChannel := model.Channel{Id: channelPart} channelArg := teamArg + ":" + channelPart - group := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewString("group-name")}} + group := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewPointer("group-name")}} mockGroups := []*model.GroupWithSchemeAdmin{group} mockError := errors.New("mock error") groupOpts := &model.GroupSearchOpts{ @@ -1147,7 +1147,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewPointer(true)}). Return(nil, &model.Response{}, mockError). Times(1) @@ -1266,7 +1266,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { channelPart := "channel-id" mockChannel := model.Channel{Id: channelPart} channelArg := teamArg + ":" + channelPart - group := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewString("group-name")}} + group := &model.GroupWithSchemeAdmin{Group: model.Group{Name: model.NewPointer("group-name")}} mockGroups := []*model.GroupWithSchemeAdmin{group} mockError := errors.New("mock error") groupOpts := &model.GroupSearchOpts{ @@ -1302,7 +1302,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewPointer(true)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1337,7 +1337,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewPointer(false)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1436,7 +1436,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewPointer(false)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1531,7 +1531,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewPointer(false)}). Return(nil, &model.Response{}, mockError). Times(1) diff --git a/server/cmd/mmctl/commands/integrity_test.go b/server/cmd/mmctl/commands/integrity_test.go index 16eb339bfd..64a503900c 100644 --- a/server/cmd/mmctl/commands/integrity_test.go +++ b/server/cmd/mmctl/commands/integrity_test.go @@ -28,8 +28,8 @@ func (s *MmctlUnitTestSuite) TestIntegrityCmd() { ChildIdAttr: "childIdAttr", Records: []model.OrphanedRecord{ { - ParentId: model.NewString("parentId"), - ChildId: model.NewString("childId"), + ParentId: model.NewPointer("parentId"), + ChildId: model.NewPointer("childId"), }, }, } @@ -82,8 +82,8 @@ func (s *MmctlUnitTestSuite) TestIntegrityCmd() { ChildIdAttr: "childIdAttr", Records: []model.OrphanedRecord{ { - ParentId: model.NewString("parentId"), - ChildId: model.NewString("childId"), + ParentId: model.NewPointer("parentId"), + ChildId: model.NewPointer("childId"), }, }, } diff --git a/server/cmd/mmctl/commands/user.go b/server/cmd/mmctl/commands/user.go index b63f4fd592..b43aad1b0d 100644 --- a/server/cmd/mmctl/commands/user.go +++ b/server/cmd/mmctl/commands/user.go @@ -948,7 +948,7 @@ func convertBotToUser(c client.Client, cmd *cobra.Command, userArgs []string) er return errors.New("username is empty") } } else { - up.Username = model.NewString(username) + up.Username = model.NewPointer(username) } email, _ := cmd.Flags().GetString("email") @@ -957,27 +957,27 @@ func convertBotToUser(c client.Client, cmd *cobra.Command, userArgs []string) er return errors.New("email is empty") } } else { - up.Email = model.NewString(email) + up.Email = model.NewPointer(email) } nickname, _ := cmd.Flags().GetString("nickname") if nickname != "" { - up.Nickname = model.NewString(nickname) + up.Nickname = model.NewPointer(nickname) } firstname, _ := cmd.Flags().GetString("firstname") if firstname != "" { - up.FirstName = model.NewString(firstname) + up.FirstName = model.NewPointer(firstname) } lastname, _ := cmd.Flags().GetString("lastname") if lastname != "" { - up.LastName = model.NewString(lastname) + up.LastName = model.NewPointer(lastname) } locale, _ := cmd.Flags().GetString("locale") if locale != "" { - up.Locale = model.NewString(locale) + up.Locale = model.NewPointer(locale) } systemAdmin, _ := cmd.Flags().GetBool("system-admin") diff --git a/server/cmd/mmctl/commands/user_e2e_test.go b/server/cmd/mmctl/commands/user_e2e_test.go index 6a36d42504..1fbba9ec16 100644 --- a/server/cmd/mmctl/commands/user_e2e_test.go +++ b/server/cmd/mmctl/commands/user_e2e_test.go @@ -1070,7 +1070,7 @@ func (s *MmctlE2ETestSuite) TestMigrateAuthCmd() { ldapUser, appErr := s.th.App.CreateUser(s.th.Context, &model.User{ Email: s.th.GenerateTestEmail(), Username: model.NewId(), - AuthData: model.NewString("test.user.1"), + AuthData: model.NewPointer("test.user.1"), AuthService: model.UserAuthServiceLdap, }) s.Require().Nil(appErr) @@ -1078,7 +1078,7 @@ func (s *MmctlE2ETestSuite) TestMigrateAuthCmd() { samlUser, appErr := s.th.App.CreateUser(s.th.Context, &model.User{ Email: "success+devone@simulator.amazonses.com", Username: "dev.one", - AuthData: model.NewString("dev.one"), + AuthData: model.NewPointer("dev.one"), AuthService: model.UserAuthServiceSaml, }) s.Require().Nil(appErr) @@ -1107,7 +1107,7 @@ func (s *MmctlE2ETestSuite) TestMigrateAuthCmd() { s.Require().NoError(err) defer func() { _, appErr := s.th.App.UpdateUserAuth(s.th.Context, ldapUser.Id, &model.UserAuth{ - AuthData: model.NewString("test.user.1"), + AuthData: model.NewPointer("test.user.1"), AuthService: model.UserAuthServiceLdap, }) s.Require().Nil(appErr) @@ -1136,7 +1136,7 @@ func (s *MmctlE2ETestSuite) TestMigrateAuthCmd() { s.Require().NoError(err) defer func() { _, appErr := s.th.App.UpdateUserAuth(s.th.Context, samlUser.Id, &model.UserAuth{ - AuthData: model.NewString("dev.one"), + AuthData: model.NewPointer("dev.one"), AuthService: model.UserAuthServiceSaml, }) s.Require().Nil(appErr) diff --git a/server/cmd/mmctl/commands/user_test.go b/server/cmd/mmctl/commands/user_test.go index d15ff77c45..27d7238e3a 100644 --- a/server/cmd/mmctl/commands/user_test.go +++ b/server/cmd/mmctl/commands/user_test.go @@ -2607,9 +2607,9 @@ func (s *MmctlUnitTestSuite) TestUserConvertCmd() { mockBotUser := model.User{Id: "example", Username: userNameArg, IsBot: true} userPatch := model.UserPatch{ - Email: model.NewString("example@example.com"), - Password: model.NewString("password"), - Username: model.NewString("example-user"), + Email: model.NewPointer("example@example.com"), + Password: model.NewPointer("password"), + Username: model.NewPointer("example-user"), } cmd := &cobra.Command{} @@ -2687,9 +2687,9 @@ func (s *MmctlUnitTestSuite) TestUserConvertCmd() { mockBotUser := model.User{Id: "example", Username: userNameArg, IsBot: true} userPatch := model.UserPatch{ - Email: model.NewString("example@example.com"), - Password: model.NewString("password"), - Username: model.NewString("example-user"), + Email: model.NewPointer("example@example.com"), + Password: model.NewPointer("password"), + Username: model.NewPointer("example-user"), } cmd := &cobra.Command{} diff --git a/server/config/client_test.go b/server/config/client_test.go index f8cc783a42..bd6c9d9923 100644 --- a/server/config/client_test.go +++ b/server/config/client_test.go @@ -25,16 +25,16 @@ func TestGetClientConfig(t *testing.T) { "unlicensed", &model.Config{ EmailSettings: model.EmailSettings{ - EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull), + EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull), }, ThemeSettings: model.ThemeSettings{ // Ignored, since not licensed. - AllowCustomThemes: model.NewBool(false), + AllowCustomThemes: model.NewPointer(false), }, ServiceSettings: model.ServiceSettings{ - WebsocketURL: model.NewString("ws://mattermost.example.com:8065"), - WebsocketPort: model.NewInt(80), - WebsocketSecurePort: model.NewInt(443), + WebsocketURL: model.NewPointer("ws://mattermost.example.com:8065"), + WebsocketPort: model.NewPointer(80), + WebsocketSecurePort: model.NewPointer(443), }, }, "", @@ -53,17 +53,17 @@ func TestGetClientConfig(t *testing.T) { "licensed, but not for theme management", &model.Config{ EmailSettings: model.EmailSettings{ - EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull), + EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull), }, ThemeSettings: model.ThemeSettings{ // Ignored, since not licensed. - AllowCustomThemes: model.NewBool(false), + AllowCustomThemes: model.NewPointer(false), }, }, "tag1", &model.License{ Features: &model.Features{ - ThemeManagement: model.NewBool(false), + ThemeManagement: model.NewPointer(false), }, }, map[string]string{ @@ -76,16 +76,16 @@ func TestGetClientConfig(t *testing.T) { "licensed for theme management", &model.Config{ EmailSettings: model.EmailSettings{ - EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull), + EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull), }, ThemeSettings: model.ThemeSettings{ - AllowCustomThemes: model.NewBool(false), + AllowCustomThemes: model.NewPointer(false), }, }, "tag2", &model.License{ Features: &model.Features{ - ThemeManagement: model.NewBool(true), + ThemeManagement: model.NewPointer(true), }, }, map[string]string{ @@ -98,13 +98,13 @@ func TestGetClientConfig(t *testing.T) { "licensed for enforcement", &model.Config{ ServiceSettings: model.ServiceSettings{ - EnforceMultifactorAuthentication: model.NewBool(true), + EnforceMultifactorAuthentication: model.NewPointer(true), }, }, "tag1", &model.License{ Features: &model.Features{ - MFA: model.NewBool(true), + MFA: model.NewPointer(true), }, }, map[string]string{ @@ -115,7 +115,7 @@ func TestGetClientConfig(t *testing.T) { "default marketplace", &model.Config{ PluginSettings: model.PluginSettings{ - MarketplaceURL: model.NewString(model.PluginSettingsDefaultMarketplaceURL), + MarketplaceURL: model.NewPointer(model.PluginSettingsDefaultMarketplaceURL), }, }, "tag1", @@ -128,7 +128,7 @@ func TestGetClientConfig(t *testing.T) { "non-default marketplace", &model.Config{ PluginSettings: model.PluginSettings{ - MarketplaceURL: model.NewString("http://example.com"), + MarketplaceURL: model.NewPointer("http://example.com"), }, }, "tag1", @@ -141,7 +141,7 @@ func TestGetClientConfig(t *testing.T) { "enable ShowFullName prop", &model.Config{ PrivacySettings: model.PrivacySettings{ - ShowFullName: model.NewBool(true), + ShowFullName: model.NewPointer(true), }, }, "tag1", @@ -190,13 +190,13 @@ func TestGetClientConfig(t *testing.T) { "Shared channels other license", &model.Config{ ExperimentalSettings: model.ExperimentalSettings{ - EnableSharedChannels: model.NewBool(true), + EnableSharedChannels: model.NewPointer(true), }, }, "", &model.License{ Features: &model.Features{ - SharedChannels: model.NewBool(false), + SharedChannels: model.NewPointer(false), }, SkuShortName: "other", }, @@ -208,13 +208,13 @@ func TestGetClientConfig(t *testing.T) { "licensed for shared channels", &model.Config{ ExperimentalSettings: model.ExperimentalSettings{ - EnableSharedChannels: model.NewBool(true), + EnableSharedChannels: model.NewPointer(true), }, }, "", &model.License{ Features: &model.Features{ - SharedChannels: model.NewBool(true), + SharedChannels: model.NewPointer(true), }, SkuShortName: "other", }, @@ -226,13 +226,13 @@ func TestGetClientConfig(t *testing.T) { "Shared channels professional license", &model.Config{ ExperimentalSettings: model.ExperimentalSettings{ - EnableSharedChannels: model.NewBool(true), + EnableSharedChannels: model.NewPointer(true), }, }, "", &model.License{ Features: &model.Features{ - SharedChannels: model.NewBool(false), + SharedChannels: model.NewPointer(false), }, SkuShortName: model.LicenseShortSkuProfessional, }, @@ -244,7 +244,7 @@ func TestGetClientConfig(t *testing.T) { "disable EnableUserStatuses", &model.Config{ ServiceSettings: model.ServiceSettings{ - EnableUserStatuses: model.NewBool(false), + EnableUserStatuses: model.NewPointer(false), }, }, "", @@ -257,13 +257,13 @@ func TestGetClientConfig(t *testing.T) { "Shared channels enterprise license", &model.Config{ ExperimentalSettings: model.ExperimentalSettings{ - EnableSharedChannels: model.NewBool(true), + EnableSharedChannels: model.NewPointer(true), }, }, "", &model.License{ Features: &model.Features{ - SharedChannels: model.NewBool(false), + SharedChannels: model.NewPointer(false), }, SkuShortName: model.LicenseShortSkuEnterprise, }, @@ -275,7 +275,7 @@ func TestGetClientConfig(t *testing.T) { "Disable App Bar", &model.Config{ ExperimentalSettings: model.ExperimentalSettings{ - DisableAppBar: model.NewBool(true), + DisableAppBar: model.NewPointer(true), }, }, "", @@ -297,7 +297,7 @@ func TestGetClientConfig(t *testing.T) { "disable EnableJoinLeaveMessage", &model.Config{ TeamSettings: model.TeamSettings{ - EnableJoinLeaveMessageByDefault: model.NewBool(false), + EnableJoinLeaveMessageByDefault: model.NewPointer(false), }, }, "tag1", @@ -310,7 +310,7 @@ func TestGetClientConfig(t *testing.T) { "test key for GiphySdkKey", &model.Config{ ServiceSettings: model.ServiceSettings{ - GiphySdkKey: model.NewString(""), + GiphySdkKey: model.NewPointer(""), }, }, "", @@ -355,16 +355,16 @@ func TestGetLimitedClientConfig(t *testing.T) { "unlicensed", &model.Config{ EmailSettings: model.EmailSettings{ - EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull), + EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull), }, ThemeSettings: model.ThemeSettings{ // Ignored, since not licensed. - AllowCustomThemes: model.NewBool(false), + AllowCustomThemes: model.NewPointer(false), }, ServiceSettings: model.ServiceSettings{ - WebsocketURL: model.NewString("ws://mattermost.example.com:8065"), - WebsocketPort: model.NewInt(80), - WebsocketSecurePort: model.NewInt(443), + WebsocketURL: model.NewPointer("ws://mattermost.example.com:8065"), + WebsocketPort: model.NewPointer(80), + WebsocketSecurePort: model.NewPointer(443), }, }, "", @@ -381,11 +381,11 @@ func TestGetLimitedClientConfig(t *testing.T) { "password settings", &model.Config{ PasswordSettings: model.PasswordSettings{ - MinimumLength: model.NewInt(15), - Lowercase: model.NewBool(true), - Uppercase: model.NewBool(true), - Number: model.NewBool(true), - Symbol: model.NewBool(false), + MinimumLength: model.NewPointer(15), + Lowercase: model.NewPointer(true), + Uppercase: model.NewPointer(true), + Number: model.NewPointer(true), + Symbol: model.NewPointer(false), }, }, "", diff --git a/server/config/common_test.go b/server/config/common_test.go index f2925e9c98..225974eaa2 100644 --- a/server/config/common_test.go +++ b/server/config/common_test.go @@ -19,23 +19,23 @@ func init() { emptyConfig = &model.Config{} readOnlyConfig = &model.Config{ ClusterSettings: model.ClusterSettings{ - Enable: model.NewBool(true), - ReadOnlyConfig: model.NewBool(true), + Enable: model.NewPointer(true), + ReadOnlyConfig: model.NewPointer(true), }, } minimalConfig = &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("http://minimal"), + SiteURL: model.NewPointer("http://minimal"), }, SqlSettings: model.SqlSettings{ - AtRestEncryptKey: model.NewString("abcdefghijklmnopqrstuvwxyz0123456789"), + AtRestEncryptKey: model.NewPointer("abcdefghijklmnopqrstuvwxyz0123456789"), }, FileSettings: model.FileSettings{ - PublicLinkSalt: model.NewString("abcdefghijklmnopqrstuvwxyz0123456789"), + PublicLinkSalt: model.NewPointer("abcdefghijklmnopqrstuvwxyz0123456789"), }, LocalizationSettings: model.LocalizationSettings{ - DefaultServerLocale: model.NewString("en"), - DefaultClientLocale: model.NewString("en"), + DefaultServerLocale: model.NewPointer("en"), + DefaultClientLocale: model.NewPointer("en"), }, } @@ -46,39 +46,39 @@ func init() { invalidConfig = &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("invalid"), + SiteURL: model.NewPointer("invalid"), }, } fixesRequiredConfig = &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("http://trailingslash/"), + SiteURL: model.NewPointer("http://trailingslash/"), }, SqlSettings: model.SqlSettings{ - AtRestEncryptKey: model.NewString("abcdefghijklmnopqrstuvwxyz0123456789"), + AtRestEncryptKey: model.NewPointer("abcdefghijklmnopqrstuvwxyz0123456789"), }, FileSettings: model.FileSettings{ - DriverName: model.NewString(model.ImageDriverLocal), - Directory: model.NewString("/path/to/directory"), - PublicLinkSalt: model.NewString("abcdefghijklmnopqrstuvwxyz0123456789"), + DriverName: model.NewPointer(model.ImageDriverLocal), + Directory: model.NewPointer("/path/to/directory"), + PublicLinkSalt: model.NewPointer("abcdefghijklmnopqrstuvwxyz0123456789"), }, LocalizationSettings: model.LocalizationSettings{ - DefaultServerLocale: model.NewString("garbage"), - DefaultClientLocale: model.NewString("garbage"), + DefaultServerLocale: model.NewPointer("garbage"), + DefaultClientLocale: model.NewPointer("garbage"), }, } ldapConfig = &model.Config{ LdapSettings: model.LdapSettings{ - BindPassword: model.NewString("password"), + BindPassword: model.NewPointer("password"), }, } testConfig = &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("http://TestStoreNew"), + SiteURL: model.NewPointer("http://TestStoreNew"), }, } customConfigDefaults = &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("http://custom.com"), + SiteURL: model.NewPointer("http://custom.com"), }, } } @@ -110,7 +110,7 @@ func TestMergeConfigs(t *testing.T) { base := &model.Config{} base.SetDefaults() patch := base.Clone() - patch.ServiceSettings.SiteURL = model.NewString("http://newhost.ca") + patch.ServiceSettings.SiteURL = model.NewPointer("http://newhost.ca") merged, err := Merge(base, patch, nil) require.NoError(t, err) @@ -122,12 +122,12 @@ func TestMergeConfigs(t *testing.T) { base := &model.Config{} base.SetDefaults() patch := &model.Config{} - patch.ServiceSettings.SiteURL = model.NewString("http://newhost.ca") - patch.GoogleSettings.Enable = model.NewBool(true) + patch.ServiceSettings.SiteURL = model.NewPointer("http://newhost.ca") + patch.GoogleSettings.Enable = model.NewPointer(true) expected := base.Clone() - expected.ServiceSettings.SiteURL = model.NewString("http://newhost.ca") - expected.GoogleSettings.Enable = model.NewBool(true) + expected.ServiceSettings.SiteURL = model.NewPointer("http://newhost.ca") + expected.GoogleSettings.Enable = model.NewPointer(true) merged, err := Merge(base, patch, nil) require.NoError(t, err) @@ -144,7 +144,7 @@ func TestConfigEnvironmentOverrides(t *testing.T) { base, err := NewStoreFromBacking(memstore, nil, false) require.NoError(t, err) originalConfig := &model.Config{} - originalConfig.ServiceSettings.SiteURL = model.NewString("http://notoverridden.ca") + originalConfig.ServiceSettings.SiteURL = model.NewPointer("http://notoverridden.ca") os.Setenv("MM_SERVICESETTINGS_SITEURL", "http://overridden.ca") defer os.Unsetenv("MM_SERVICESETTINGS_SITEURL") diff --git a/server/config/database.go b/server/config/database.go index 51a8e0ac97..c7174f462a 100644 --- a/server/config/database.go +++ b/server/config/database.go @@ -316,8 +316,8 @@ func (ds *DatabaseStore) Load() ([]byte, error) { // Initialize from the default config if no active configuration could be found. if len(configurationData) == 0 { configWithDB := model.Config{} - configWithDB.SqlSettings.DriverName = model.NewString(ds.driverName) - configWithDB.SqlSettings.DataSource = model.NewString(ds.dataSourceName) + configWithDB.SqlSettings.DriverName = model.NewPointer(ds.driverName) + configWithDB.SqlSettings.DataSource = model.NewPointer(ds.dataSourceName) return json.Marshal(configWithDB) } diff --git a/server/config/database_test.go b/server/config/database_test.go index c92aaeb5d5..b096c2b3b4 100644 --- a/server/config/database_test.go +++ b/server/config/database_test.go @@ -451,7 +451,7 @@ func TestDatabaseStoreSet(t *testing.T) { defer ds.Close() newCfg := &model.Config{} - newCfg.LdapSettings.BindPassword = model.NewString(model.FakeSetting) + newCfg.LdapSettings.BindPassword = model.NewPointer(model.FakeSetting) _, _, err = ds.Set(newCfg) require.NoError(t, err) @@ -468,7 +468,7 @@ func TestDatabaseStoreSet(t *testing.T) { defer ds.Close() newCfg := &model.Config{} - newCfg.ServiceSettings.SiteURL = model.NewString("invalid") + newCfg.ServiceSettings.SiteURL = model.NewPointer("invalid") _, _, err = ds.Set(newCfg) if assert.Error(t, err) { @@ -507,7 +507,7 @@ func TestDatabaseStoreSet(t *testing.T) { newCfg := &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("http://new"), + SiteURL: model.NewPointer("http://new"), }, } @@ -527,7 +527,7 @@ func TestDatabaseStoreSet(t *testing.T) { newCfg := &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("http://new"), + SiteURL: model.NewPointer("http://new"), }, } @@ -573,7 +573,7 @@ func TestDatabaseStoreSet(t *testing.T) { longSiteURL := fmt.Sprintf("http://%s", strings.Repeat("a", MaxWriteLength)) newCfg := emptyConfig.Clone() - newCfg.ServiceSettings.SiteURL = model.NewString(longSiteURL) + newCfg.ServiceSettings.SiteURL = model.NewPointer(longSiteURL) _, _, err = ds.Set(newCfg) require.Error(t, err) @@ -1128,7 +1128,7 @@ func TestCleanUp(t *testing.T) { b, err := marshalConfig(ds.config) require.NoError(t, err) - ds.config.JobSettings.CleanupConfigThresholdDays = model.NewInt(30) // we set 30 days as threshold + ds.config.JobSettings.CleanupConfigThresholdDays = model.NewPointer(30) // we set 30 days as threshold now := time.Now() for i := 0; i < 5; i++ { diff --git a/server/config/diff_test.go b/server/config/diff_test.go index 43b6a07c1e..73300799d3 100644 --- a/server/config/diff_test.go +++ b/server/config/diff_test.go @@ -57,11 +57,11 @@ func BenchmarkDiff(b *testing.B) { b.Run("some diffs", func(b *testing.B) { baseCfg := defaultConfigGen() actualCfg := defaultConfigGen() - baseCfg.ServiceSettings.SiteURL = model.NewString("http://localhost") - baseCfg.ServiceSettings.ReadTimeout = model.NewInt(300) - baseCfg.SqlSettings.QueryTimeout = model.NewInt(0) + baseCfg.ServiceSettings.SiteURL = model.NewPointer("http://localhost") + baseCfg.ServiceSettings.ReadTimeout = model.NewPointer(300) + baseCfg.SqlSettings.QueryTimeout = model.NewPointer(0) actualCfg.PluginSettings.EnableUploads = nil - actualCfg.TeamSettings.MaxChannelsPerTeam = model.NewInt64(100000) + actualCfg.TeamSettings.MaxChannelsPerTeam = model.NewPointer(int64(100000)) actualCfg.FeatureFlags = nil actualCfg.SqlSettings.DataSourceReplicas = []string{ "ds0", @@ -142,12 +142,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive LdapSettings.BindPassword", func() *model.Config { cfg := defaultConfigGen() - cfg.LdapSettings.BindPassword = model.NewString("base") + cfg.LdapSettings.BindPassword = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.LdapSettings.BindPassword = model.NewString("actual") + cfg.LdapSettings.BindPassword = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -163,12 +163,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive FileSettings.PublicLinkSalt", func() *model.Config { cfg := defaultConfigGen() - cfg.FileSettings.PublicLinkSalt = model.NewString("base") + cfg.FileSettings.PublicLinkSalt = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.FileSettings.PublicLinkSalt = model.NewString("actual") + cfg.FileSettings.PublicLinkSalt = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -184,12 +184,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive FileSettings.AmazonS3SecretAccessKey", func() *model.Config { cfg := defaultConfigGen() - cfg.FileSettings.AmazonS3SecretAccessKey = model.NewString("base") + cfg.FileSettings.AmazonS3SecretAccessKey = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.FileSettings.AmazonS3SecretAccessKey = model.NewString("actual") + cfg.FileSettings.AmazonS3SecretAccessKey = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -205,12 +205,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive SqlSettings.DataSource", func() *model.Config { cfg := defaultConfigGen() - cfg.SqlSettings.DataSource = model.NewString("base") + cfg.SqlSettings.DataSource = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.SqlSettings.DataSource = model.NewString("actual") + cfg.SqlSettings.DataSource = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -226,12 +226,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive SqlSettings.AtRestEncryptKey", func() *model.Config { cfg := defaultConfigGen() - cfg.SqlSettings.AtRestEncryptKey = model.NewString("base") + cfg.SqlSettings.AtRestEncryptKey = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.SqlSettings.AtRestEncryptKey = model.NewString("actual") + cfg.SqlSettings.AtRestEncryptKey = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -303,12 +303,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive EmailSettings.SMTPPassword", func() *model.Config { cfg := defaultConfigGen() - cfg.EmailSettings.SMTPPassword = model.NewString("base") + cfg.EmailSettings.SMTPPassword = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.EmailSettings.SMTPPassword = model.NewString("actual") + cfg.EmailSettings.SMTPPassword = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -324,12 +324,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive GitLabSettings.Secret", func() *model.Config { cfg := defaultConfigGen() - cfg.GitLabSettings.Secret = model.NewString("base") + cfg.GitLabSettings.Secret = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.GitLabSettings.Secret = model.NewString("actual") + cfg.GitLabSettings.Secret = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -345,12 +345,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive GoogleSettings.Secret", func() *model.Config { cfg := defaultConfigGen() - cfg.GoogleSettings.Secret = model.NewString("base") + cfg.GoogleSettings.Secret = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.GoogleSettings.Secret = model.NewString("actual") + cfg.GoogleSettings.Secret = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -366,12 +366,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive Office365Settings.Secret", func() *model.Config { cfg := defaultConfigGen() - cfg.Office365Settings.Secret = model.NewString("base") + cfg.Office365Settings.Secret = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.Office365Settings.Secret = model.NewString("actual") + cfg.Office365Settings.Secret = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -387,12 +387,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive OpenIdSettings.Secret", func() *model.Config { cfg := defaultConfigGen() - cfg.OpenIdSettings.Secret = model.NewString("base") + cfg.OpenIdSettings.Secret = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.OpenIdSettings.Secret = model.NewString("actual") + cfg.OpenIdSettings.Secret = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -408,12 +408,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive ElasticsearchSettings.Password", func() *model.Config { cfg := defaultConfigGen() - cfg.ElasticsearchSettings.Password = model.NewString("base") + cfg.ElasticsearchSettings.Password = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.ElasticsearchSettings.Password = model.NewString("actual") + cfg.ElasticsearchSettings.Password = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -430,18 +430,18 @@ func TestDiffSanitized(t *testing.T) { func() *model.Config { cfg := defaultConfigGen() cfg.MessageExportSettings.GlobalRelaySettings = &model.GlobalRelayMessageExportSettings{ - SMTPUsername: model.NewString("base"), - SMTPPassword: model.NewString("base"), - EmailAddress: model.NewString("base"), + SMTPUsername: model.NewPointer("base"), + SMTPPassword: model.NewPointer("base"), + EmailAddress: model.NewPointer("base"), } return cfg }(), func() *model.Config { cfg := defaultConfigGen() cfg.MessageExportSettings.GlobalRelaySettings = &model.GlobalRelayMessageExportSettings{ - SMTPUsername: model.NewString("actual"), - SMTPPassword: model.NewString("actual"), - EmailAddress: model.NewString("actual"), + SMTPUsername: model.NewPointer("actual"), + SMTPPassword: model.NewPointer("actual"), + EmailAddress: model.NewPointer("actual"), } return cfg }(), @@ -468,12 +468,12 @@ func TestDiffSanitized(t *testing.T) { "sensitive ServiceSettings.SplitKey", func() *model.Config { cfg := defaultConfigGen() - cfg.ServiceSettings.SplitKey = model.NewString("base") + cfg.ServiceSettings.SplitKey = model.NewPointer("base") return cfg }(), func() *model.Config { cfg := defaultConfigGen() - cfg.ServiceSettings.SplitKey = model.NewString("actual") + cfg.ServiceSettings.SplitKey = model.NewPointer("actual") return cfg }(), ConfigDiffs{ @@ -582,7 +582,7 @@ func TestDiff(t *testing.T) { defaultConfigGen(), func() *model.Config { cfg := defaultConfigGen() - cfg.ServiceSettings.SiteURL = model.NewString("http://changed") + cfg.ServiceSettings.SiteURL = model.NewPointer("http://changed") return cfg }(), ConfigDiffs{ @@ -618,7 +618,7 @@ func TestDiff(t *testing.T) { defaultConfigGen(), func() *model.Config { cfg := defaultConfigGen() - cfg.PluginSettings.Enable = model.NewBool(!*cfg.PluginSettings.Enable) + cfg.PluginSettings.Enable = model.NewPointer(!*cfg.PluginSettings.Enable) return cfg }(), ConfigDiffs{ @@ -654,7 +654,7 @@ func TestDiff(t *testing.T) { defaultConfigGen(), func() *model.Config { cfg := defaultConfigGen() - cfg.ServiceSettings.ReadTimeout = model.NewInt(0) + cfg.ServiceSettings.ReadTimeout = model.NewPointer(0) return cfg }(), ConfigDiffs{ diff --git a/server/config/file_test.go b/server/config/file_test.go index 00b7b1225b..db96129db3 100644 --- a/server/config/file_test.go +++ b/server/config/file_test.go @@ -476,7 +476,7 @@ func TestFileStoreSet(t *testing.T) { defer tearDown() newCfg := &model.Config{} - newCfg.LdapSettings.BindPassword = model.NewString(model.FakeSetting) + newCfg.LdapSettings.BindPassword = model.NewPointer(model.FakeSetting) _, newConfig, err := configStore.Set(newCfg) require.NoError(t, err) @@ -490,7 +490,7 @@ func TestFileStoreSet(t *testing.T) { defer tearDown() newCfg := &model.Config{} - newCfg.ServiceSettings.SiteURL = model.NewString("invalid") + newCfg.ServiceSettings.SiteURL = model.NewPointer("invalid") _, _, err := configStore.Set(newCfg) if assert.Error(t, err) { @@ -506,7 +506,7 @@ func TestFileStoreSet(t *testing.T) { newReadOnlyConfig := readOnlyConfig.Clone() newReadOnlyConfig.ServiceSettings = model.ServiceSettings{ - SiteURL: model.NewString("http://test"), + SiteURL: model.NewPointer("http://test"), } _, _, err := configStore.Set(newReadOnlyConfig) if assert.Error(t, err) { @@ -565,7 +565,7 @@ func TestFileStoreSet(t *testing.T) { callback := func(oldCfg, newCfg *model.Config) { require.NotEqual(t, oldCfg, newCfg) expectedConfig := minimalConfig.Clone() - expectedConfig.ServiceSettings.SiteURL = model.NewString("http://override") + expectedConfig.ServiceSettings.SiteURL = model.NewPointer("http://override") require.Equal(t, minimalConfig, oldCfg) require.Equal(t, expectedConfig, newCfg) called <- true @@ -911,7 +911,7 @@ func TestFileStoreLoad(t *testing.T) { callback := func(oldCfg, newCfg *model.Config) { require.NotEqual(t, oldCfg, newCfg) expectedConfig := minimalConfig.Clone() - expectedConfig.ServiceSettings.SiteURL = model.NewString("http://override") + expectedConfig.ServiceSettings.SiteURL = model.NewPointer("http://override") require.Equal(t, minimalConfig, oldCfg) require.Equal(t, expectedConfig, newCfg) called <- true @@ -934,7 +934,7 @@ func TestFileStoreSave(t *testing.T) { newCfg := &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("http://new"), + SiteURL: model.NewPointer("http://new"), }, } diff --git a/server/config/logger_test.go b/server/config/logger_test.go index fbc51507d3..fd18fce37d 100644 --- a/server/config/logger_test.go +++ b/server/config/logger_test.go @@ -16,13 +16,13 @@ import ( func TestMloggerConfigFromAuditConfig(t *testing.T) { auditSettings := model.ExperimentalAuditSettings{ - FileEnabled: model.NewBool(true), - FileName: model.NewString("audit.log"), - FileMaxSizeMB: model.NewInt(20), - FileMaxAgeDays: model.NewInt(1), - FileMaxBackups: model.NewInt(5), - FileCompress: model.NewBool(true), - FileMaxQueueSize: model.NewInt(5000), + FileEnabled: model.NewPointer(true), + FileName: model.NewPointer("audit.log"), + FileMaxSizeMB: model.NewPointer(20), + FileMaxAgeDays: model.NewPointer(1), + FileMaxBackups: model.NewPointer(5), + FileCompress: model.NewPointer(true), + FileMaxQueueSize: model.NewPointer(5000), } t.Run("validate default audit settings", func(t *testing.T) { diff --git a/server/config/migrate_test.go b/server/config/migrate_test.go index e69efe4396..3941914a4a 100644 --- a/server/config/migrate_test.go +++ b/server/config/migrate_test.go @@ -55,7 +55,7 @@ func TestMigrate(t *testing.T) { cfg := source.Get() originalCfg := cfg.Clone() - cfg.ServiceSettings.SiteURL = model.NewString("http://example.com") + cfg.ServiceSettings.SiteURL = model.NewPointer("http://example.com") cfg.SamlSettings.IdpCertificateFile = &files[0] cfg.SamlSettings.PublicCertificateFile = &files[1] cfg.SamlSettings.PrivateKeyFile = &files[2] diff --git a/server/config/store.go b/server/config/store.go index 3353ebeb37..9f1337f8e3 100644 --- a/server/config/store.go +++ b/server/config/store.go @@ -278,7 +278,7 @@ func (s *Store) Load() error { // SetDefaults() will generate missing data. This avoids an additional write // to the backing store. if loadedCfg.ServiceSettings.SiteURL == nil { - loadedCfg.ServiceSettings.SiteURL = model.NewString("") + loadedCfg.ServiceSettings.SiteURL = model.NewPointer("") } // Setting defaults allows us to accept partial config objects. diff --git a/server/config/utils_test.go b/server/config/utils_test.go index 18dce8561f..3ed0bf23d9 100644 --- a/server/config/utils_test.go +++ b/server/config/utils_test.go @@ -18,19 +18,19 @@ func TestDesanitize(t *testing.T) { actual.SetDefaults() // These setting should be ignored - actual.LdapSettings.Enable = model.NewBool(false) - actual.FileSettings.DriverName = model.NewString("s3") + actual.LdapSettings.Enable = model.NewPointer(false) + actual.FileSettings.DriverName = model.NewPointer("s3") // These settings should be desanitized into target. - actual.LdapSettings.BindPassword = model.NewString("bind_password") - actual.FileSettings.PublicLinkSalt = model.NewString("public_link_salt") - actual.FileSettings.AmazonS3SecretAccessKey = model.NewString("amazon_s3_secret_access_key") - actual.EmailSettings.SMTPPassword = model.NewString("smtp_password") - actual.GitLabSettings.Secret = model.NewString("secret") - actual.OpenIdSettings.Secret = model.NewString("secret") - actual.SqlSettings.DataSource = model.NewString("data_source") - actual.SqlSettings.AtRestEncryptKey = model.NewString("at_rest_encrypt_key") - actual.ElasticsearchSettings.Password = model.NewString("password") + actual.LdapSettings.BindPassword = model.NewPointer("bind_password") + actual.FileSettings.PublicLinkSalt = model.NewPointer("public_link_salt") + actual.FileSettings.AmazonS3SecretAccessKey = model.NewPointer("amazon_s3_secret_access_key") + actual.EmailSettings.SMTPPassword = model.NewPointer("smtp_password") + actual.GitLabSettings.Secret = model.NewPointer("secret") + actual.OpenIdSettings.Secret = model.NewPointer("secret") + actual.SqlSettings.DataSource = model.NewPointer("data_source") + actual.SqlSettings.AtRestEncryptKey = model.NewPointer("at_rest_encrypt_key") + actual.ElasticsearchSettings.Password = model.NewPointer("password") actual.SqlSettings.DataSourceReplicas = append(actual.SqlSettings.DataSourceReplicas, "replica0") actual.SqlSettings.DataSourceReplicas = append(actual.SqlSettings.DataSourceReplicas, "replica1") actual.SqlSettings.DataSourceSearchReplicas = append(actual.SqlSettings.DataSourceSearchReplicas, "search_replica0") @@ -40,19 +40,19 @@ func TestDesanitize(t *testing.T) { target.SetDefaults() // These setting should be ignored - target.LdapSettings.Enable = model.NewBool(true) - target.FileSettings.DriverName = model.NewString("file") + target.LdapSettings.Enable = model.NewPointer(true) + target.FileSettings.DriverName = model.NewPointer("file") // These settings should be updated from actual - target.LdapSettings.BindPassword = model.NewString(model.FakeSetting) - target.FileSettings.PublicLinkSalt = model.NewString(model.FakeSetting) - target.FileSettings.AmazonS3SecretAccessKey = model.NewString(model.FakeSetting) - target.EmailSettings.SMTPPassword = model.NewString(model.FakeSetting) - target.GitLabSettings.Secret = model.NewString(model.FakeSetting) - target.OpenIdSettings.Secret = model.NewString(model.FakeSetting) - target.SqlSettings.DataSource = model.NewString(model.FakeSetting) - target.SqlSettings.AtRestEncryptKey = model.NewString(model.FakeSetting) - target.ElasticsearchSettings.Password = model.NewString(model.FakeSetting) + target.LdapSettings.BindPassword = model.NewPointer(model.FakeSetting) + target.FileSettings.PublicLinkSalt = model.NewPointer(model.FakeSetting) + target.FileSettings.AmazonS3SecretAccessKey = model.NewPointer(model.FakeSetting) + target.EmailSettings.SMTPPassword = model.NewPointer(model.FakeSetting) + target.GitLabSettings.Secret = model.NewPointer(model.FakeSetting) + target.OpenIdSettings.Secret = model.NewPointer(model.FakeSetting) + target.SqlSettings.DataSource = model.NewPointer(model.FakeSetting) + target.SqlSettings.AtRestEncryptKey = model.NewPointer(model.FakeSetting) + target.ElasticsearchSettings.Password = model.NewPointer(model.FakeSetting) target.SqlSettings.DataSourceReplicas = []string{model.FakeSetting, model.FakeSetting} target.SqlSettings.DataSourceSearchReplicas = []string{model.FakeSetting, model.FakeSetting} diff --git a/server/platform/services/imageproxy/atmos_camo_test.go b/server/platform/services/imageproxy/atmos_camo_test.go index d11036f30b..40a0756b3e 100644 --- a/server/platform/services/imageproxy/atmos_camo_test.go +++ b/server/platform/services/imageproxy/atmos_camo_test.go @@ -22,14 +22,14 @@ func makeTestAtmosCamoProxy() *ImageProxy { configService := &testutils.StaticConfigService{ Cfg: &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("https://mattermost.example.com"), - AllowedUntrustedInternalConnections: model.NewString("127.0.0.1"), + SiteURL: model.NewPointer("https://mattermost.example.com"), + AllowedUntrustedInternalConnections: model.NewPointer("127.0.0.1"), }, ImageProxySettings: model.ImageProxySettings{ - Enable: model.NewBool(true), - ImageProxyType: model.NewString(model.ImageProxyTypeAtmosCamo), - RemoteImageProxyURL: model.NewString("http://images.example.com"), - RemoteImageProxyOptions: model.NewString("7e5f3fab20b94782b43cdb022a66985ef28ba355df2c5d5da3c9a05e4b697bac"), + Enable: model.NewPointer(true), + ImageProxyType: model.NewPointer(model.ImageProxyTypeAtmosCamo), + RemoteImageProxyURL: model.NewPointer("http://images.example.com"), + RemoteImageProxyOptions: model.NewPointer("7e5f3fab20b94782b43cdb022a66985ef28ba355df2c5d5da3c9a05e4b697bac"), }, }, } diff --git a/server/platform/services/imageproxy/imageproxy_test.go b/server/platform/services/imageproxy/imageproxy_test.go index 537d52cc2c..e6b7545ec3 100644 --- a/server/platform/services/imageproxy/imageproxy_test.go +++ b/server/platform/services/imageproxy/imageproxy_test.go @@ -125,14 +125,14 @@ func TestOnConfigChange(t *testing.T) { require.Equal(t, "https://mattermost.example.com", proxy.backend.(*AtmosCamoBackend).siteURL.String()) newConfig := proxy.ConfigService.Config().Clone() - newConfig.ImageProxySettings.ImageProxyType = model.NewString(model.ImageProxyTypeLocal) + newConfig.ImageProxySettings.ImageProxyType = model.NewPointer(model.ImageProxyTypeLocal) proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig) require.Equal(t, "https://mattermost.example.com", proxy.backend.(*LocalBackend).baseURL.String()) newConfig = proxy.ConfigService.Config().Clone() - newConfig.ImageProxySettings.ImageProxyType = model.NewString(model.ImageProxyTypeAtmosCamo) + newConfig.ImageProxySettings.ImageProxyType = model.NewPointer(model.ImageProxyTypeAtmosCamo) proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig) @@ -146,7 +146,7 @@ func TestOnConfigChange(t *testing.T) { require.Equal(t, "https://mattermost.example.com", proxy.backend.(*LocalBackend).baseURL.String()) newConfig := proxy.ConfigService.Config().Clone() - newConfig.ServiceSettings.SiteURL = model.NewString("https://new.example.com") + newConfig.ServiceSettings.SiteURL = model.NewPointer("https://new.example.com") proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig) @@ -161,7 +161,7 @@ func TestOnConfigChange(t *testing.T) { require.Equal(t, "https://mattermost.example.com", proxy.backend.(*AtmosCamoBackend).siteURL.String()) newConfig := proxy.ConfigService.Config().Clone() - newConfig.ServiceSettings.SiteURL = model.NewString("https://new.example.com") + newConfig.ServiceSettings.SiteURL = model.NewPointer("https://new.example.com") proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig) @@ -176,8 +176,8 @@ func TestOnConfigChange(t *testing.T) { // require.Equal(t, "7e5f3fab20b94782b43cdb022a66985ef28ba355df2c5d5da3c9a05e4b697bac", proxy.backend.(*AtmosCamoBackend).remoteOptions) newConfig := proxy.ConfigService.Config().Clone() - newConfig.ImageProxySettings.RemoteImageProxyURL = model.NewString("https://new.example.com") - newConfig.ImageProxySettings.RemoteImageProxyOptions = model.NewString("some other random hash") + newConfig.ImageProxySettings.RemoteImageProxyURL = model.NewPointer("https://new.example.com") + newConfig.ImageProxySettings.RemoteImageProxyOptions = model.NewPointer("some other random hash") proxy.ConfigService.(*testutils.StaticConfigService).UpdateConfig(newConfig) diff --git a/server/platform/services/imageproxy/local_test.go b/server/platform/services/imageproxy/local_test.go index ce899a5be3..33478e6e1a 100644 --- a/server/platform/services/imageproxy/local_test.go +++ b/server/platform/services/imageproxy/local_test.go @@ -22,12 +22,12 @@ func makeTestLocalProxy() *ImageProxy { configService := &testutils.StaticConfigService{ Cfg: &model.Config{ ServiceSettings: model.ServiceSettings{ - SiteURL: model.NewString("https://mattermost.example.com"), - AllowedUntrustedInternalConnections: model.NewString("127.0.0.1"), + SiteURL: model.NewPointer("https://mattermost.example.com"), + AllowedUntrustedInternalConnections: model.NewPointer("127.0.0.1"), }, ImageProxySettings: model.ImageProxySettings{ - Enable: model.NewBool(true), - ImageProxyType: model.NewString(model.ImageProxyTypeLocal), + Enable: model.NewPointer(true), + ImageProxyType: model.NewPointer(model.ImageProxyTypeLocal), }, }, } diff --git a/server/platform/services/remotecluster/sendprofileImage_test.go b/server/platform/services/remotecluster/sendprofileImage_test.go index c99d453a2e..f0c1326743 100644 --- a/server/platform/services/remotecluster/sendprofileImage_test.go +++ b/server/platform/services/remotecluster/sendprofileImage_test.go @@ -95,7 +95,7 @@ func TestService_sendProfileImageToRemote(t *testing.T) { user := &model.User{ Id: model.NewId(), - RemoteId: model.NewString(rc.RemoteId), + RemoteId: model.NewPointer(rc.RemoteId), } provider := testImageProvider{} diff --git a/server/platform/services/searchengine/bleveengine/bleve_test.go b/server/platform/services/searchengine/bleveengine/bleve_test.go index 7febff704b..4dc1a0bee0 100644 --- a/server/platform/services/searchengine/bleveengine/bleve_test.go +++ b/server/platform/services/searchengine/bleveengine/bleve_test.go @@ -62,11 +62,11 @@ func (s *BleveEngineTestSuite) setupStore() { cfg := &model.Config{} cfg.SetDefaults() - cfg.BleveSettings.EnableIndexing = model.NewBool(true) - cfg.BleveSettings.EnableSearching = model.NewBool(true) - cfg.BleveSettings.EnableAutocomplete = model.NewBool(true) - cfg.BleveSettings.IndexDir = model.NewString(s.IndexDir) - cfg.SqlSettings.DisableDatabaseSearch = model.NewBool(true) + cfg.BleveSettings.EnableIndexing = model.NewPointer(true) + cfg.BleveSettings.EnableSearching = model.NewPointer(true) + cfg.BleveSettings.EnableAutocomplete = model.NewPointer(true) + cfg.BleveSettings.IndexDir = model.NewPointer(s.IndexDir) + cfg.SqlSettings.DisableDatabaseSearch = model.NewPointer(true) s.SearchEngine = searchengine.NewBroker(cfg) s.Store = searchlayer.NewSearchLayer(&testlib.TestStore{Store: s.SQLStore}, s.SearchEngine, cfg) diff --git a/server/platform/services/searchengine/bleveengine/indexer/indexing_job_test.go b/server/platform/services/searchengine/bleveengine/indexer/indexing_job_test.go index 60fa5d08a7..796a30cb96 100644 --- a/server/platform/services/searchengine/bleveengine/indexer/indexing_job_test.go +++ b/server/platform/services/searchengine/bleveengine/indexer/indexing_job_test.go @@ -43,8 +43,8 @@ func TestBleveIndexer(t *testing.T) { cfg := &model.Config{ BleveSettings: model.BleveSettings{ - EnableIndexing: model.NewBool(true), - IndexDir: model.NewString(tempDir), + EnableIndexing: model.NewPointer(true), + IndexDir: model.NewPointer(tempDir), }, } diff --git a/server/platform/services/sharedchannel/channelinvite.go b/server/platform/services/sharedchannel/channelinvite.go index 24f642c124..d4499c946f 100644 --- a/server/platform/services/sharedchannel/channelinvite.go +++ b/server/platform/services/sharedchannel/channelinvite.go @@ -276,7 +276,7 @@ func (scs *Service) handleChannelCreation(invite channelInviteMsg, rc *model.Rem Header: invite.Header, Purpose: invite.Purpose, CreatorId: rc.CreatorId, - Shared: model.NewBool(true), + Shared: model.NewPointer(true), } // check user perms? diff --git a/server/platform/services/sharedchannel/channelinvite_test.go b/server/platform/services/sharedchannel/channelinvite_test.go index 0471cc8aaf..14ae9a45e1 100644 --- a/server/platform/services/sharedchannel/channelinvite_test.go +++ b/server/platform/services/sharedchannel/channelinvite_test.go @@ -93,8 +93,8 @@ func TestOnReceiveChannelInvite(t *testing.T) { createPostPermission := model.ChannelModeratedPermissionsMap[model.PermissionCreatePost.Id] createReactionPermission := model.ChannelModeratedPermissionsMap[model.PermissionAddReaction.Id] updateMap := model.ChannelModeratedRolesPatch{ - Guests: model.NewBool(false), - Members: model.NewBool(false), + Guests: model.NewPointer(false), + Members: model.NewPointer(false), } mockApp.On("CreateChannelWithUser", mockTypeReqContext, mockTypeChannel, mockTypeString).Return(channel, nil) @@ -175,7 +175,7 @@ func TestOnReceiveChannelInvite(t *testing.T) { {"two remotes", &model.User{Id: model.NewId(), RemoteId: &testRemoteID}, &model.User{Id: model.NewId(), RemoteId: &testRemoteID}, true, false}, {"two locals", &model.User{Id: model.NewId()}, &model.User{Id: model.NewId()}, true, false}, {"can't see", &model.User{Id: model.NewId(), RemoteId: &testRemoteID}, &model.User{Id: model.NewId()}, false, false}, - {"invalid remoteid", &model.User{Id: model.NewId(), RemoteId: model.NewString("bogus")}, &model.User{Id: model.NewId()}, true, false}, + {"invalid remoteid", &model.User{Id: model.NewId(), RemoteId: model.NewPointer("bogus")}, &model.User{Id: model.NewId()}, true, false}, } for _, tc := range testCases { diff --git a/server/platform/services/sharedchannel/service.go b/server/platform/services/sharedchannel/service.go index 918d53d3ea..04044c3a03 100644 --- a/server/platform/services/sharedchannel/service.go +++ b/server/platform/services/sharedchannel/service.go @@ -220,8 +220,8 @@ func (scs *Service) makeChannelReadOnly(channel *model.Channel) *model.AppError createPostPermission := model.ChannelModeratedPermissionsMap[model.PermissionCreatePost.Id] createReactionPermission := model.ChannelModeratedPermissionsMap[model.PermissionAddReaction.Id] updateMap := model.ChannelModeratedRolesPatch{ - Guests: model.NewBool(false), - Members: model.NewBool(false), + Guests: model.NewPointer(false), + Members: model.NewPointer(false), } readonlyChannelModerations := []*model.ChannelModerationPatch{ diff --git a/server/platform/services/sharedchannel/sync_recv.go b/server/platform/services/sharedchannel/sync_recv.go index 21db2f10c8..b258fb5c5c 100644 --- a/server/platform/services/sharedchannel/sync_recv.go +++ b/server/platform/services/sharedchannel/sync_recv.go @@ -194,7 +194,7 @@ func (scs *Service) upsertSyncUser(c request.CTX, user *model.User, channel *mod var userSaved *model.User if euser == nil { // new user. Make sure the remoteID is correct and insert the record - user.RemoteId = model.NewString(rc.RemoteId) + user.RemoteId = model.NewPointer(rc.RemoteId) if userSaved, err = scs.insertSyncUser(c, user, channel, rc); err != nil { return nil, err } @@ -353,7 +353,7 @@ func (scs *Service) updateSyncUser(rctx request.CTX, patch *model.UserPatch, use func (scs *Service) upsertSyncPost(post *model.Post, targetChannel *model.Channel, rc *model.RemoteCluster) (*model.Post, error) { var appErr *model.AppError - post.RemoteId = model.NewString(rc.RemoteId) + post.RemoteId = model.NewPointer(rc.RemoteId) rctx := request.EmptyContext(scs.server.Log()) rpost, err := scs.server.GetStore().Post().GetSingle(rctx, post.Id, true) @@ -450,7 +450,7 @@ func (scs *Service) upsertSyncReaction(reaction *model.Reaction, targetChannel * if user.GetRemoteID() != rc.RemoteId { return nil, fmt.Errorf("reaction sync failed: %w", ErrRemoteIDMismatch) } - reaction.RemoteId = model.NewString(rc.RemoteId) + reaction.RemoteId = model.NewPointer(rc.RemoteId) savedReaction, appErr = scs.app.SaveReactionForPost(request.EmptyContext(scs.server.Log()), reaction) } else { // make sure the reaction being deleted is owned by the remote diff --git a/server/platform/shared/filestore/filesstore_test.go b/server/platform/shared/filestore/filesstore_test.go index df2b721659..d57fb07abe 100644 --- a/server/platform/shared/filestore/filesstore_test.go +++ b/server/platform/shared/filestore/filesstore_test.go @@ -713,8 +713,8 @@ func TestNewExportFileBackendSettingsFromConfig(t *testing.T) { } actual := NewExportFileBackendSettingsFromConfig(&model.FileSettings{ - ExportDriverName: model.NewString(driverLocal), - ExportDirectory: model.NewString("directory"), + ExportDriverName: model.NewPointer(driverLocal), + ExportDirectory: model.NewPointer("directory"), }, enableComplianceFeature, skipVerify) require.Equal(t, expected, actual) @@ -744,20 +744,20 @@ func TestNewExportFileBackendSettingsFromConfig(t *testing.T) { } actual := NewExportFileBackendSettingsFromConfig(&model.FileSettings{ - ExportDriverName: model.NewString(driverS3), - ExportAmazonS3AccessKeyId: model.NewString("minioaccesskey"), - ExportAmazonS3SecretAccessKey: model.NewString("miniosecretkey"), - ExportAmazonS3Bucket: model.NewString("mattermost-test"), - ExportAmazonS3Region: model.NewString("region"), - ExportAmazonS3Endpoint: model.NewString("s3.example.com"), - ExportAmazonS3PathPrefix: model.NewString("prefix"), - ExportAmazonS3SSL: model.NewBool(true), - ExportAmazonS3SignV2: model.NewBool(true), - ExportAmazonS3SSE: model.NewBool(true), - ExportAmazonS3Trace: model.NewBool(true), - ExportAmazonS3RequestTimeoutMilliseconds: model.NewInt64(1000), - ExportAmazonS3PresignExpiresSeconds: model.NewInt64(60000), - ExportAmazonS3UploadPartSizeBytes: model.NewInt64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes), + ExportDriverName: model.NewPointer(driverS3), + ExportAmazonS3AccessKeyId: model.NewPointer("minioaccesskey"), + ExportAmazonS3SecretAccessKey: model.NewPointer("miniosecretkey"), + ExportAmazonS3Bucket: model.NewPointer("mattermost-test"), + ExportAmazonS3Region: model.NewPointer("region"), + ExportAmazonS3Endpoint: model.NewPointer("s3.example.com"), + ExportAmazonS3PathPrefix: model.NewPointer("prefix"), + ExportAmazonS3SSL: model.NewPointer(true), + ExportAmazonS3SignV2: model.NewPointer(true), + ExportAmazonS3SSE: model.NewPointer(true), + ExportAmazonS3Trace: model.NewPointer(true), + ExportAmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(1000)), + ExportAmazonS3PresignExpiresSeconds: model.NewPointer(int64(60000)), + ExportAmazonS3UploadPartSizeBytes: model.NewPointer(int64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes)), }, enableComplianceFeature, skipVerify) require.Equal(t, expected, actual) @@ -787,20 +787,20 @@ func TestNewExportFileBackendSettingsFromConfig(t *testing.T) { } actual := NewExportFileBackendSettingsFromConfig(&model.FileSettings{ - ExportDriverName: model.NewString(driverS3), - ExportAmazonS3AccessKeyId: model.NewString("minioaccesskey"), - ExportAmazonS3SecretAccessKey: model.NewString("miniosecretkey"), - ExportAmazonS3Bucket: model.NewString("mattermost-test"), - ExportAmazonS3Region: model.NewString("region"), - ExportAmazonS3Endpoint: model.NewString("s3.example.com"), - ExportAmazonS3PathPrefix: model.NewString("prefix"), - ExportAmazonS3SSL: model.NewBool(true), - ExportAmazonS3SignV2: model.NewBool(true), - ExportAmazonS3SSE: model.NewBool(true), - ExportAmazonS3Trace: model.NewBool(true), - ExportAmazonS3RequestTimeoutMilliseconds: model.NewInt64(1000), - ExportAmazonS3PresignExpiresSeconds: model.NewInt64(60000), - ExportAmazonS3UploadPartSizeBytes: model.NewInt64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes), + ExportDriverName: model.NewPointer(driverS3), + ExportAmazonS3AccessKeyId: model.NewPointer("minioaccesskey"), + ExportAmazonS3SecretAccessKey: model.NewPointer("miniosecretkey"), + ExportAmazonS3Bucket: model.NewPointer("mattermost-test"), + ExportAmazonS3Region: model.NewPointer("region"), + ExportAmazonS3Endpoint: model.NewPointer("s3.example.com"), + ExportAmazonS3PathPrefix: model.NewPointer("prefix"), + ExportAmazonS3SSL: model.NewPointer(true), + ExportAmazonS3SignV2: model.NewPointer(true), + ExportAmazonS3SSE: model.NewPointer(true), + ExportAmazonS3Trace: model.NewPointer(true), + ExportAmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(1000)), + ExportAmazonS3PresignExpiresSeconds: model.NewPointer(int64(60000)), + ExportAmazonS3UploadPartSizeBytes: model.NewPointer(int64(model.FileSettingsDefaultS3ExportUploadPartSizeBytes)), }, enableComplianceFeature, skipVerify) require.Equal(t, expected, actual) diff --git a/server/public/model/bot_test.go b/server/public/model/bot_test.go index a5056b91c9..8245db218f 100644 --- a/server/public/model/bot_test.go +++ b/server/public/model/bot_test.go @@ -496,7 +496,7 @@ func TestBotWouldPatch(t *testing.T) { t.Run("patch", func(t *testing.T) { patch := &BotPatch{ - DisplayName: NewString("BotName"), + DisplayName: NewPointer("BotName"), } ok := b.WouldPatch(patch) require.True(t, ok) @@ -504,7 +504,7 @@ func TestBotWouldPatch(t *testing.T) { t.Run("no patch", func(t *testing.T) { patch := &BotPatch{ - DisplayName: NewString("BotName"), + DisplayName: NewPointer("BotName"), } b.Patch(patch) ok := b.WouldPatch(patch) diff --git a/server/public/model/builtin.go b/server/public/model/builtin.go index f84a8b657e..a1ceed7f0b 100644 --- a/server/public/model/builtin.go +++ b/server/public/model/builtin.go @@ -3,11 +3,14 @@ package model +// These functions are deprecated. Please use only NewPointer. func NewBool(b bool) *bool { return &b } func NewInt(n int) *int { return &n } func NewInt64(n int64) *int64 { return &n } func NewString(s string) *string { return &s } -func NewPointer[T any](t T) *T { return &t } + +// NewPointer returns a pointer to the object passed. +func NewPointer[T any](t T) *T { return &t } // SafeDereference returns the zero value of T if t is nil. // Otherwise it return the derference of t. diff --git a/server/public/model/builtin_test.go b/server/public/model/builtin_test.go index 8212173e43..29c0e49922 100644 --- a/server/public/model/builtin_test.go +++ b/server/public/model/builtin_test.go @@ -24,7 +24,7 @@ func TestSafeDereference(t *testing.T) { s := SafeDereference[string](nil) assert.Equal(t, "", s) - s = SafeDereference(NewString("foo")) + s = SafeDereference(NewPointer("foo")) assert.Equal(t, "foo", s) }) @@ -32,7 +32,7 @@ func TestSafeDereference(t *testing.T) { s := SafeDereference[*string](nil) assert.Nil(t, s) - f := NewString("foo") + f := NewPointer("foo") s = SafeDereference(&f) assert.Equal(t, f, s) }) diff --git a/server/public/model/channel.go b/server/public/model/channel.go index 511cf7197a..4f9b4cf4d0 100644 --- a/server/public/model/channel.go +++ b/server/public/model/channel.go @@ -207,7 +207,7 @@ func WithID(ID string) ChannelOption { func (o *Channel) DeepCopy() *Channel { cCopy := *o if cCopy.SchemeId != nil { - cCopy.SchemeId = NewString(*o.SchemeId) + cCopy.SchemeId = NewPointer(*o.SchemeId) } return &cCopy } diff --git a/server/public/model/channel_bookmark_test.go b/server/public/model/channel_bookmark_test.go index 4186c69e70..328ec27f68 100644 --- a/server/public/model/channel_bookmark_test.go +++ b/server/public/model/channel_bookmark_test.go @@ -523,9 +523,9 @@ func TestChannelBookmarkPreUpdate(t *testing.T) { func TestChannelBookmarkPatch(t *testing.T) { p := &ChannelBookmarkPatch{ - DisplayName: NewString(NewId()), - SortOrder: NewInt64(1), - LinkUrl: NewString(NewId()), + DisplayName: NewPointer(NewId()), + SortOrder: NewPointer(int64(1)), + LinkUrl: NewPointer(NewId()), } b := ChannelBookmark{ diff --git a/server/public/model/client4.go b/server/public/model/client4.go index 47cfc9eeb3..896b5747d7 100644 --- a/server/public/model/client4.go +++ b/server/public/model/client4.go @@ -2317,10 +2317,10 @@ func (c *Client4) SearchTeams(ctx context.Context, search *TeamSearch) ([]*Team, // SearchTeamsPaged returns a page of teams and the total count matching the provided search term. func (c *Client4) SearchTeamsPaged(ctx context.Context, search *TeamSearch) ([]*Team, int64, *Response, error) { if search.Page == nil { - search.Page = NewInt(0) + search.Page = NewPointer(0) } if search.PerPage == nil { - search.PerPage = NewInt(100) + search.PerPage = NewPointer(100) } buf, err := json.Marshal(search) if err != nil { diff --git a/server/public/model/config.go b/server/public/model/config.go index 11685deda3..d1f1cc3da4 100644 --- a/server/public/model/config.go +++ b/server/public/model/config.go @@ -420,138 +420,138 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { if s.EnableEmailInvitations == nil { // If the site URL is also not present then assume this is a clean install if s.SiteURL == nil { - s.EnableEmailInvitations = NewBool(false) + s.EnableEmailInvitations = NewPointer(false) } else { - s.EnableEmailInvitations = NewBool(true) + s.EnableEmailInvitations = NewPointer(true) } } if s.SiteURL == nil { if s.EnableDeveloper != nil && *s.EnableDeveloper { - s.SiteURL = NewString(ServiceSettingsDefaultSiteURL) + s.SiteURL = NewPointer(ServiceSettingsDefaultSiteURL) } else { - s.SiteURL = NewString("") + s.SiteURL = NewPointer("") } } if s.WebsocketURL == nil { - s.WebsocketURL = NewString("") + s.WebsocketURL = NewPointer("") } if s.LicenseFileLocation == nil { - s.LicenseFileLocation = NewString("") + s.LicenseFileLocation = NewPointer("") } if s.ListenAddress == nil { - s.ListenAddress = NewString(ServiceSettingsDefaultListenAndAddress) + s.ListenAddress = NewPointer(ServiceSettingsDefaultListenAndAddress) } if s.EnableLinkPreviews == nil { - s.EnableLinkPreviews = NewBool(true) + s.EnableLinkPreviews = NewPointer(true) } if s.EnablePermalinkPreviews == nil { - s.EnablePermalinkPreviews = NewBool(true) + s.EnablePermalinkPreviews = NewPointer(true) } if s.RestrictLinkPreviews == nil { - s.RestrictLinkPreviews = NewString("") + s.RestrictLinkPreviews = NewPointer("") } if s.EnableTesting == nil { - s.EnableTesting = NewBool(false) + s.EnableTesting = NewPointer(false) } if s.EnableDeveloper == nil { - s.EnableDeveloper = NewBool(false) + s.EnableDeveloper = NewPointer(false) } if s.DeveloperFlags == nil { - s.DeveloperFlags = NewString("") + s.DeveloperFlags = NewPointer("") } if s.EnableClientPerformanceDebugging == nil { - s.EnableClientPerformanceDebugging = NewBool(false) + s.EnableClientPerformanceDebugging = NewPointer(false) } if s.EnableOpenTracing == nil { - s.EnableOpenTracing = NewBool(false) + s.EnableOpenTracing = NewPointer(false) } if s.EnableSecurityFixAlert == nil { - s.EnableSecurityFixAlert = NewBool(true) + s.EnableSecurityFixAlert = NewPointer(true) } if s.EnableInsecureOutgoingConnections == nil { - s.EnableInsecureOutgoingConnections = NewBool(false) + s.EnableInsecureOutgoingConnections = NewPointer(false) } if s.AllowedUntrustedInternalConnections == nil { - s.AllowedUntrustedInternalConnections = NewString("") + s.AllowedUntrustedInternalConnections = NewPointer("") } if s.EnableMultifactorAuthentication == nil { - s.EnableMultifactorAuthentication = NewBool(false) + s.EnableMultifactorAuthentication = NewPointer(false) } if s.EnforceMultifactorAuthentication == nil { - s.EnforceMultifactorAuthentication = NewBool(false) + s.EnforceMultifactorAuthentication = NewPointer(false) } if s.EnableUserAccessTokens == nil { - s.EnableUserAccessTokens = NewBool(false) + s.EnableUserAccessTokens = NewPointer(false) } if s.GoroutineHealthThreshold == nil { - s.GoroutineHealthThreshold = NewInt(-1) + s.GoroutineHealthThreshold = NewPointer(-1) } if s.GoogleDeveloperKey == nil { - s.GoogleDeveloperKey = NewString("") + s.GoogleDeveloperKey = NewPointer("") } if s.EnableOAuthServiceProvider == nil { - s.EnableOAuthServiceProvider = NewBool(true) + s.EnableOAuthServiceProvider = NewPointer(true) } if s.EnableIncomingWebhooks == nil { - s.EnableIncomingWebhooks = NewBool(true) + s.EnableIncomingWebhooks = NewPointer(true) } if s.EnableOutgoingWebhooks == nil { - s.EnableOutgoingWebhooks = NewBool(true) + s.EnableOutgoingWebhooks = NewPointer(true) } if s.EnableOutgoingOAuthConnections == nil { - s.EnableOutgoingOAuthConnections = NewBool(false) + s.EnableOutgoingOAuthConnections = NewPointer(false) } if s.OutgoingIntegrationRequestsTimeout == nil { - s.OutgoingIntegrationRequestsTimeout = NewInt64(OutgoingIntegrationRequestsDefaultTimeout) + s.OutgoingIntegrationRequestsTimeout = NewPointer(int64(OutgoingIntegrationRequestsDefaultTimeout)) } if s.ConnectionSecurity == nil { - s.ConnectionSecurity = NewString("") + s.ConnectionSecurity = NewPointer("") } if s.TLSKeyFile == nil { - s.TLSKeyFile = NewString(ServiceSettingsDefaultTLSKeyFile) + s.TLSKeyFile = NewPointer(ServiceSettingsDefaultTLSKeyFile) } if s.TLSCertFile == nil { - s.TLSCertFile = NewString(ServiceSettingsDefaultTLSCertFile) + s.TLSCertFile = NewPointer(ServiceSettingsDefaultTLSCertFile) } if s.TLSMinVer == nil { - s.TLSMinVer = NewString("1.2") + s.TLSMinVer = NewPointer("1.2") } if s.TLSStrictTransport == nil { - s.TLSStrictTransport = NewBool(false) + s.TLSStrictTransport = NewPointer(false) } if s.TLSStrictTransportMaxAge == nil { - s.TLSStrictTransportMaxAge = NewInt64(63072000) + s.TLSStrictTransportMaxAge = NewPointer(int64(63072000)) } if s.TLSOverwriteCiphers == nil { @@ -559,31 +559,31 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { } if s.UseLetsEncrypt == nil { - s.UseLetsEncrypt = NewBool(false) + s.UseLetsEncrypt = NewPointer(false) } if s.LetsEncryptCertificateCacheFile == nil { - s.LetsEncryptCertificateCacheFile = NewString("./config/letsencrypt.cache") + s.LetsEncryptCertificateCacheFile = NewPointer("./config/letsencrypt.cache") } if s.ReadTimeout == nil { - s.ReadTimeout = NewInt(ServiceSettingsDefaultReadTimeout) + s.ReadTimeout = NewPointer(ServiceSettingsDefaultReadTimeout) } if s.WriteTimeout == nil { - s.WriteTimeout = NewInt(ServiceSettingsDefaultWriteTimeout) + s.WriteTimeout = NewPointer(ServiceSettingsDefaultWriteTimeout) } if s.IdleTimeout == nil { - s.IdleTimeout = NewInt(ServiceSettingsDefaultIdleTimeout) + s.IdleTimeout = NewPointer(ServiceSettingsDefaultIdleTimeout) } if s.MaximumLoginAttempts == nil { - s.MaximumLoginAttempts = NewInt(ServiceSettingsDefaultMaxLoginAttempts) + s.MaximumLoginAttempts = NewPointer(ServiceSettingsDefaultMaxLoginAttempts) } if s.Forward80To443 == nil { - s.Forward80To443 = NewBool(false) + s.Forward80To443 = NewPointer(false) } if s.TrustedProxyIPHeader == nil { @@ -591,60 +591,60 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { } if s.TimeBetweenUserTypingUpdatesMilliseconds == nil { - s.TimeBetweenUserTypingUpdatesMilliseconds = NewInt64(5000) + s.TimeBetweenUserTypingUpdatesMilliseconds = NewPointer(int64(5000)) } if s.EnablePostSearch == nil { - s.EnablePostSearch = NewBool(true) + s.EnablePostSearch = NewPointer(true) } if s.EnableFileSearch == nil { - s.EnableFileSearch = NewBool(true) + s.EnableFileSearch = NewPointer(true) } if s.MinimumHashtagLength == nil { - s.MinimumHashtagLength = NewInt(3) + s.MinimumHashtagLength = NewPointer(3) } if s.EnableUserTypingMessages == nil { - s.EnableUserTypingMessages = NewBool(true) + s.EnableUserTypingMessages = NewPointer(true) } if s.EnableChannelViewedMessages == nil { - s.EnableChannelViewedMessages = NewBool(true) + s.EnableChannelViewedMessages = NewPointer(true) } if s.EnableUserStatuses == nil { - s.EnableUserStatuses = NewBool(true) + s.EnableUserStatuses = NewPointer(true) } if s.ClusterLogTimeoutMilliseconds == nil { - s.ClusterLogTimeoutMilliseconds = NewInt(2000) + s.ClusterLogTimeoutMilliseconds = NewPointer(2000) } if s.EnableTutorial == nil { - s.EnableTutorial = NewBool(true) + s.EnableTutorial = NewPointer(true) } if s.EnableOnboardingFlow == nil { - s.EnableOnboardingFlow = NewBool(true) + s.EnableOnboardingFlow = NewPointer(true) } // Must be manually enabled for existing installations. if s.ExtendSessionLengthWithActivity == nil { - s.ExtendSessionLengthWithActivity = NewBool(!isUpdate) + s.ExtendSessionLengthWithActivity = NewPointer(!isUpdate) } // Must be manually enabled for existing installations. if s.TerminateSessionsOnPasswordChange == nil { - s.TerminateSessionsOnPasswordChange = NewBool(!isUpdate) + s.TerminateSessionsOnPasswordChange = NewPointer(!isUpdate) } if s.SessionLengthWebInDays == nil { if isUpdate { - s.SessionLengthWebInDays = NewInt(180) + s.SessionLengthWebInDays = NewPointer(180) } else { - s.SessionLengthWebInDays = NewInt(30) + s.SessionLengthWebInDays = NewPointer(30) } } @@ -659,14 +659,14 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { } else { webTTLDays = *s.SessionLengthWebInDays } - s.SessionLengthWebInHours = NewInt(webTTLDays * 24) + s.SessionLengthWebInHours = NewPointer(webTTLDays * 24) } if s.SessionLengthMobileInDays == nil { if isUpdate { - s.SessionLengthMobileInDays = NewInt(180) + s.SessionLengthMobileInDays = NewPointer(180) } else { - s.SessionLengthMobileInDays = NewInt(30) + s.SessionLengthMobileInDays = NewPointer(30) } } @@ -681,11 +681,11 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { } else { mobileTTLDays = *s.SessionLengthMobileInDays } - s.SessionLengthMobileInHours = NewInt(mobileTTLDays * 24) + s.SessionLengthMobileInHours = NewPointer(mobileTTLDays * 24) } if s.SessionLengthSSOInDays == nil { - s.SessionLengthSSOInDays = NewInt(30) + s.SessionLengthSSOInDays = NewPointer(30) } if s.SessionLengthSSOInHours == nil { @@ -695,237 +695,237 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { } else { ssoTTLDays = *s.SessionLengthSSOInDays } - s.SessionLengthSSOInHours = NewInt(ssoTTLDays * 24) + s.SessionLengthSSOInHours = NewPointer(ssoTTLDays * 24) } if s.SessionCacheInMinutes == nil { - s.SessionCacheInMinutes = NewInt(10) + s.SessionCacheInMinutes = NewPointer(10) } if s.SessionIdleTimeoutInMinutes == nil { - s.SessionIdleTimeoutInMinutes = NewInt(43200) + s.SessionIdleTimeoutInMinutes = NewPointer(43200) } if s.EnableCommands == nil { - s.EnableCommands = NewBool(true) + s.EnableCommands = NewPointer(true) } if s.EnablePostUsernameOverride == nil { - s.EnablePostUsernameOverride = NewBool(false) + s.EnablePostUsernameOverride = NewPointer(false) } if s.EnablePostIconOverride == nil { - s.EnablePostIconOverride = NewBool(false) + s.EnablePostIconOverride = NewPointer(false) } if s.WebsocketPort == nil { - s.WebsocketPort = NewInt(80) + s.WebsocketPort = NewPointer(80) } if s.WebsocketSecurePort == nil { - s.WebsocketSecurePort = NewInt(443) + s.WebsocketSecurePort = NewPointer(443) } if s.AllowCorsFrom == nil { - s.AllowCorsFrom = NewString(ServiceSettingsDefaultAllowCorsFrom) + s.AllowCorsFrom = NewPointer(ServiceSettingsDefaultAllowCorsFrom) } if s.CorsExposedHeaders == nil { - s.CorsExposedHeaders = NewString("") + s.CorsExposedHeaders = NewPointer("") } if s.CorsAllowCredentials == nil { - s.CorsAllowCredentials = NewBool(false) + s.CorsAllowCredentials = NewPointer(false) } if s.CorsDebug == nil { - s.CorsDebug = NewBool(false) + s.CorsDebug = NewPointer(false) } if s.AllowCookiesForSubdomains == nil { - s.AllowCookiesForSubdomains = NewBool(false) + s.AllowCookiesForSubdomains = NewPointer(false) } if s.WebserverMode == nil { - s.WebserverMode = NewString("gzip") + s.WebserverMode = NewPointer("gzip") } else if *s.WebserverMode == "regular" { *s.WebserverMode = "gzip" } if s.EnableCustomEmoji == nil { - s.EnableCustomEmoji = NewBool(true) + s.EnableCustomEmoji = NewPointer(true) } if s.EnableEmojiPicker == nil { - s.EnableEmojiPicker = NewBool(true) + s.EnableEmojiPicker = NewPointer(true) } if s.EnableGifPicker == nil { - s.EnableGifPicker = NewBool(true) + s.EnableGifPicker = NewPointer(true) } if s.GiphySdkKey == nil || *s.GiphySdkKey == "" { - s.GiphySdkKey = NewString("") + s.GiphySdkKey = NewPointer("") } if s.ExperimentalEnableAuthenticationTransfer == nil { - s.ExperimentalEnableAuthenticationTransfer = NewBool(true) + s.ExperimentalEnableAuthenticationTransfer = NewPointer(true) } if s.PostEditTimeLimit == nil { - s.PostEditTimeLimit = NewInt(-1) + s.PostEditTimeLimit = NewPointer(-1) } if s.ExperimentalEnableDefaultChannelLeaveJoinMessages == nil { - s.ExperimentalEnableDefaultChannelLeaveJoinMessages = NewBool(true) + s.ExperimentalEnableDefaultChannelLeaveJoinMessages = NewPointer(true) } if s.ExperimentalGroupUnreadChannels == nil { - s.ExperimentalGroupUnreadChannels = NewString(GroupUnreadChannelsDisabled) + s.ExperimentalGroupUnreadChannels = NewPointer(GroupUnreadChannelsDisabled) } else if *s.ExperimentalGroupUnreadChannels == "0" { - s.ExperimentalGroupUnreadChannels = NewString(GroupUnreadChannelsDisabled) + s.ExperimentalGroupUnreadChannels = NewPointer(GroupUnreadChannelsDisabled) } else if *s.ExperimentalGroupUnreadChannels == "1" { - s.ExperimentalGroupUnreadChannels = NewString(GroupUnreadChannelsDefaultOn) + s.ExperimentalGroupUnreadChannels = NewPointer(GroupUnreadChannelsDefaultOn) } if s.EnableAPITeamDeletion == nil { - s.EnableAPITeamDeletion = NewBool(false) + s.EnableAPITeamDeletion = NewPointer(false) } if s.EnableAPITriggerAdminNotifications == nil { - s.EnableAPITriggerAdminNotifications = NewBool(false) + s.EnableAPITriggerAdminNotifications = NewPointer(false) } if s.EnableAPIUserDeletion == nil { - s.EnableAPIUserDeletion = NewBool(false) + s.EnableAPIUserDeletion = NewPointer(false) } if s.EnableAPIChannelDeletion == nil { - s.EnableAPIChannelDeletion = NewBool(false) + s.EnableAPIChannelDeletion = NewPointer(false) } if s.ExperimentalEnableHardenedMode == nil { - s.ExperimentalEnableHardenedMode = NewBool(false) + s.ExperimentalEnableHardenedMode = NewPointer(false) } if s.ExperimentalStrictCSRFEnforcement == nil { - s.ExperimentalStrictCSRFEnforcement = NewBool(false) + s.ExperimentalStrictCSRFEnforcement = NewPointer(false) } if s.DisableBotsWhenOwnerIsDeactivated == nil { - s.DisableBotsWhenOwnerIsDeactivated = NewBool(true) + s.DisableBotsWhenOwnerIsDeactivated = NewPointer(true) } if s.EnableBotAccountCreation == nil { - s.EnableBotAccountCreation = NewBool(false) + s.EnableBotAccountCreation = NewPointer(false) } if s.EnableSVGs == nil { if isUpdate { - s.EnableSVGs = NewBool(true) + s.EnableSVGs = NewPointer(true) } else { - s.EnableSVGs = NewBool(false) + s.EnableSVGs = NewPointer(false) } } if s.EnableLatex == nil { if isUpdate { - s.EnableLatex = NewBool(true) + s.EnableLatex = NewPointer(true) } else { - s.EnableLatex = NewBool(false) + s.EnableLatex = NewPointer(false) } } if s.EnableInlineLatex == nil { - s.EnableInlineLatex = NewBool(true) + s.EnableInlineLatex = NewPointer(true) } if s.EnableLocalMode == nil { - s.EnableLocalMode = NewBool(false) + s.EnableLocalMode = NewPointer(false) } if s.LocalModeSocketLocation == nil { - s.LocalModeSocketLocation = NewString(LocalModeSocketPath) + s.LocalModeSocketLocation = NewPointer(LocalModeSocketPath) } if s.EnableAWSMetering == nil { - s.EnableAWSMetering = NewBool(false) + s.EnableAWSMetering = NewPointer(false) } if s.SplitKey == nil { - s.SplitKey = NewString("") + s.SplitKey = NewPointer("") } if s.FeatureFlagSyncIntervalSeconds == nil { - s.FeatureFlagSyncIntervalSeconds = NewInt(30) + s.FeatureFlagSyncIntervalSeconds = NewPointer(30) } if s.DebugSplit == nil { - s.DebugSplit = NewBool(false) + s.DebugSplit = NewPointer(false) } if s.ThreadAutoFollow == nil { - s.ThreadAutoFollow = NewBool(true) + s.ThreadAutoFollow = NewPointer(true) } if s.CollapsedThreads == nil { - s.CollapsedThreads = NewString(CollapsedThreadsAlwaysOn) + s.CollapsedThreads = NewPointer(CollapsedThreadsAlwaysOn) } if s.ManagedResourcePaths == nil { - s.ManagedResourcePaths = NewString("") + s.ManagedResourcePaths = NewPointer("") } if s.EnableCustomGroups == nil { - s.EnableCustomGroups = NewBool(true) + s.EnableCustomGroups = NewPointer(true) } if s.PostPriority == nil { - s.PostPriority = NewBool(true) + s.PostPriority = NewPointer(true) } if s.AllowPersistentNotifications == nil { - s.AllowPersistentNotifications = NewBool(true) + s.AllowPersistentNotifications = NewPointer(true) } if s.AllowPersistentNotificationsForGuests == nil { - s.AllowPersistentNotificationsForGuests = NewBool(false) + s.AllowPersistentNotificationsForGuests = NewPointer(false) } if s.PersistentNotificationIntervalMinutes == nil { - s.PersistentNotificationIntervalMinutes = NewInt(5) + s.PersistentNotificationIntervalMinutes = NewPointer(5) } if s.PersistentNotificationMaxCount == nil { - s.PersistentNotificationMaxCount = NewInt(6) + s.PersistentNotificationMaxCount = NewPointer(6) } if s.PersistentNotificationMaxRecipients == nil { - s.PersistentNotificationMaxRecipients = NewInt(5) + s.PersistentNotificationMaxRecipients = NewPointer(5) } if s.AllowSyncedDrafts == nil { - s.AllowSyncedDrafts = NewBool(true) + s.AllowSyncedDrafts = NewPointer(true) } if s.UniqueEmojiReactionLimitPerPost == nil { - s.UniqueEmojiReactionLimitPerPost = NewInt(ServiceSettingsDefaultUniqueReactionsPerPost) + s.UniqueEmojiReactionLimitPerPost = NewPointer(ServiceSettingsDefaultUniqueReactionsPerPost) } if *s.UniqueEmojiReactionLimitPerPost > ServiceSettingsMaxUniqueReactionsPerPost { - s.UniqueEmojiReactionLimitPerPost = NewInt(ServiceSettingsMaxUniqueReactionsPerPost) + s.UniqueEmojiReactionLimitPerPost = NewPointer(ServiceSettingsMaxUniqueReactionsPerPost) } if s.RefreshPostStatsRunTime == nil { - s.RefreshPostStatsRunTime = NewString("00:00") + s.RefreshPostStatsRunTime = NewPointer("00:00") } if s.MaximumPayloadSizeBytes == nil { - s.MaximumPayloadSizeBytes = NewInt64(300000) + s.MaximumPayloadSizeBytes = NewPointer(int64(300000)) } if s.MaximumURLLength == nil { - s.MaximumURLLength = NewInt(ServiceSettingsDefaultMaxURLLength) + s.MaximumURLLength = NewPointer(ServiceSettingsDefaultMaxURLLength) } } @@ -945,47 +945,47 @@ type ClusterSettings struct { func (s *ClusterSettings) SetDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.ClusterName == nil { - s.ClusterName = NewString("") + s.ClusterName = NewPointer("") } if s.OverrideHostname == nil { - s.OverrideHostname = NewString("") + s.OverrideHostname = NewPointer("") } if s.NetworkInterface == nil { - s.NetworkInterface = NewString("") + s.NetworkInterface = NewPointer("") } if s.BindAddress == nil { - s.BindAddress = NewString("") + s.BindAddress = NewPointer("") } if s.AdvertiseAddress == nil { - s.AdvertiseAddress = NewString("") + s.AdvertiseAddress = NewPointer("") } if s.UseIPAddress == nil { - s.UseIPAddress = NewBool(true) + s.UseIPAddress = NewPointer(true) } if s.EnableExperimentalGossipEncryption == nil { - s.EnableExperimentalGossipEncryption = NewBool(false) + s.EnableExperimentalGossipEncryption = NewPointer(false) } if s.EnableGossipCompression == nil { - s.EnableGossipCompression = NewBool(true) + s.EnableGossipCompression = NewPointer(true) } if s.ReadOnlyConfig == nil { - s.ReadOnlyConfig = NewBool(true) + s.ReadOnlyConfig = NewPointer(true) } if s.GossipPort == nil { - s.GossipPort = NewInt(8074) + s.GossipPort = NewPointer(8074) } } @@ -999,23 +999,23 @@ type MetricsSettings struct { func (s *MetricsSettings) SetDefaults() { if s.ListenAddress == nil { - s.ListenAddress = NewString(":8067") + s.ListenAddress = NewPointer(":8067") } if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.BlockProfileRate == nil { - s.BlockProfileRate = NewInt(0) + s.BlockProfileRate = NewPointer(0) } if s.EnableClientMetrics == nil { - s.EnableClientMetrics = NewBool(true) + s.EnableClientMetrics = NewPointer(true) } if s.EnableNotificationMetrics == nil { - s.EnableNotificationMetrics = NewBool(true) + s.EnableNotificationMetrics = NewPointer(true) } } @@ -1035,47 +1035,47 @@ type ExperimentalSettings struct { func (s *ExperimentalSettings) SetDefaults() { if s.ClientSideCertEnable == nil { - s.ClientSideCertEnable = NewBool(false) + s.ClientSideCertEnable = NewPointer(false) } if s.ClientSideCertCheck == nil { - s.ClientSideCertCheck = NewString(ClientSideCertCheckSecondaryAuth) + s.ClientSideCertCheck = NewPointer(ClientSideCertCheckSecondaryAuth) } if s.LinkMetadataTimeoutMilliseconds == nil { - s.LinkMetadataTimeoutMilliseconds = NewInt64(ExperimentalSettingsDefaultLinkMetadataTimeoutMilliseconds) + s.LinkMetadataTimeoutMilliseconds = NewPointer(int64(ExperimentalSettingsDefaultLinkMetadataTimeoutMilliseconds)) } if s.RestrictSystemAdmin == nil { - s.RestrictSystemAdmin = NewBool(false) + s.RestrictSystemAdmin = NewPointer(false) } if s.EnableSharedChannels == nil { - s.EnableSharedChannels = NewBool(false) + s.EnableSharedChannels = NewPointer(false) } if s.EnableRemoteClusterService == nil { - s.EnableRemoteClusterService = NewBool(false) + s.EnableRemoteClusterService = NewPointer(false) } if s.DisableAppBar == nil { - s.DisableAppBar = NewBool(false) + s.DisableAppBar = NewPointer(false) } if s.DisableRefetchingOnBrowserFocus == nil { - s.DisableRefetchingOnBrowserFocus = NewBool(false) + s.DisableRefetchingOnBrowserFocus = NewPointer(false) } if s.DelayChannelAutocomplete == nil { - s.DelayChannelAutocomplete = NewBool(false) + s.DelayChannelAutocomplete = NewPointer(false) } if s.DisableWakeUpReconnectHandler == nil { - s.DisableWakeUpReconnectHandler = NewBool(false) + s.DisableWakeUpReconnectHandler = NewPointer(false) } if s.UsersStatusAndProfileFetchingPollIntervalMilliseconds == nil { - s.UsersStatusAndProfileFetchingPollIntervalMilliseconds = NewInt64(ExperimentalSettingsDefaultUsersStatusAndProfileFetchingPollIntervalMilliseconds) + s.UsersStatusAndProfileFetchingPollIntervalMilliseconds = NewPointer(int64(ExperimentalSettingsDefaultUsersStatusAndProfileFetchingPollIntervalMilliseconds)) } } @@ -1085,7 +1085,7 @@ type AnalyticsSettings struct { func (s *AnalyticsSettings) SetDefaults() { if s.MaxUsersForStatistics == nil { - s.MaxUsersForStatistics = NewInt(AnalyticsSettingsDefaultMaxUsersForStatistics) + s.MaxUsersForStatistics = NewPointer(AnalyticsSettingsDefaultMaxUsersForStatistics) } } @@ -1104,43 +1104,43 @@ type SSOSettings struct { func (s *SSOSettings) setDefaults(scope, authEndpoint, tokenEndpoint, userAPIEndpoint, buttonColor string) { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.Secret == nil { - s.Secret = NewString("") + s.Secret = NewPointer("") } if s.Id == nil { - s.Id = NewString("") + s.Id = NewPointer("") } if s.Scope == nil { - s.Scope = NewString(scope) + s.Scope = NewPointer(scope) } if s.DiscoveryEndpoint == nil { - s.DiscoveryEndpoint = NewString("") + s.DiscoveryEndpoint = NewPointer("") } if s.AuthEndpoint == nil { - s.AuthEndpoint = NewString(authEndpoint) + s.AuthEndpoint = NewPointer(authEndpoint) } if s.TokenEndpoint == nil { - s.TokenEndpoint = NewString(tokenEndpoint) + s.TokenEndpoint = NewPointer(tokenEndpoint) } if s.UserAPIEndpoint == nil { - s.UserAPIEndpoint = NewString(userAPIEndpoint) + s.UserAPIEndpoint = NewPointer(userAPIEndpoint) } if s.ButtonText == nil { - s.ButtonText = NewString("") + s.ButtonText = NewPointer("") } if s.ButtonColor == nil { - s.ButtonColor = NewString(buttonColor) + s.ButtonColor = NewPointer(buttonColor) } } @@ -1158,39 +1158,39 @@ type Office365Settings struct { func (s *Office365Settings) setDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.Id == nil { - s.Id = NewString("") + s.Id = NewPointer("") } if s.Secret == nil { - s.Secret = NewString("") + s.Secret = NewPointer("") } if s.Scope == nil { - s.Scope = NewString(Office365SettingsDefaultScope) + s.Scope = NewPointer(Office365SettingsDefaultScope) } if s.DiscoveryEndpoint == nil { - s.DiscoveryEndpoint = NewString("") + s.DiscoveryEndpoint = NewPointer("") } if s.AuthEndpoint == nil { - s.AuthEndpoint = NewString(Office365SettingsDefaultAuthEndpoint) + s.AuthEndpoint = NewPointer(Office365SettingsDefaultAuthEndpoint) } if s.TokenEndpoint == nil { - s.TokenEndpoint = NewString(Office365SettingsDefaultTokenEndpoint) + s.TokenEndpoint = NewPointer(Office365SettingsDefaultTokenEndpoint) } if s.UserAPIEndpoint == nil { - s.UserAPIEndpoint = NewString(Office365SettingsDefaultUserAPIEndpoint) + s.UserAPIEndpoint = NewPointer(Office365SettingsDefaultUserAPIEndpoint) } if s.DirectoryId == nil { - s.DirectoryId = NewString("") + s.DirectoryId = NewPointer("") } } @@ -1233,11 +1233,11 @@ type SqlSettings struct { func (s *SqlSettings) SetDefaults(isUpdate bool) { if s.DriverName == nil { - s.DriverName = NewString(DatabaseDriverPostgres) + s.DriverName = NewPointer(DatabaseDriverPostgres) } if s.DataSource == nil { - s.DataSource = NewString(SqlSettingsDefaultDataSource) + s.DataSource = NewPointer(SqlSettingsDefaultDataSource) } if s.DataSourceReplicas == nil { @@ -1251,43 +1251,43 @@ func (s *SqlSettings) SetDefaults(isUpdate bool) { if isUpdate { // When updating an existing configuration, ensure an encryption key has been specified. if s.AtRestEncryptKey == nil || *s.AtRestEncryptKey == "" { - s.AtRestEncryptKey = NewString(NewRandomString(32)) + s.AtRestEncryptKey = NewPointer(NewRandomString(32)) } } else { // When generating a blank configuration, leave this key empty to be generated on server start. - s.AtRestEncryptKey = NewString("") + s.AtRestEncryptKey = NewPointer("") } if s.MaxIdleConns == nil { - s.MaxIdleConns = NewInt(20) + s.MaxIdleConns = NewPointer(20) } if s.MaxOpenConns == nil { - s.MaxOpenConns = NewInt(300) + s.MaxOpenConns = NewPointer(300) } if s.ConnMaxLifetimeMilliseconds == nil { - s.ConnMaxLifetimeMilliseconds = NewInt(3600000) + s.ConnMaxLifetimeMilliseconds = NewPointer(3600000) } if s.ConnMaxIdleTimeMilliseconds == nil { - s.ConnMaxIdleTimeMilliseconds = NewInt(300000) + s.ConnMaxIdleTimeMilliseconds = NewPointer(300000) } if s.Trace == nil { - s.Trace = NewBool(false) + s.Trace = NewPointer(false) } if s.QueryTimeout == nil { - s.QueryTimeout = NewInt(30) + s.QueryTimeout = NewPointer(30) } if s.DisableDatabaseSearch == nil { - s.DisableDatabaseSearch = NewBool(false) + s.DisableDatabaseSearch = NewPointer(false) } if s.MigrationsStatementTimeoutSeconds == nil { - s.MigrationsStatementTimeoutSeconds = NewInt(100000) + s.MigrationsStatementTimeoutSeconds = NewPointer(100000) } if s.ReplicaLagSettings == nil { @@ -1295,7 +1295,7 @@ func (s *SqlSettings) SetDefaults(isUpdate bool) { } if s.ReplicaMonitorIntervalSeconds == nil { - s.ReplicaMonitorIntervalSeconds = NewInt(5) + s.ReplicaMonitorIntervalSeconds = NewPointer(5) } } @@ -1340,51 +1340,51 @@ func (s *LogSettings) isValid() *AppError { func (s *LogSettings) SetDefaults() { if s.EnableConsole == nil { - s.EnableConsole = NewBool(true) + s.EnableConsole = NewPointer(true) } if s.ConsoleLevel == nil { - s.ConsoleLevel = NewString("DEBUG") + s.ConsoleLevel = NewPointer("DEBUG") } if s.EnableColor == nil { - s.EnableColor = NewBool(false) + s.EnableColor = NewPointer(false) } if s.EnableFile == nil { - s.EnableFile = NewBool(true) + s.EnableFile = NewPointer(true) } if s.FileLevel == nil { - s.FileLevel = NewString("INFO") + s.FileLevel = NewPointer("INFO") } if s.FileLocation == nil { - s.FileLocation = NewString("") + s.FileLocation = NewPointer("") } if s.EnableWebhookDebugging == nil { - s.EnableWebhookDebugging = NewBool(true) + s.EnableWebhookDebugging = NewPointer(true) } if s.EnableDiagnostics == nil { - s.EnableDiagnostics = NewBool(true) + s.EnableDiagnostics = NewPointer(true) } if s.VerboseDiagnostics == nil { - s.VerboseDiagnostics = NewBool(false) + s.VerboseDiagnostics = NewPointer(false) } if s.EnableSentry == nil { - s.EnableSentry = NewBool(*s.EnableDiagnostics) + s.EnableSentry = NewPointer(*s.EnableDiagnostics) } if s.ConsoleJson == nil { - s.ConsoleJson = NewBool(true) + s.ConsoleJson = NewPointer(true) } if s.FileJson == nil { - s.FileJson = NewBool(true) + s.FileJson = NewPointer(true) } if utils.IsEmptyJSON(s.AdvancedLoggingJSON) { @@ -1392,11 +1392,11 @@ func (s *LogSettings) SetDefaults() { } if s.AdvancedLoggingConfig == nil { - s.AdvancedLoggingConfig = NewString("") + s.AdvancedLoggingConfig = NewPointer("") } if s.MaxFieldSize == nil { - s.MaxFieldSize = NewInt(2048) + s.MaxFieldSize = NewPointer(2048) } } @@ -1426,31 +1426,31 @@ type ExperimentalAuditSettings struct { func (s *ExperimentalAuditSettings) SetDefaults() { if s.FileEnabled == nil { - s.FileEnabled = NewBool(false) + s.FileEnabled = NewPointer(false) } if s.FileName == nil { - s.FileName = NewString("") + s.FileName = NewPointer("") } if s.FileMaxSizeMB == nil { - s.FileMaxSizeMB = NewInt(100) + s.FileMaxSizeMB = NewPointer(100) } if s.FileMaxAgeDays == nil { - s.FileMaxAgeDays = NewInt(0) // no limit on age + s.FileMaxAgeDays = NewPointer(0) // no limit on age } if s.FileMaxBackups == nil { // no limit on number of backups - s.FileMaxBackups = NewInt(0) + s.FileMaxBackups = NewPointer(0) } if s.FileCompress == nil { - s.FileCompress = NewBool(false) + s.FileCompress = NewPointer(false) } if s.FileMaxQueueSize == nil { - s.FileMaxQueueSize = NewInt(1000) + s.FileMaxQueueSize = NewPointer(1000) } if utils.IsEmptyJSON(s.AdvancedLoggingJSON) { @@ -1458,7 +1458,7 @@ func (s *ExperimentalAuditSettings) SetDefaults() { } if s.AdvancedLoggingConfig == nil { - s.AdvancedLoggingConfig = NewString("") + s.AdvancedLoggingConfig = NewPointer("") } } @@ -1489,35 +1489,35 @@ type NotificationLogSettings struct { func (s *NotificationLogSettings) SetDefaults() { if s.EnableConsole == nil { - s.EnableConsole = NewBool(true) + s.EnableConsole = NewPointer(true) } if s.ConsoleLevel == nil { - s.ConsoleLevel = NewString("DEBUG") + s.ConsoleLevel = NewPointer("DEBUG") } if s.EnableFile == nil { - s.EnableFile = NewBool(true) + s.EnableFile = NewPointer(true) } if s.FileLevel == nil { - s.FileLevel = NewString("INFO") + s.FileLevel = NewPointer("INFO") } if s.FileLocation == nil { - s.FileLocation = NewString("") + s.FileLocation = NewPointer("") } if s.ConsoleJson == nil { - s.ConsoleJson = NewBool(true) + s.ConsoleJson = NewPointer(true) } if s.EnableColor == nil { - s.EnableColor = NewBool(false) + s.EnableColor = NewPointer(false) } if s.FileJson == nil { - s.FileJson = NewBool(true) + s.FileJson = NewPointer(true) } if utils.IsEmptyJSON(s.AdvancedLoggingJSON) { @@ -1525,7 +1525,7 @@ func (s *NotificationLogSettings) SetDefaults() { } if s.AdvancedLoggingConfig == nil { - s.AdvancedLoggingConfig = NewString("") + s.AdvancedLoggingConfig = NewPointer("") } } @@ -1552,27 +1552,27 @@ type PasswordSettings struct { func (s *PasswordSettings) SetDefaults() { if s.MinimumLength == nil { - s.MinimumLength = NewInt(8) + s.MinimumLength = NewPointer(8) } if s.Lowercase == nil { - s.Lowercase = NewBool(false) + s.Lowercase = NewPointer(false) } if s.Number == nil { - s.Number = NewBool(false) + s.Number = NewPointer(false) } if s.Uppercase == nil { - s.Uppercase = NewBool(false) + s.Uppercase = NewPointer(false) } if s.Symbol == nil { - s.Symbol = NewBool(false) + s.Symbol = NewPointer(false) } if s.EnableForgotLink == nil { - s.EnableForgotLink = NewBool(true) + s.EnableForgotLink = NewPointer(true) } } @@ -1623,91 +1623,91 @@ type FileSettings struct { func (s *FileSettings) SetDefaults(isUpdate bool) { if s.EnableFileAttachments == nil { - s.EnableFileAttachments = NewBool(true) + s.EnableFileAttachments = NewPointer(true) } if s.EnableMobileUpload == nil { - s.EnableMobileUpload = NewBool(true) + s.EnableMobileUpload = NewPointer(true) } if s.EnableMobileDownload == nil { - s.EnableMobileDownload = NewBool(true) + s.EnableMobileDownload = NewPointer(true) } if s.MaxFileSize == nil { - s.MaxFileSize = NewInt64(100 * 1024 * 1024) // 100MB (IEC) + s.MaxFileSize = NewPointer(int64(100 * 1024 * 1024)) // 100MB (IEC) } if s.MaxImageResolution == nil { - s.MaxImageResolution = NewInt64(7680 * 4320) // 8K, ~33MPX + s.MaxImageResolution = NewPointer(int64(7680 * 4320)) // 8K, ~33MPX } if s.MaxImageDecoderConcurrency == nil { - s.MaxImageDecoderConcurrency = NewInt64(-1) // Default to NumCPU + s.MaxImageDecoderConcurrency = NewPointer(int64(-1)) // Default to NumCPU } if s.DriverName == nil { - s.DriverName = NewString(ImageDriverLocal) + s.DriverName = NewPointer(ImageDriverLocal) } if s.Directory == nil || *s.Directory == "" { - s.Directory = NewString(FileSettingsDefaultDirectory) + s.Directory = NewPointer(FileSettingsDefaultDirectory) } if s.EnablePublicLink == nil { - s.EnablePublicLink = NewBool(false) + s.EnablePublicLink = NewPointer(false) } if s.ExtractContent == nil { - s.ExtractContent = NewBool(true) + s.ExtractContent = NewPointer(true) } if s.ArchiveRecursion == nil { - s.ArchiveRecursion = NewBool(false) + s.ArchiveRecursion = NewPointer(false) } if isUpdate { // When updating an existing configuration, ensure link salt has been specified. if s.PublicLinkSalt == nil || *s.PublicLinkSalt == "" { - s.PublicLinkSalt = NewString(NewRandomString(32)) + s.PublicLinkSalt = NewPointer(NewRandomString(32)) } } else { // When generating a blank configuration, leave link salt empty to be generated on server start. - s.PublicLinkSalt = NewString("") + s.PublicLinkSalt = NewPointer("") } if s.InitialFont == nil { // Defaults to "nunito-bold.ttf" - s.InitialFont = NewString("nunito-bold.ttf") + s.InitialFont = NewPointer("nunito-bold.ttf") } if s.AmazonS3AccessKeyId == nil { - s.AmazonS3AccessKeyId = NewString("") + s.AmazonS3AccessKeyId = NewPointer("") } if s.AmazonS3SecretAccessKey == nil { - s.AmazonS3SecretAccessKey = NewString("") + s.AmazonS3SecretAccessKey = NewPointer("") } if s.AmazonS3Bucket == nil { - s.AmazonS3Bucket = NewString("") + s.AmazonS3Bucket = NewPointer("") } if s.AmazonS3PathPrefix == nil { - s.AmazonS3PathPrefix = NewString("") + s.AmazonS3PathPrefix = NewPointer("") } if s.AmazonS3Region == nil { - s.AmazonS3Region = NewString("") + s.AmazonS3Region = NewPointer("") } if s.AmazonS3Endpoint == nil || *s.AmazonS3Endpoint == "" { // Defaults to "s3.amazonaws.com" - s.AmazonS3Endpoint = NewString("s3.amazonaws.com") + s.AmazonS3Endpoint = NewPointer("s3.amazonaws.com") } if s.AmazonS3SSL == nil { - s.AmazonS3SSL = NewBool(true) // Secure by default. + s.AmazonS3SSL = NewPointer(true) // Secure by default. } if s.AmazonS3SignV2 == nil { @@ -1716,60 +1716,60 @@ func (s *FileSettings) SetDefaults(isUpdate bool) { } if s.AmazonS3SSE == nil { - s.AmazonS3SSE = NewBool(false) // Not Encrypted by default. + s.AmazonS3SSE = NewPointer(false) // Not Encrypted by default. } if s.AmazonS3Trace == nil { - s.AmazonS3Trace = NewBool(false) + s.AmazonS3Trace = NewPointer(false) } if s.AmazonS3RequestTimeoutMilliseconds == nil { - s.AmazonS3RequestTimeoutMilliseconds = NewInt64(30000) + s.AmazonS3RequestTimeoutMilliseconds = NewPointer(int64(30000)) } if s.AmazonS3UploadPartSizeBytes == nil { - s.AmazonS3UploadPartSizeBytes = NewInt64(FileSettingsDefaultS3UploadPartSizeBytes) + s.AmazonS3UploadPartSizeBytes = NewPointer(int64(FileSettingsDefaultS3UploadPartSizeBytes)) } if s.DedicatedExportStore == nil { - s.DedicatedExportStore = NewBool(false) + s.DedicatedExportStore = NewPointer(false) } if s.ExportDriverName == nil { - s.ExportDriverName = NewString(ImageDriverLocal) + s.ExportDriverName = NewPointer(ImageDriverLocal) } if s.ExportDirectory == nil || *s.ExportDirectory == "" { - s.ExportDirectory = NewString(FileSettingsDefaultDirectory) + s.ExportDirectory = NewPointer(FileSettingsDefaultDirectory) } if s.ExportAmazonS3AccessKeyId == nil { - s.ExportAmazonS3AccessKeyId = NewString("") + s.ExportAmazonS3AccessKeyId = NewPointer("") } if s.ExportAmazonS3SecretAccessKey == nil { - s.ExportAmazonS3SecretAccessKey = NewString("") + s.ExportAmazonS3SecretAccessKey = NewPointer("") } if s.ExportAmazonS3Bucket == nil { - s.ExportAmazonS3Bucket = NewString("") + s.ExportAmazonS3Bucket = NewPointer("") } if s.ExportAmazonS3PathPrefix == nil { - s.ExportAmazonS3PathPrefix = NewString("") + s.ExportAmazonS3PathPrefix = NewPointer("") } if s.ExportAmazonS3Region == nil { - s.ExportAmazonS3Region = NewString("") + s.ExportAmazonS3Region = NewPointer("") } if s.ExportAmazonS3Endpoint == nil || *s.ExportAmazonS3Endpoint == "" { // Defaults to "s3.amazonaws.com" - s.ExportAmazonS3Endpoint = NewString("s3.amazonaws.com") + s.ExportAmazonS3Endpoint = NewPointer("s3.amazonaws.com") } if s.ExportAmazonS3SSL == nil { - s.ExportAmazonS3SSL = NewBool(true) // Secure by default. + s.ExportAmazonS3SSL = NewPointer(true) // Secure by default. } if s.ExportAmazonS3SignV2 == nil { @@ -1778,23 +1778,23 @@ func (s *FileSettings) SetDefaults(isUpdate bool) { } if s.ExportAmazonS3SSE == nil { - s.ExportAmazonS3SSE = NewBool(false) // Not Encrypted by default. + s.ExportAmazonS3SSE = NewPointer(false) // Not Encrypted by default. } if s.ExportAmazonS3Trace == nil { - s.ExportAmazonS3Trace = NewBool(false) + s.ExportAmazonS3Trace = NewPointer(false) } if s.ExportAmazonS3RequestTimeoutMilliseconds == nil { - s.ExportAmazonS3RequestTimeoutMilliseconds = NewInt64(30000) + s.ExportAmazonS3RequestTimeoutMilliseconds = NewPointer(int64(30000)) } if s.ExportAmazonS3PresignExpiresSeconds == nil { - s.ExportAmazonS3PresignExpiresSeconds = NewInt64(21600) // 6h + s.ExportAmazonS3PresignExpiresSeconds = NewPointer(int64(21600)) // 6h } if s.ExportAmazonS3UploadPartSizeBytes == nil { - s.ExportAmazonS3UploadPartSizeBytes = NewInt64(FileSettingsDefaultS3ExportUploadPartSizeBytes) + s.ExportAmazonS3UploadPartSizeBytes = NewPointer(int64(FileSettingsDefaultS3ExportUploadPartSizeBytes)) } } @@ -1833,118 +1833,118 @@ type EmailSettings struct { func (s *EmailSettings) SetDefaults(isUpdate bool) { if s.EnableSignUpWithEmail == nil { - s.EnableSignUpWithEmail = NewBool(true) + s.EnableSignUpWithEmail = NewPointer(true) } if s.EnableSignInWithEmail == nil { - s.EnableSignInWithEmail = NewBool(*s.EnableSignUpWithEmail) + s.EnableSignInWithEmail = NewPointer(*s.EnableSignUpWithEmail) } if s.EnableSignInWithUsername == nil { - s.EnableSignInWithUsername = NewBool(true) + s.EnableSignInWithUsername = NewPointer(true) } if s.SendEmailNotifications == nil { - s.SendEmailNotifications = NewBool(true) + s.SendEmailNotifications = NewPointer(true) } if s.UseChannelInEmailNotifications == nil { - s.UseChannelInEmailNotifications = NewBool(false) + s.UseChannelInEmailNotifications = NewPointer(false) } if s.RequireEmailVerification == nil { - s.RequireEmailVerification = NewBool(false) + s.RequireEmailVerification = NewPointer(false) } if s.FeedbackName == nil { - s.FeedbackName = NewString("") + s.FeedbackName = NewPointer("") } if s.FeedbackEmail == nil { - s.FeedbackEmail = NewString("test@example.com") + s.FeedbackEmail = NewPointer("test@example.com") } if s.ReplyToAddress == nil { - s.ReplyToAddress = NewString("test@example.com") + s.ReplyToAddress = NewPointer("test@example.com") } if s.FeedbackOrganization == nil { - s.FeedbackOrganization = NewString(EmailSettingsDefaultFeedbackOrganization) + s.FeedbackOrganization = NewPointer(EmailSettingsDefaultFeedbackOrganization) } if s.EnableSMTPAuth == nil { if s.ConnectionSecurity == nil || *s.ConnectionSecurity == ConnSecurityNone { - s.EnableSMTPAuth = NewBool(false) + s.EnableSMTPAuth = NewPointer(false) } else { - s.EnableSMTPAuth = NewBool(true) + s.EnableSMTPAuth = NewPointer(true) } } if s.SMTPUsername == nil { - s.SMTPUsername = NewString("") + s.SMTPUsername = NewPointer("") } if s.SMTPPassword == nil { - s.SMTPPassword = NewString("") + s.SMTPPassword = NewPointer("") } if s.SMTPServer == nil || *s.SMTPServer == "" { - s.SMTPServer = NewString(EmailSMTPDefaultServer) + s.SMTPServer = NewPointer(EmailSMTPDefaultServer) } if s.SMTPPort == nil || *s.SMTPPort == "" { - s.SMTPPort = NewString(EmailSMTPDefaultPort) + s.SMTPPort = NewPointer(EmailSMTPDefaultPort) } if s.SMTPServerTimeout == nil || *s.SMTPServerTimeout == 0 { - s.SMTPServerTimeout = NewInt(10) + s.SMTPServerTimeout = NewPointer(10) } if s.ConnectionSecurity == nil || *s.ConnectionSecurity == ConnSecurityPlain { - s.ConnectionSecurity = NewString(ConnSecurityNone) + s.ConnectionSecurity = NewPointer(ConnSecurityNone) } if s.SendPushNotifications == nil { - s.SendPushNotifications = NewBool(!isUpdate) + s.SendPushNotifications = NewPointer(!isUpdate) } if s.PushNotificationServer == nil { if isUpdate { - s.PushNotificationServer = NewString("") + s.PushNotificationServer = NewPointer("") } else { - s.PushNotificationServer = NewString(GenericNotificationServer) + s.PushNotificationServer = NewPointer(GenericNotificationServer) } } if s.PushNotificationContents == nil { - s.PushNotificationContents = NewString(FullNotification) + s.PushNotificationContents = NewPointer(FullNotification) } if s.PushNotificationBuffer == nil { - s.PushNotificationBuffer = NewInt(1000) + s.PushNotificationBuffer = NewPointer(1000) } if s.EnableEmailBatching == nil { - s.EnableEmailBatching = NewBool(false) + s.EnableEmailBatching = NewPointer(false) } if s.EmailBatchingBufferSize == nil { - s.EmailBatchingBufferSize = NewInt(EmailBatchingBufferSize) + s.EmailBatchingBufferSize = NewPointer(EmailBatchingBufferSize) } if s.EmailBatchingInterval == nil { - s.EmailBatchingInterval = NewInt(EmailBatchingInterval) + s.EmailBatchingInterval = NewPointer(EmailBatchingInterval) } if s.EnablePreviewModeBanner == nil { - s.EnablePreviewModeBanner = NewBool(true) + s.EnablePreviewModeBanner = NewPointer(true) } if s.EnableSMTPAuth == nil { if *s.ConnectionSecurity == ConnSecurityNone { - s.EnableSMTPAuth = NewBool(false) + s.EnableSMTPAuth = NewPointer(false) } else { - s.EnableSMTPAuth = NewBool(true) + s.EnableSMTPAuth = NewPointer(true) } } @@ -1953,23 +1953,23 @@ func (s *EmailSettings) SetDefaults(isUpdate bool) { } if s.SkipServerCertificateVerification == nil { - s.SkipServerCertificateVerification = NewBool(false) + s.SkipServerCertificateVerification = NewPointer(false) } if s.EmailNotificationContentsType == nil { - s.EmailNotificationContentsType = NewString(EmailNotificationContentsFull) + s.EmailNotificationContentsType = NewPointer(EmailNotificationContentsFull) } if s.LoginButtonColor == nil { - s.LoginButtonColor = NewString("#0000") + s.LoginButtonColor = NewPointer("#0000") } if s.LoginButtonBorderColor == nil { - s.LoginButtonBorderColor = NewString("#2389D7") + s.LoginButtonBorderColor = NewPointer("#2389D7") } if s.LoginButtonTextColor == nil { - s.LoginButtonTextColor = NewString("#2389D7") + s.LoginButtonTextColor = NewPointer("#2389D7") } } @@ -1985,27 +1985,27 @@ type RateLimitSettings struct { func (s *RateLimitSettings) SetDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.PerSec == nil { - s.PerSec = NewInt(10) + s.PerSec = NewPointer(10) } if s.MaxBurst == nil { - s.MaxBurst = NewInt(100) + s.MaxBurst = NewPointer(100) } if s.MemoryStoreSize == nil { - s.MemoryStoreSize = NewInt(10000) + s.MemoryStoreSize = NewPointer(10000) } if s.VaryByRemoteAddr == nil { - s.VaryByRemoteAddr = NewBool(true) + s.VaryByRemoteAddr = NewPointer(true) } if s.VaryByUser == nil { - s.VaryByUser = NewBool(false) + s.VaryByUser = NewPointer(false) } } @@ -2016,11 +2016,11 @@ type PrivacySettings struct { func (s *PrivacySettings) setDefaults() { if s.ShowEmailAddress == nil { - s.ShowEmailAddress = NewBool(true) + s.ShowEmailAddress = NewPointer(true) } if s.ShowFullName == nil { - s.ShowFullName = NewBool(true) + s.ShowFullName = NewPointer(true) } } @@ -2043,7 +2043,7 @@ func (s *SupportSettings) SetDefaults() { } if s.TermsOfServiceLink == nil { - s.TermsOfServiceLink = NewString(SupportSettingsDefaultTermsOfServiceLink) + s.TermsOfServiceLink = NewPointer(SupportSettingsDefaultTermsOfServiceLink) } if !isSafeLink(s.PrivacyPolicyLink) { @@ -2051,7 +2051,7 @@ func (s *SupportSettings) SetDefaults() { } if s.PrivacyPolicyLink == nil { - s.PrivacyPolicyLink = NewString(SupportSettingsDefaultPrivacyPolicyLink) + s.PrivacyPolicyLink = NewPointer(SupportSettingsDefaultPrivacyPolicyLink) } if !isSafeLink(s.AboutLink) { @@ -2059,7 +2059,7 @@ func (s *SupportSettings) SetDefaults() { } if s.AboutLink == nil { - s.AboutLink = NewString(SupportSettingsDefaultAboutLink) + s.AboutLink = NewPointer(SupportSettingsDefaultAboutLink) } if !isSafeLink(s.HelpLink) { @@ -2067,7 +2067,7 @@ func (s *SupportSettings) SetDefaults() { } if s.HelpLink == nil { - s.HelpLink = NewString(SupportSettingsDefaultHelpLink) + s.HelpLink = NewPointer(SupportSettingsDefaultHelpLink) } if !isSafeLink(s.ReportAProblemLink) { @@ -2075,7 +2075,7 @@ func (s *SupportSettings) SetDefaults() { } if s.ReportAProblemLink == nil { - s.ReportAProblemLink = NewString(SupportSettingsDefaultReportAProblemLink) + s.ReportAProblemLink = NewPointer(SupportSettingsDefaultReportAProblemLink) } if !isSafeLink(s.ForgotPasswordLink) { @@ -2083,23 +2083,23 @@ func (s *SupportSettings) SetDefaults() { } if s.ForgotPasswordLink == nil { - s.ForgotPasswordLink = NewString("") + s.ForgotPasswordLink = NewPointer("") } if s.SupportEmail == nil { - s.SupportEmail = NewString(SupportSettingsDefaultSupportEmail) + s.SupportEmail = NewPointer(SupportSettingsDefaultSupportEmail) } if s.CustomTermsOfServiceEnabled == nil { - s.CustomTermsOfServiceEnabled = NewBool(false) + s.CustomTermsOfServiceEnabled = NewPointer(false) } if s.CustomTermsOfServiceReAcceptancePeriod == nil { - s.CustomTermsOfServiceReAcceptancePeriod = NewInt(SupportSettingsDefaultReAcceptancePeriod) + s.CustomTermsOfServiceReAcceptancePeriod = NewPointer(SupportSettingsDefaultReAcceptancePeriod) } if s.EnableAskCommunityLink == nil { - s.EnableAskCommunityLink = NewBool(true) + s.EnableAskCommunityLink = NewPointer(true) } } @@ -2118,40 +2118,40 @@ type AnnouncementSettings struct { func (s *AnnouncementSettings) SetDefaults() { if s.EnableBanner == nil { - s.EnableBanner = NewBool(false) + s.EnableBanner = NewPointer(false) } if s.BannerText == nil { - s.BannerText = NewString("") + s.BannerText = NewPointer("") } if s.BannerColor == nil { - s.BannerColor = NewString(AnnouncementSettingsDefaultBannerColor) + s.BannerColor = NewPointer(AnnouncementSettingsDefaultBannerColor) } if s.BannerTextColor == nil { - s.BannerTextColor = NewString(AnnouncementSettingsDefaultBannerTextColor) + s.BannerTextColor = NewPointer(AnnouncementSettingsDefaultBannerTextColor) } if s.AllowBannerDismissal == nil { - s.AllowBannerDismissal = NewBool(true) + s.AllowBannerDismissal = NewPointer(true) } if s.AdminNoticesEnabled == nil { - s.AdminNoticesEnabled = NewBool(true) + s.AdminNoticesEnabled = NewPointer(true) } if s.UserNoticesEnabled == nil { - s.UserNoticesEnabled = NewBool(true) + s.UserNoticesEnabled = NewPointer(true) } if s.NoticesURL == nil { - s.NoticesURL = NewString(AnnouncementSettingsDefaultNoticesJsonURL) + s.NoticesURL = NewPointer(AnnouncementSettingsDefaultNoticesJsonURL) } if s.NoticesSkipCache == nil { - s.NoticesSkipCache = NewBool(false) + s.NoticesSkipCache = NewPointer(false) } if s.NoticesFetchFrequency == nil { - s.NoticesFetchFrequency = NewInt(AnnouncementSettingsDefaultNoticesFetchFrequencySeconds) + s.NoticesFetchFrequency = NewPointer(AnnouncementSettingsDefaultNoticesFetchFrequencySeconds) } } @@ -2164,15 +2164,15 @@ type ThemeSettings struct { func (s *ThemeSettings) SetDefaults() { if s.EnableThemeSelection == nil { - s.EnableThemeSelection = NewBool(true) + s.EnableThemeSelection = NewPointer(true) } if s.DefaultTheme == nil { - s.DefaultTheme = NewString(TeamSettingsDefaultTeamText) + s.DefaultTheme = NewPointer(TeamSettingsDefaultTeamText) } if s.AllowCustomThemes == nil { - s.AllowCustomThemes = NewBool(true) + s.AllowCustomThemes = NewPointer(true) } if s.AllowedThemes == nil { @@ -2209,79 +2209,79 @@ type TeamSettings struct { func (s *TeamSettings) SetDefaults() { if s.SiteName == nil || *s.SiteName == "" { - s.SiteName = NewString(TeamSettingsDefaultSiteName) + s.SiteName = NewPointer(TeamSettingsDefaultSiteName) } if s.MaxUsersPerTeam == nil { - s.MaxUsersPerTeam = NewInt(TeamSettingsDefaultMaxUsersPerTeam) + s.MaxUsersPerTeam = NewPointer(TeamSettingsDefaultMaxUsersPerTeam) } if s.EnableJoinLeaveMessageByDefault == nil { - s.EnableJoinLeaveMessageByDefault = NewBool(true) + s.EnableJoinLeaveMessageByDefault = NewPointer(true) } if s.EnableUserCreation == nil { - s.EnableUserCreation = NewBool(true) + s.EnableUserCreation = NewPointer(true) } if s.EnableOpenServer == nil { - s.EnableOpenServer = NewBool(false) + s.EnableOpenServer = NewPointer(false) } if s.RestrictCreationToDomains == nil { - s.RestrictCreationToDomains = NewString("") + s.RestrictCreationToDomains = NewPointer("") } if s.EnableCustomUserStatuses == nil { - s.EnableCustomUserStatuses = NewBool(true) + s.EnableCustomUserStatuses = NewPointer(true) } if s.EnableLastActiveTime == nil { - s.EnableLastActiveTime = NewBool(true) + s.EnableLastActiveTime = NewPointer(true) } if s.EnableCustomBrand == nil { - s.EnableCustomBrand = NewBool(false) + s.EnableCustomBrand = NewPointer(false) } if s.EnableUserDeactivation == nil { - s.EnableUserDeactivation = NewBool(false) + s.EnableUserDeactivation = NewPointer(false) } if s.CustomBrandText == nil { - s.CustomBrandText = NewString(TeamSettingsDefaultCustomBrandText) + s.CustomBrandText = NewPointer(TeamSettingsDefaultCustomBrandText) } if s.CustomDescriptionText == nil { - s.CustomDescriptionText = NewString(TeamSettingsDefaultCustomDescriptionText) + s.CustomDescriptionText = NewPointer(TeamSettingsDefaultCustomDescriptionText) } if s.RestrictDirectMessage == nil { - s.RestrictDirectMessage = NewString(DirectMessageAny) + s.RestrictDirectMessage = NewPointer(DirectMessageAny) } if s.UserStatusAwayTimeout == nil { - s.UserStatusAwayTimeout = NewInt64(TeamSettingsDefaultUserStatusAwayTimeout) + s.UserStatusAwayTimeout = NewPointer(int64(TeamSettingsDefaultUserStatusAwayTimeout)) } if s.MaxChannelsPerTeam == nil { - s.MaxChannelsPerTeam = NewInt64(2000) + s.MaxChannelsPerTeam = NewPointer(int64(2000)) } if s.MaxNotificationsPerChannel == nil { - s.MaxNotificationsPerChannel = NewInt64(1000) + s.MaxNotificationsPerChannel = NewPointer(int64(1000)) } if s.EnableConfirmNotificationsToChannel == nil { - s.EnableConfirmNotificationsToChannel = NewBool(true) + s.EnableConfirmNotificationsToChannel = NewPointer(true) } if s.ExperimentalEnableAutomaticReplies == nil { - s.ExperimentalEnableAutomaticReplies = NewBool(false) + s.ExperimentalEnableAutomaticReplies = NewPointer(false) } if s.ExperimentalPrimaryTeam == nil { - s.ExperimentalPrimaryTeam = NewString("") + s.ExperimentalPrimaryTeam = NewPointer("") } if s.ExperimentalDefaultChannels == nil { @@ -2289,15 +2289,15 @@ func (s *TeamSettings) SetDefaults() { } if s.EnableUserCreation == nil { - s.EnableUserCreation = NewBool(true) + s.EnableUserCreation = NewPointer(true) } if s.ExperimentalViewArchivedChannels == nil { - s.ExperimentalViewArchivedChannels = NewBool(true) + s.ExperimentalViewArchivedChannels = NewPointer(true) } if s.LockTeammateNameDisplay == nil { - s.LockTeammateNameDisplay = NewBool(false) + s.LockTeammateNameDisplay = NewPointer(false) } } @@ -2361,104 +2361,104 @@ type LdapSettings struct { func (s *LdapSettings) SetDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } // When unset should default to LDAP Enabled if s.EnableSync == nil { - s.EnableSync = NewBool(*s.Enable) + s.EnableSync = NewPointer(*s.Enable) } if s.EnableAdminFilter == nil { - s.EnableAdminFilter = NewBool(false) + s.EnableAdminFilter = NewPointer(false) } if s.LdapServer == nil { - s.LdapServer = NewString("") + s.LdapServer = NewPointer("") } if s.LdapPort == nil { - s.LdapPort = NewInt(389) + s.LdapPort = NewPointer(389) } if s.ConnectionSecurity == nil { - s.ConnectionSecurity = NewString("") + s.ConnectionSecurity = NewPointer("") } if s.PublicCertificateFile == nil { - s.PublicCertificateFile = NewString("") + s.PublicCertificateFile = NewPointer("") } if s.PrivateKeyFile == nil { - s.PrivateKeyFile = NewString("") + s.PrivateKeyFile = NewPointer("") } if s.BaseDN == nil { - s.BaseDN = NewString("") + s.BaseDN = NewPointer("") } if s.BindUsername == nil { - s.BindUsername = NewString("") + s.BindUsername = NewPointer("") } if s.BindPassword == nil { - s.BindPassword = NewString("") + s.BindPassword = NewPointer("") } if s.UserFilter == nil { - s.UserFilter = NewString("") + s.UserFilter = NewPointer("") } if s.GuestFilter == nil { - s.GuestFilter = NewString("") + s.GuestFilter = NewPointer("") } if s.AdminFilter == nil { - s.AdminFilter = NewString("") + s.AdminFilter = NewPointer("") } if s.GroupFilter == nil { - s.GroupFilter = NewString("") + s.GroupFilter = NewPointer("") } if s.GroupDisplayNameAttribute == nil { - s.GroupDisplayNameAttribute = NewString(LdapSettingsDefaultGroupDisplayNameAttribute) + s.GroupDisplayNameAttribute = NewPointer(LdapSettingsDefaultGroupDisplayNameAttribute) } if s.GroupIdAttribute == nil { - s.GroupIdAttribute = NewString(LdapSettingsDefaultGroupIdAttribute) + s.GroupIdAttribute = NewPointer(LdapSettingsDefaultGroupIdAttribute) } if s.FirstNameAttribute == nil { - s.FirstNameAttribute = NewString(LdapSettingsDefaultFirstNameAttribute) + s.FirstNameAttribute = NewPointer(LdapSettingsDefaultFirstNameAttribute) } if s.LastNameAttribute == nil { - s.LastNameAttribute = NewString(LdapSettingsDefaultLastNameAttribute) + s.LastNameAttribute = NewPointer(LdapSettingsDefaultLastNameAttribute) } if s.EmailAttribute == nil { - s.EmailAttribute = NewString(LdapSettingsDefaultEmailAttribute) + s.EmailAttribute = NewPointer(LdapSettingsDefaultEmailAttribute) } if s.UsernameAttribute == nil { - s.UsernameAttribute = NewString(LdapSettingsDefaultUsernameAttribute) + s.UsernameAttribute = NewPointer(LdapSettingsDefaultUsernameAttribute) } if s.NicknameAttribute == nil { - s.NicknameAttribute = NewString(LdapSettingsDefaultNicknameAttribute) + s.NicknameAttribute = NewPointer(LdapSettingsDefaultNicknameAttribute) } if s.IdAttribute == nil { - s.IdAttribute = NewString(LdapSettingsDefaultIdAttribute) + s.IdAttribute = NewPointer(LdapSettingsDefaultIdAttribute) } if s.PositionAttribute == nil { - s.PositionAttribute = NewString(LdapSettingsDefaultPositionAttribute) + s.PositionAttribute = NewPointer(LdapSettingsDefaultPositionAttribute) } if s.PictureAttribute == nil { - s.PictureAttribute = NewString(LdapSettingsDefaultPictureAttribute) + s.PictureAttribute = NewPointer(LdapSettingsDefaultPictureAttribute) } // For those upgrading to the version when LoginIdAttribute was added @@ -2468,35 +2468,35 @@ func (s *LdapSettings) SetDefaults() { } if s.SyncIntervalMinutes == nil { - s.SyncIntervalMinutes = NewInt(60) + s.SyncIntervalMinutes = NewPointer(60) } if s.SkipCertificateVerification == nil { - s.SkipCertificateVerification = NewBool(false) + s.SkipCertificateVerification = NewPointer(false) } if s.QueryTimeout == nil { - s.QueryTimeout = NewInt(60) + s.QueryTimeout = NewPointer(60) } if s.MaxPageSize == nil { - s.MaxPageSize = NewInt(0) + s.MaxPageSize = NewPointer(0) } if s.LoginFieldName == nil { - s.LoginFieldName = NewString(LdapSettingsDefaultLoginFieldName) + s.LoginFieldName = NewPointer(LdapSettingsDefaultLoginFieldName) } if s.LoginButtonColor == nil { - s.LoginButtonColor = NewString("#0000") + s.LoginButtonColor = NewPointer("#0000") } if s.LoginButtonBorderColor == nil { - s.LoginButtonBorderColor = NewString("#2389D7") + s.LoginButtonBorderColor = NewPointer("#2389D7") } if s.LoginButtonTextColor == nil { - s.LoginButtonTextColor = NewString("#2389D7") + s.LoginButtonTextColor = NewPointer("#2389D7") } } @@ -2509,19 +2509,19 @@ type ComplianceSettings struct { func (s *ComplianceSettings) SetDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.Directory == nil { - s.Directory = NewString("./data/") + s.Directory = NewPointer("./data/") } if s.EnableDaily == nil { - s.EnableDaily = NewBool(false) + s.EnableDaily = NewPointer(false) } if s.BatchSize == nil { - s.BatchSize = NewInt(30000) + s.BatchSize = NewPointer(30000) } } @@ -2533,15 +2533,15 @@ type LocalizationSettings struct { func (s *LocalizationSettings) SetDefaults() { if s.DefaultServerLocale == nil { - s.DefaultServerLocale = NewString(DefaultLocale) + s.DefaultServerLocale = NewPointer(DefaultLocale) } if s.DefaultClientLocale == nil { - s.DefaultClientLocale = NewString(DefaultLocale) + s.DefaultClientLocale = NewPointer(DefaultLocale) } if s.AvailableLocales == nil { - s.AvailableLocales = NewString("") + s.AvailableLocales = NewPointer("") } } @@ -2594,141 +2594,141 @@ type SamlSettings struct { func (s *SamlSettings) SetDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.EnableSyncWithLdap == nil { - s.EnableSyncWithLdap = NewBool(false) + s.EnableSyncWithLdap = NewPointer(false) } if s.EnableSyncWithLdapIncludeAuth == nil { - s.EnableSyncWithLdapIncludeAuth = NewBool(false) + s.EnableSyncWithLdapIncludeAuth = NewPointer(false) } if s.IgnoreGuestsLdapSync == nil { - s.IgnoreGuestsLdapSync = NewBool(false) + s.IgnoreGuestsLdapSync = NewPointer(false) } if s.EnableAdminAttribute == nil { - s.EnableAdminAttribute = NewBool(false) + s.EnableAdminAttribute = NewPointer(false) } if s.Verify == nil { - s.Verify = NewBool(true) + s.Verify = NewPointer(true) } if s.Encrypt == nil { - s.Encrypt = NewBool(true) + s.Encrypt = NewPointer(true) } if s.SignRequest == nil { - s.SignRequest = NewBool(false) + s.SignRequest = NewPointer(false) } if s.SignatureAlgorithm == nil { - s.SignatureAlgorithm = NewString(SamlSettingsDefaultSignatureAlgorithm) + s.SignatureAlgorithm = NewPointer(SamlSettingsDefaultSignatureAlgorithm) } if s.CanonicalAlgorithm == nil { - s.CanonicalAlgorithm = NewString(SamlSettingsDefaultCanonicalAlgorithm) + s.CanonicalAlgorithm = NewPointer(SamlSettingsDefaultCanonicalAlgorithm) } if s.IdpURL == nil { - s.IdpURL = NewString("") + s.IdpURL = NewPointer("") } if s.IdpDescriptorURL == nil { - s.IdpDescriptorURL = NewString("") + s.IdpDescriptorURL = NewPointer("") } if s.ServiceProviderIdentifier == nil { if s.IdpDescriptorURL != nil { - s.ServiceProviderIdentifier = NewString(*s.IdpDescriptorURL) + s.ServiceProviderIdentifier = NewPointer(*s.IdpDescriptorURL) } else { - s.ServiceProviderIdentifier = NewString("") + s.ServiceProviderIdentifier = NewPointer("") } } if s.IdpMetadataURL == nil { - s.IdpMetadataURL = NewString("") + s.IdpMetadataURL = NewPointer("") } if s.IdpCertificateFile == nil { - s.IdpCertificateFile = NewString("") + s.IdpCertificateFile = NewPointer("") } if s.PublicCertificateFile == nil { - s.PublicCertificateFile = NewString("") + s.PublicCertificateFile = NewPointer("") } if s.PrivateKeyFile == nil { - s.PrivateKeyFile = NewString("") + s.PrivateKeyFile = NewPointer("") } if s.AssertionConsumerServiceURL == nil { - s.AssertionConsumerServiceURL = NewString("") + s.AssertionConsumerServiceURL = NewPointer("") } if s.ScopingIDPProviderId == nil { - s.ScopingIDPProviderId = NewString("") + s.ScopingIDPProviderId = NewPointer("") } if s.ScopingIDPName == nil { - s.ScopingIDPName = NewString("") + s.ScopingIDPName = NewPointer("") } if s.LoginButtonText == nil || *s.LoginButtonText == "" { - s.LoginButtonText = NewString(UserAuthServiceSamlText) + s.LoginButtonText = NewPointer(UserAuthServiceSamlText) } if s.IdAttribute == nil { - s.IdAttribute = NewString(SamlSettingsDefaultIdAttribute) + s.IdAttribute = NewPointer(SamlSettingsDefaultIdAttribute) } if s.GuestAttribute == nil { - s.GuestAttribute = NewString(SamlSettingsDefaultGuestAttribute) + s.GuestAttribute = NewPointer(SamlSettingsDefaultGuestAttribute) } if s.AdminAttribute == nil { - s.AdminAttribute = NewString(SamlSettingsDefaultAdminAttribute) + s.AdminAttribute = NewPointer(SamlSettingsDefaultAdminAttribute) } if s.FirstNameAttribute == nil { - s.FirstNameAttribute = NewString(SamlSettingsDefaultFirstNameAttribute) + s.FirstNameAttribute = NewPointer(SamlSettingsDefaultFirstNameAttribute) } if s.LastNameAttribute == nil { - s.LastNameAttribute = NewString(SamlSettingsDefaultLastNameAttribute) + s.LastNameAttribute = NewPointer(SamlSettingsDefaultLastNameAttribute) } if s.EmailAttribute == nil { - s.EmailAttribute = NewString(SamlSettingsDefaultEmailAttribute) + s.EmailAttribute = NewPointer(SamlSettingsDefaultEmailAttribute) } if s.UsernameAttribute == nil { - s.UsernameAttribute = NewString(SamlSettingsDefaultUsernameAttribute) + s.UsernameAttribute = NewPointer(SamlSettingsDefaultUsernameAttribute) } if s.NicknameAttribute == nil { - s.NicknameAttribute = NewString(SamlSettingsDefaultNicknameAttribute) + s.NicknameAttribute = NewPointer(SamlSettingsDefaultNicknameAttribute) } if s.PositionAttribute == nil { - s.PositionAttribute = NewString(SamlSettingsDefaultPositionAttribute) + s.PositionAttribute = NewPointer(SamlSettingsDefaultPositionAttribute) } if s.LocaleAttribute == nil { - s.LocaleAttribute = NewString(SamlSettingsDefaultLocaleAttribute) + s.LocaleAttribute = NewPointer(SamlSettingsDefaultLocaleAttribute) } if s.LoginButtonColor == nil { - s.LoginButtonColor = NewString("#34a28b") + s.LoginButtonColor = NewPointer("#34a28b") } if s.LoginButtonBorderColor == nil { - s.LoginButtonBorderColor = NewString("#2389D7") + s.LoginButtonBorderColor = NewPointer("#2389D7") } if s.LoginButtonTextColor == nil { - s.LoginButtonTextColor = NewString("#ffffff") + s.LoginButtonTextColor = NewPointer("#ffffff") } } @@ -2741,15 +2741,15 @@ type NativeAppSettings struct { func (s *NativeAppSettings) SetDefaults() { if s.AppDownloadLink == nil { - s.AppDownloadLink = NewString(NativeappSettingsDefaultAppDownloadLink) + s.AppDownloadLink = NewPointer(NativeappSettingsDefaultAppDownloadLink) } if s.AndroidAppDownloadLink == nil { - s.AndroidAppDownloadLink = NewString(NativeappSettingsDefaultAndroidAppDownloadLink) + s.AndroidAppDownloadLink = NewPointer(NativeappSettingsDefaultAndroidAppDownloadLink) } if s.IosAppDownloadLink == nil { - s.IosAppDownloadLink = NewString(NativeappSettingsDefaultIosAppDownloadLink) + s.IosAppDownloadLink = NewPointer(NativeappSettingsDefaultIosAppDownloadLink) } if s.AppCustomURLSchemes == nil { @@ -2789,107 +2789,107 @@ type ElasticsearchSettings struct { func (s *ElasticsearchSettings) SetDefaults() { if s.ConnectionURL == nil { - s.ConnectionURL = NewString(ElasticsearchSettingsDefaultConnectionURL) + s.ConnectionURL = NewPointer(ElasticsearchSettingsDefaultConnectionURL) } if s.Backend == nil { - s.Backend = NewString(ElasticsearchSettingsESBackend) + s.Backend = NewPointer(ElasticsearchSettingsESBackend) } if s.Username == nil { - s.Username = NewString(ElasticsearchSettingsDefaultUsername) + s.Username = NewPointer(ElasticsearchSettingsDefaultUsername) } if s.Password == nil { - s.Password = NewString(ElasticsearchSettingsDefaultPassword) + s.Password = NewPointer(ElasticsearchSettingsDefaultPassword) } if s.CA == nil { - s.CA = NewString("") + s.CA = NewPointer("") } if s.ClientCert == nil { - s.ClientCert = NewString("") + s.ClientCert = NewPointer("") } if s.ClientKey == nil { - s.ClientKey = NewString("") + s.ClientKey = NewPointer("") } if s.EnableIndexing == nil { - s.EnableIndexing = NewBool(false) + s.EnableIndexing = NewPointer(false) } if s.EnableSearching == nil { - s.EnableSearching = NewBool(false) + s.EnableSearching = NewPointer(false) } if s.EnableAutocomplete == nil { - s.EnableAutocomplete = NewBool(false) + s.EnableAutocomplete = NewPointer(false) } if s.Sniff == nil { - s.Sniff = NewBool(true) + s.Sniff = NewPointer(true) } if s.PostIndexReplicas == nil { - s.PostIndexReplicas = NewInt(ElasticsearchSettingsDefaultPostIndexReplicas) + s.PostIndexReplicas = NewPointer(ElasticsearchSettingsDefaultPostIndexReplicas) } if s.PostIndexShards == nil { - s.PostIndexShards = NewInt(ElasticsearchSettingsDefaultPostIndexShards) + s.PostIndexShards = NewPointer(ElasticsearchSettingsDefaultPostIndexShards) } if s.ChannelIndexReplicas == nil { - s.ChannelIndexReplicas = NewInt(ElasticsearchSettingsDefaultChannelIndexReplicas) + s.ChannelIndexReplicas = NewPointer(ElasticsearchSettingsDefaultChannelIndexReplicas) } if s.ChannelIndexShards == nil { - s.ChannelIndexShards = NewInt(ElasticsearchSettingsDefaultChannelIndexShards) + s.ChannelIndexShards = NewPointer(ElasticsearchSettingsDefaultChannelIndexShards) } if s.UserIndexReplicas == nil { - s.UserIndexReplicas = NewInt(ElasticsearchSettingsDefaultUserIndexReplicas) + s.UserIndexReplicas = NewPointer(ElasticsearchSettingsDefaultUserIndexReplicas) } if s.UserIndexShards == nil { - s.UserIndexShards = NewInt(ElasticsearchSettingsDefaultUserIndexShards) + s.UserIndexShards = NewPointer(ElasticsearchSettingsDefaultUserIndexShards) } if s.AggregatePostsAfterDays == nil { - s.AggregatePostsAfterDays = NewInt(ElasticsearchSettingsDefaultAggregatePostsAfterDays) + s.AggregatePostsAfterDays = NewPointer(ElasticsearchSettingsDefaultAggregatePostsAfterDays) } if s.PostsAggregatorJobStartTime == nil { - s.PostsAggregatorJobStartTime = NewString(ElasticsearchSettingsDefaultPostsAggregatorJobStartTime) + s.PostsAggregatorJobStartTime = NewPointer(ElasticsearchSettingsDefaultPostsAggregatorJobStartTime) } if s.IndexPrefix == nil { - s.IndexPrefix = NewString(ElasticsearchSettingsDefaultIndexPrefix) + s.IndexPrefix = NewPointer(ElasticsearchSettingsDefaultIndexPrefix) } if s.LiveIndexingBatchSize == nil { - s.LiveIndexingBatchSize = NewInt(ElasticsearchSettingsDefaultLiveIndexingBatchSize) + s.LiveIndexingBatchSize = NewPointer(ElasticsearchSettingsDefaultLiveIndexingBatchSize) } if s.BatchSize == nil { - s.BatchSize = NewInt(ElasticsearchSettingsDefaultBatchSize) + s.BatchSize = NewPointer(ElasticsearchSettingsDefaultBatchSize) } if s.RequestTimeoutSeconds == nil { - s.RequestTimeoutSeconds = NewInt(ElasticsearchSettingsDefaultRequestTimeoutSeconds) + s.RequestTimeoutSeconds = NewPointer(ElasticsearchSettingsDefaultRequestTimeoutSeconds) } if s.SkipTLSVerification == nil { - s.SkipTLSVerification = NewBool(false) + s.SkipTLSVerification = NewPointer(false) } if s.Trace == nil { - s.Trace = NewString("") + s.Trace = NewPointer("") } if s.IgnoredPurgeIndexes == nil { - s.IgnoredPurgeIndexes = NewString("") + s.IgnoredPurgeIndexes = NewPointer("") } } @@ -2904,23 +2904,23 @@ type BleveSettings struct { func (bs *BleveSettings) SetDefaults() { if bs.IndexDir == nil { - bs.IndexDir = NewString(BleveSettingsDefaultIndexDir) + bs.IndexDir = NewPointer(BleveSettingsDefaultIndexDir) } if bs.EnableIndexing == nil { - bs.EnableIndexing = NewBool(false) + bs.EnableIndexing = NewPointer(false) } if bs.EnableSearching == nil { - bs.EnableSearching = NewBool(false) + bs.EnableSearching = NewPointer(false) } if bs.EnableAutocomplete == nil { - bs.EnableAutocomplete = NewBool(false) + bs.EnableAutocomplete = NewPointer(false) } if bs.BatchSize == nil { - bs.BatchSize = NewInt(BleveSettingsDefaultBatchSize) + bs.BatchSize = NewPointer(BleveSettingsDefaultBatchSize) } } @@ -2941,50 +2941,50 @@ type DataRetentionSettings struct { func (s *DataRetentionSettings) SetDefaults() { if s.EnableMessageDeletion == nil { - s.EnableMessageDeletion = NewBool(false) + s.EnableMessageDeletion = NewPointer(false) } if s.EnableFileDeletion == nil { - s.EnableFileDeletion = NewBool(false) + s.EnableFileDeletion = NewPointer(false) } if s.EnableBoardsDeletion == nil { - s.EnableBoardsDeletion = NewBool(false) + s.EnableBoardsDeletion = NewPointer(false) } if s.MessageRetentionDays == nil { - s.MessageRetentionDays = NewInt(DataRetentionSettingsDefaultMessageRetentionDays) + s.MessageRetentionDays = NewPointer(DataRetentionSettingsDefaultMessageRetentionDays) } if s.MessageRetentionHours == nil { - s.MessageRetentionHours = NewInt(DataRetentionSettingsDefaultMessageRetentionHours) + s.MessageRetentionHours = NewPointer(DataRetentionSettingsDefaultMessageRetentionHours) } if s.FileRetentionDays == nil { - s.FileRetentionDays = NewInt(DataRetentionSettingsDefaultFileRetentionDays) + s.FileRetentionDays = NewPointer(DataRetentionSettingsDefaultFileRetentionDays) } if s.FileRetentionHours == nil { - s.FileRetentionHours = NewInt(DataRetentionSettingsDefaultFileRetentionHours) + s.FileRetentionHours = NewPointer(DataRetentionSettingsDefaultFileRetentionHours) } if s.BoardsRetentionDays == nil { - s.BoardsRetentionDays = NewInt(DataRetentionSettingsDefaultBoardsRetentionDays) + s.BoardsRetentionDays = NewPointer(DataRetentionSettingsDefaultBoardsRetentionDays) } if s.DeletionJobStartTime == nil { - s.DeletionJobStartTime = NewString(DataRetentionSettingsDefaultDeletionJobStartTime) + s.DeletionJobStartTime = NewPointer(DataRetentionSettingsDefaultDeletionJobStartTime) } if s.BatchSize == nil { - s.BatchSize = NewInt(DataRetentionSettingsDefaultBatchSize) + s.BatchSize = NewPointer(DataRetentionSettingsDefaultBatchSize) } if s.TimeBetweenBatchesMilliseconds == nil { - s.TimeBetweenBatchesMilliseconds = NewInt(DataRetentionSettingsDefaultTimeBetweenBatchesMilliseconds) + s.TimeBetweenBatchesMilliseconds = NewPointer(DataRetentionSettingsDefaultTimeBetweenBatchesMilliseconds) } if s.RetentionIdsBatchSize == nil { - s.RetentionIdsBatchSize = NewInt(DataRetentionSettingsDefaultRetentionIdsBatchSize) + s.RetentionIdsBatchSize = NewPointer(DataRetentionSettingsDefaultRetentionIdsBatchSize) } } @@ -3021,19 +3021,19 @@ type JobSettings struct { func (s *JobSettings) SetDefaults() { if s.RunJobs == nil { - s.RunJobs = NewBool(true) + s.RunJobs = NewPointer(true) } if s.RunScheduler == nil { - s.RunScheduler = NewBool(true) + s.RunScheduler = NewPointer(true) } if s.CleanupJobsThresholdDays == nil { - s.CleanupJobsThresholdDays = NewInt(-1) + s.CleanupJobsThresholdDays = NewPointer(-1) } if s.CleanupConfigThresholdDays == nil { - s.CleanupConfigThresholdDays = NewInt(-1) + s.CleanupConfigThresholdDays = NewPointer(-1) } } @@ -3049,18 +3049,18 @@ func (s *CloudSettings) SetDefaults() { if s.CWSURL == nil || serviceEnvironment == ServiceEnvironmentProduction { switch serviceEnvironment { case ServiceEnvironmentProduction: - s.CWSURL = NewString(CloudSettingsDefaultCwsURL) + s.CWSURL = NewPointer(CloudSettingsDefaultCwsURL) case ServiceEnvironmentTest, ServiceEnvironmentDev: - s.CWSURL = NewString(CloudSettingsDefaultCwsURLTest) + s.CWSURL = NewPointer(CloudSettingsDefaultCwsURLTest) } } if s.CWSAPIURL == nil { switch serviceEnvironment { case ServiceEnvironmentProduction: - s.CWSAPIURL = NewString(CloudSettingsDefaultCwsAPIURL) + s.CWSAPIURL = NewPointer(CloudSettingsDefaultCwsAPIURL) case ServiceEnvironmentTest, ServiceEnvironmentDev: - s.CWSAPIURL = NewString(CloudSettingsDefaultCwsAPIURLTest) + s.CWSAPIURL = NewPointer(CloudSettingsDefaultCwsAPIURLTest) } } if s.CWSMock == nil { @@ -3069,7 +3069,7 @@ func (s *CloudSettings) SetDefaults() { } if s.Disable == nil { - s.Disable = NewBool(false) + s.Disable = NewPointer(false) } } @@ -3097,27 +3097,27 @@ type PluginSettings struct { func (s *PluginSettings) SetDefaults(ls LogSettings) { if s.Enable == nil { - s.Enable = NewBool(true) + s.Enable = NewPointer(true) } if s.EnableUploads == nil { - s.EnableUploads = NewBool(false) + s.EnableUploads = NewPointer(false) } if s.AllowInsecureDownloadURL == nil { - s.AllowInsecureDownloadURL = NewBool(false) + s.AllowInsecureDownloadURL = NewPointer(false) } if s.EnableHealthCheck == nil { - s.EnableHealthCheck = NewBool(true) + s.EnableHealthCheck = NewPointer(true) } if s.Directory == nil || *s.Directory == "" { - s.Directory = NewString(PluginSettingsDefaultDirectory) + s.Directory = NewPointer(PluginSettingsDefaultDirectory) } if s.ClientDirectory == nil || *s.ClientDirectory == "" { - s.ClientDirectory = NewString(PluginSettingsDefaultClientDirectory) + s.ClientDirectory = NewPointer(PluginSettingsDefaultClientDirectory) } if s.Plugins == nil { @@ -3144,23 +3144,23 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) { } if s.EnableMarketplace == nil { - s.EnableMarketplace = NewBool(PluginSettingsDefaultEnableMarketplace) + s.EnableMarketplace = NewPointer(PluginSettingsDefaultEnableMarketplace) } if s.EnableRemoteMarketplace == nil { - s.EnableRemoteMarketplace = NewBool(true) + s.EnableRemoteMarketplace = NewPointer(true) } if s.AutomaticPrepackagedPlugins == nil { - s.AutomaticPrepackagedPlugins = NewBool(true) + s.AutomaticPrepackagedPlugins = NewPointer(true) } if s.MarketplaceURL == nil || *s.MarketplaceURL == "" || *s.MarketplaceURL == PluginSettingsOldMarketplaceURL { - s.MarketplaceURL = NewString(PluginSettingsDefaultMarketplaceURL) + s.MarketplaceURL = NewPointer(PluginSettingsDefaultMarketplaceURL) } if s.RequirePluginSignature == nil { - s.RequirePluginSignature = NewBool(false) + s.RequirePluginSignature = NewPointer(false) } if s.SignaturePublicKeyFiles == nil { @@ -3168,7 +3168,7 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) { } if s.ChimeraOAuthProxyURL == nil { - s.ChimeraOAuthProxyURL = NewString("") + s.ChimeraOAuthProxyURL = NewPointer("") } } @@ -3190,19 +3190,19 @@ func (w *WranglerSettings) SetDefaults() { w.AllowedEmailDomain = make([]string, 0) } if w.MoveThreadMaxCount == nil { - w.MoveThreadMaxCount = NewInt64(100) + w.MoveThreadMaxCount = NewPointer(int64(100)) } if w.MoveThreadToAnotherTeamEnable == nil { - w.MoveThreadToAnotherTeamEnable = NewBool(false) + w.MoveThreadToAnotherTeamEnable = NewPointer(false) } if w.MoveThreadFromPrivateChannelEnable == nil { - w.MoveThreadFromPrivateChannelEnable = NewBool(false) + w.MoveThreadFromPrivateChannelEnable = NewPointer(false) } if w.MoveThreadFromDirectMessageChannelEnable == nil { - w.MoveThreadFromDirectMessageChannelEnable = NewBool(false) + w.MoveThreadFromDirectMessageChannelEnable = NewPointer(false) } if w.MoveThreadFromGroupMessageChannelEnable == nil { - w.MoveThreadFromGroupMessageChannelEnable = NewBool(false) + w.MoveThreadFromGroupMessageChannelEnable = NewPointer(false) } } @@ -3229,25 +3229,25 @@ type GlobalRelayMessageExportSettings struct { func (s *GlobalRelayMessageExportSettings) SetDefaults() { if s.CustomerType == nil { - s.CustomerType = NewString(GlobalrelayCustomerTypeA9) + s.CustomerType = NewPointer(GlobalrelayCustomerTypeA9) } if s.SMTPUsername == nil { - s.SMTPUsername = NewString("") + s.SMTPUsername = NewPointer("") } if s.SMTPPassword == nil { - s.SMTPPassword = NewString("") + s.SMTPPassword = NewPointer("") } if s.EmailAddress == nil { - s.EmailAddress = NewString("") + s.EmailAddress = NewPointer("") } if s.SMTPServerTimeout == nil || *s.SMTPServerTimeout == 0 { - s.SMTPServerTimeout = NewInt(1800) + s.SMTPServerTimeout = NewPointer(1800) } if s.CustomSMTPServerName == nil { - s.CustomSMTPServerName = NewString("") + s.CustomSMTPServerName = NewPointer("") } if s.CustomSMTPPort == nil { - s.CustomSMTPPort = NewString("25") + s.CustomSMTPPort = NewPointer("25") } } @@ -3265,27 +3265,27 @@ type MessageExportSettings struct { func (s *MessageExportSettings) SetDefaults() { if s.EnableExport == nil { - s.EnableExport = NewBool(false) + s.EnableExport = NewPointer(false) } if s.DownloadExportResults == nil { - s.DownloadExportResults = NewBool(false) + s.DownloadExportResults = NewPointer(false) } if s.ExportFormat == nil { - s.ExportFormat = NewString(ComplianceExportTypeActiance) + s.ExportFormat = NewPointer(ComplianceExportTypeActiance) } if s.DailyRunTime == nil { - s.DailyRunTime = NewString("01:00") + s.DailyRunTime = NewPointer("01:00") } if s.ExportFromTimestamp == nil { - s.ExportFromTimestamp = NewInt64(0) + s.ExportFromTimestamp = NewPointer(int64(0)) } if s.BatchSize == nil { - s.BatchSize = NewInt(10000) + s.BatchSize = NewPointer(10000) } if s.GlobalRelaySettings == nil { @@ -3306,7 +3306,7 @@ func (s *DisplaySettings) SetDefaults() { } if s.MaxMarkdownNodes == nil { - s.MaxMarkdownNodes = NewInt(0) + s.MaxMarkdownNodes = NewPointer(0) } } @@ -3320,23 +3320,23 @@ type GuestAccountsSettings struct { func (s *GuestAccountsSettings) SetDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.HideTags == nil { - s.HideTags = NewBool(false) + s.HideTags = NewPointer(false) } if s.AllowEmailAccounts == nil { - s.AllowEmailAccounts = NewBool(true) + s.AllowEmailAccounts = NewPointer(true) } if s.EnforceMultifactorAuthentication == nil { - s.EnforceMultifactorAuthentication = NewBool(false) + s.EnforceMultifactorAuthentication = NewPointer(false) } if s.RestrictCreationToDomains == nil { - s.RestrictCreationToDomains = NewString("") + s.RestrictCreationToDomains = NewPointer("") } } @@ -3349,19 +3349,19 @@ type ImageProxySettings struct { func (s *ImageProxySettings) SetDefaults() { if s.Enable == nil { - s.Enable = NewBool(false) + s.Enable = NewPointer(false) } if s.ImageProxyType == nil { - s.ImageProxyType = NewString(ImageProxyTypeLocal) + s.ImageProxyType = NewPointer(ImageProxyTypeLocal) } if s.RemoteImageProxyURL == nil { - s.RemoteImageProxyURL = NewString("") + s.RemoteImageProxyURL = NewPointer("") } if s.RemoteImageProxyOptions == nil { - s.RemoteImageProxyOptions = NewString("") + s.RemoteImageProxyOptions = NewPointer("") } } @@ -3388,11 +3388,11 @@ func (s *ImportSettings) isValid() *AppError { // SetDefaults applies the default settings to the struct. func (s *ImportSettings) SetDefaults() { if s.Directory == nil || *s.Directory == "" { - s.Directory = NewString(ImportSettingsDefaultDirectory) + s.Directory = NewPointer(ImportSettingsDefaultDirectory) } if s.RetentionDays == nil { - s.RetentionDays = NewInt(ImportSettingsDefaultRetentionDays) + s.RetentionDays = NewPointer(ImportSettingsDefaultRetentionDays) } } @@ -3419,11 +3419,11 @@ func (s *ExportSettings) isValid() *AppError { // SetDefaults applies the default settings to the struct. func (s *ExportSettings) SetDefaults() { if s.Directory == nil || *s.Directory == "" { - s.Directory = NewString(ExportSettingsDefaultDirectory) + s.Directory = NewPointer(ExportSettingsDefaultDirectory) } if s.RetentionDays == nil { - s.RetentionDays = NewInt(ExportSettingsDefaultRetentionDays) + s.RetentionDays = NewPointer(ExportSettingsDefaultRetentionDays) } } @@ -3579,7 +3579,7 @@ func (o *Config) SetDefaults() { o.SamlSettings.SetDefaults() if o.TeamSettings.TeammateNameDisplay == nil { - o.TeamSettings.TeammateNameDisplay = NewString(ShowUsername) + o.TeamSettings.TeammateNameDisplay = NewPointer(ShowUsername) if *o.SamlSettings.Enable || *o.LdapSettings.Enable { *o.TeamSettings.TeammateNameDisplay = ShowFullName @@ -4389,7 +4389,7 @@ func (o *Config) Sanitize() { } for i := range o.SqlSettings.ReplicaLagSettings { - o.SqlSettings.ReplicaLagSettings[i].DataSource = NewString(FakeSetting) + o.SqlSettings.ReplicaLagSettings[i].DataSource = NewPointer(FakeSetting) } if o.MessageExportSettings.GlobalRelaySettings != nil && diff --git a/server/public/model/config_test.go b/server/public/model/config_test.go index 8e8456f5fd..98c1eea681 100644 --- a/server/public/model/config_test.go +++ b/server/public/model/config_test.go @@ -66,7 +66,7 @@ func TestConfigDefaults(t *testing.T) { func TestConfigEmptySiteName(t *testing.T) { c1 := Config{ TeamSettings: TeamSettings{ - SiteName: NewString(""), + SiteName: NewPointer(""), }, } c1.SetDefaults() @@ -85,19 +85,19 @@ func TestServiceSettingsIsValid(t *testing.T) { }, "OutgoingIntegrationRequestsTimeout is negative": { ServiceSettings: ServiceSettings{ - OutgoingIntegrationRequestsTimeout: NewInt64(-1), + OutgoingIntegrationRequestsTimeout: NewPointer(int64(-1)), }, ExpectError: true, }, "OutgoingIntegrationRequestsTimeout is zero": { ServiceSettings: ServiceSettings{ - OutgoingIntegrationRequestsTimeout: NewInt64(0), + OutgoingIntegrationRequestsTimeout: NewPointer(int64(0)), }, ExpectError: true, }, "OutgoingIntegrationRequestsTimeout is positiv": { ServiceSettings: ServiceSettings{ - OutgoingIntegrationRequestsTimeout: NewInt64(1), + OutgoingIntegrationRequestsTimeout: NewPointer(int64(1)), }, ExpectError: false, }, @@ -121,8 +121,8 @@ func TestConfigEnableDeveloper(t *testing.T) { EnableDeveloper *bool ExpectedSiteURL string }{ - {"enable developer is true", NewBool(true), ServiceSettingsDefaultSiteURL}, - {"enable developer is false", NewBool(false), ""}, + {"enable developer is true", NewPointer(true), ServiceSettingsDefaultSiteURL}, + {"enable developer is false", NewPointer(false), ""}, {"enable developer is nil", nil, ""}, } @@ -173,8 +173,8 @@ func TestConfigOverwriteSignatureAlgorithm(t *testing.T) { const testAlgorithm = "FakeAlgorithm" c1 := Config{ SamlSettings: SamlSettings{ - CanonicalAlgorithm: NewString(testAlgorithm), - SignatureAlgorithm: NewString(testAlgorithm), + CanonicalAlgorithm: NewPointer(testAlgorithm), + SignatureAlgorithm: NewPointer(testAlgorithm), }, } @@ -224,14 +224,14 @@ func TestConfigIsValidDefaultAlgorithms(t *testing.T) { func TestConfigServiceProviderDefault(t *testing.T) { c1 := &Config{ SamlSettings: SamlSettings{ - Enable: NewBool(true), - Verify: NewBool(false), - Encrypt: NewBool(false), - IdpURL: NewString("http://test.url.com"), - IdpDescriptorURL: NewString("http://test2.url.com"), - IdpCertificateFile: NewString("certificatefile"), - EmailAttribute: NewString("Email"), - UsernameAttribute: NewString("Username"), + Enable: NewPointer(true), + Verify: NewPointer(false), + Encrypt: NewPointer(false), + IdpURL: NewPointer("http://test.url.com"), + IdpDescriptorURL: NewPointer("http://test2.url.com"), + IdpCertificateFile: NewPointer("certificatefile"), + EmailAttribute: NewPointer("Email"), + UsernameAttribute: NewPointer("Username"), }, } @@ -277,7 +277,7 @@ func TestConfigOverwriteGuestSettings(t *testing.T) { const attribute = "FakeAttributeName" c1 := Config{ SamlSettings: SamlSettings{ - GuestAttribute: NewString(attribute), + GuestAttribute: NewPointer(attribute), }, } @@ -290,7 +290,7 @@ func TestConfigOverwriteAdminSettings(t *testing.T) { const attribute = "FakeAttributeName" c1 := Config{ SamlSettings: SamlSettings{ - AdminAttribute: NewString(attribute), + AdminAttribute: NewPointer(attribute), }, } @@ -308,7 +308,7 @@ func TestConfigDefaultServiceSettingsExperimentalGroupUnreadChannels(t *testing. // This setting was briefly a boolean, so ensure that those values still work as expected c1 = Config{ ServiceSettings: ServiceSettings{ - ExperimentalGroupUnreadChannels: NewString("1"), + ExperimentalGroupUnreadChannels: NewPointer("1"), }, } c1.SetDefaults() @@ -317,7 +317,7 @@ func TestConfigDefaultServiceSettingsExperimentalGroupUnreadChannels(t *testing. c1 = Config{ ServiceSettings: ServiceSettings{ - ExperimentalGroupUnreadChannels: NewString("0"), + ExperimentalGroupUnreadChannels: NewPointer("0"), }, } c1.SetDefaults() @@ -336,7 +336,7 @@ func TestConfigDefaultNPSPluginState(t *testing.T) { t.Run("should enable NPS plugin if diagnostics are enabled", func(t *testing.T) { c1 := Config{ LogSettings: LogSettings{ - EnableDiagnostics: NewBool(true), + EnableDiagnostics: NewPointer(true), }, } @@ -348,7 +348,7 @@ func TestConfigDefaultNPSPluginState(t *testing.T) { t.Run("should not enable NPS plugin if diagnostics are disabled", func(t *testing.T) { c1 := Config{ LogSettings: LogSettings{ - EnableDiagnostics: NewBool(false), + EnableDiagnostics: NewPointer(false), }, } @@ -387,7 +387,7 @@ func TestConfigDefaultChannelExportPluginState(t *testing.T) { func TestTeamSettingsIsValidSiteNameEmpty(t *testing.T) { c1 := Config{} c1.SetDefaults() - c1.TeamSettings.SiteName = NewString("") + c1.TeamSettings.SiteName = NewPointer("") // should not fail if ts.SiteName is not set, defaults are used require.Nil(t, c1.TeamSettings.isValid()) @@ -398,7 +398,7 @@ func TestTeamSettingsDefaultJoinLeaveMessage(t *testing.T) { c1.SetDefaults() // should default to true - require.Equal(t, NewBool(true), c1.TeamSettings.EnableJoinLeaveMessageByDefault) + require.Equal(t, NewPointer(true), c1.TeamSettings.EnableJoinLeaveMessageByDefault) } func TestMessageExportSettingsIsValidEnableExportNotSet(t *testing.T) { @@ -410,7 +410,7 @@ func TestMessageExportSettingsIsValidEnableExportNotSet(t *testing.T) { func TestMessageExportSettingsIsValidEnableExportFalse(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(false), + EnableExport: NewPointer(false), } // should fail fast because message export isn't enabled @@ -419,18 +419,18 @@ func TestMessageExportSettingsIsValidEnableExportFalse(t *testing.T) { func TestMessageExportSettingsIsValidExportFromTimestampInvalid(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), + EnableExport: NewPointer(true), } // should fail fast because export from timestamp isn't set require.NotNil(t, mes.isValid()) - mes.ExportFromTimestamp = NewInt64(-1) + mes.ExportFromTimestamp = NewPointer(int64(-1)) // should fail fast because export from timestamp isn't valid require.NotNil(t, mes.isValid()) - mes.ExportFromTimestamp = NewInt64(GetMillis() + 10000) + mes.ExportFromTimestamp = NewPointer(GetMillis() + 10000) // should fail fast because export from timestamp is greater than current time require.NotNil(t, mes.isValid()) @@ -438,14 +438,14 @@ func TestMessageExportSettingsIsValidExportFromTimestampInvalid(t *testing.T) { func TestMessageExportSettingsIsValidDailyRunTimeInvalid(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFromTimestamp: NewInt64(0), + EnableExport: NewPointer(true), + ExportFromTimestamp: NewPointer(int64(0)), } // should fail fast because daily runtime isn't set require.NotNil(t, mes.isValid()) - mes.DailyRunTime = NewString("33:33:33") + mes.DailyRunTime = NewPointer("33:33:33") // should fail fast because daily runtime is invalid format require.NotNil(t, mes.isValid()) @@ -453,9 +453,9 @@ func TestMessageExportSettingsIsValidDailyRunTimeInvalid(t *testing.T) { func TestMessageExportSettingsIsValidBatchSizeInvalid(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), + EnableExport: NewPointer(true), + ExportFromTimestamp: NewPointer(int64(0)), + DailyRunTime: NewPointer("15:04"), } // should fail fast because batch size isn't set @@ -464,10 +464,10 @@ func TestMessageExportSettingsIsValidBatchSizeInvalid(t *testing.T) { func TestMessageExportSettingsIsValidExportFormatInvalid(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), - BatchSize: NewInt(100), + EnableExport: NewPointer(true), + ExportFromTimestamp: NewPointer(int64(0)), + DailyRunTime: NewPointer("15:04"), + BatchSize: NewPointer(100), } // should fail fast because export format isn't set @@ -476,11 +476,11 @@ func TestMessageExportSettingsIsValidExportFormatInvalid(t *testing.T) { func TestMessageExportSettingsIsValidGlobalRelayEmailAddressInvalid(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFormat: NewString(ComplianceExportTypeGlobalrelay), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), - BatchSize: NewInt(100), + EnableExport: NewPointer(true), + ExportFormat: NewPointer(ComplianceExportTypeGlobalrelay), + ExportFromTimestamp: NewPointer(int64(0)), + DailyRunTime: NewPointer("15:04"), + BatchSize: NewPointer(100), } // should fail fast because global relay email address isn't set @@ -489,11 +489,11 @@ func TestMessageExportSettingsIsValidGlobalRelayEmailAddressInvalid(t *testing.T func TestMessageExportSettingsIsValidActiance(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFormat: NewString(ComplianceExportTypeActiance), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), - BatchSize: NewInt(100), + EnableExport: NewPointer(true), + ExportFormat: NewPointer(ComplianceExportTypeActiance), + ExportFromTimestamp: NewPointer(int64(0)), + DailyRunTime: NewPointer("15:04"), + BatchSize: NewPointer(100), } // should pass because everything is valid @@ -502,11 +502,11 @@ func TestMessageExportSettingsIsValidActiance(t *testing.T) { func TestMessageExportSettingsIsValidGlobalRelaySettingsMissing(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFormat: NewString(ComplianceExportTypeGlobalrelay), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), - BatchSize: NewInt(100), + EnableExport: NewPointer(true), + ExportFormat: NewPointer(ComplianceExportTypeGlobalrelay), + ExportFromTimestamp: NewPointer(int64(0)), + DailyRunTime: NewPointer("15:04"), + BatchSize: NewPointer(100), } // should fail because globalrelay settings are missing @@ -515,16 +515,16 @@ func TestMessageExportSettingsIsValidGlobalRelaySettingsMissing(t *testing.T) { func TestMessageExportSettingsIsValidGlobalRelaySettingsInvalidCustomerType(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFormat: NewString(ComplianceExportTypeGlobalrelay), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), - BatchSize: NewInt(100), + EnableExport: NewPointer(true), + ExportFormat: NewPointer(ComplianceExportTypeGlobalrelay), + ExportFromTimestamp: NewPointer(int64(0)), + DailyRunTime: NewPointer("15:04"), + BatchSize: NewPointer(100), GlobalRelaySettings: &GlobalRelayMessageExportSettings{ - CustomerType: NewString("Invalid"), - EmailAddress: NewString("valid@mattermost.com"), - SMTPUsername: NewString("SomeUsername"), - SMTPPassword: NewString("SomePassword"), + CustomerType: NewPointer("Invalid"), + EmailAddress: NewPointer("valid@mattermost.com"), + SMTPUsername: NewPointer("SomeUsername"), + SMTPPassword: NewPointer("SomePassword"), }, } @@ -542,49 +542,49 @@ func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) { { "Invalid email address", &GlobalRelayMessageExportSettings{ - CustomerType: NewString(GlobalrelayCustomerTypeA9), - EmailAddress: NewString("invalidEmailAddress"), - SMTPUsername: NewString("SomeUsername"), - SMTPPassword: NewString("SomePassword"), + CustomerType: NewPointer(GlobalrelayCustomerTypeA9), + EmailAddress: NewPointer("invalidEmailAddress"), + SMTPUsername: NewPointer("SomeUsername"), + SMTPPassword: NewPointer("SomePassword"), }, false, }, { "Missing smtp username", &GlobalRelayMessageExportSettings{ - CustomerType: NewString(GlobalrelayCustomerTypeA10), - EmailAddress: NewString("valid@mattermost.com"), - SMTPPassword: NewString("SomePassword"), + CustomerType: NewPointer(GlobalrelayCustomerTypeA10), + EmailAddress: NewPointer("valid@mattermost.com"), + SMTPPassword: NewPointer("SomePassword"), }, false, }, { "Invalid smtp username", &GlobalRelayMessageExportSettings{ - CustomerType: NewString(GlobalrelayCustomerTypeA10), - EmailAddress: NewString("valid@mattermost.com"), - SMTPUsername: NewString(""), - SMTPPassword: NewString("SomePassword"), + CustomerType: NewPointer(GlobalrelayCustomerTypeA10), + EmailAddress: NewPointer("valid@mattermost.com"), + SMTPUsername: NewPointer(""), + SMTPPassword: NewPointer("SomePassword"), }, false, }, { "Invalid smtp password", &GlobalRelayMessageExportSettings{ - CustomerType: NewString(GlobalrelayCustomerTypeA10), - EmailAddress: NewString("valid@mattermost.com"), - SMTPUsername: NewString("SomeUsername"), - SMTPPassword: NewString(""), + CustomerType: NewPointer(GlobalrelayCustomerTypeA10), + EmailAddress: NewPointer("valid@mattermost.com"), + SMTPUsername: NewPointer("SomeUsername"), + SMTPPassword: NewPointer(""), }, false, }, { "Valid data", &GlobalRelayMessageExportSettings{ - CustomerType: NewString(GlobalrelayCustomerTypeA9), - EmailAddress: NewString("valid@mattermost.com"), - SMTPUsername: NewString("SomeUsername"), - SMTPPassword: NewString("SomePassword"), + CustomerType: NewPointer(GlobalrelayCustomerTypeA9), + EmailAddress: NewPointer("valid@mattermost.com"), + SMTPUsername: NewPointer("SomeUsername"), + SMTPPassword: NewPointer("SomePassword"), }, true, }, @@ -593,11 +593,11 @@ func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFormat: NewString(ComplianceExportTypeGlobalrelay), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), - BatchSize: NewInt(100), + EnableExport: NewPointer(true), + ExportFormat: NewPointer(ComplianceExportTypeGlobalrelay), + ExportFromTimestamp: NewPointer(int64(0)), + DailyRunTime: NewPointer("15:04"), + BatchSize: NewPointer(100), GlobalRelaySettings: tt.value, } @@ -624,7 +624,7 @@ func TestMessageExportSetDefaults(t *testing.T) { func TestMessageExportSetDefaultsExportEnabledExportFromTimestampNil(t *testing.T) { // Test retained as protection against regression of MM-13185 mes := &MessageExportSettings{ - EnableExport: NewBool(true), + EnableExport: NewPointer(true), } mes.SetDefaults() @@ -638,8 +638,8 @@ func TestMessageExportSetDefaultsExportEnabledExportFromTimestampNil(t *testing. func TestMessageExportSetDefaultsExportEnabledExportFromTimestampZero(t *testing.T) { // Test retained as protection against regression of MM-13185 mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFromTimestamp: NewInt64(0), + EnableExport: NewPointer(true), + ExportFromTimestamp: NewPointer(int64(0)), } mes.SetDefaults() @@ -652,8 +652,8 @@ func TestMessageExportSetDefaultsExportEnabledExportFromTimestampZero(t *testing func TestMessageExportSetDefaultsExportEnabledExportFromTimestampNonZero(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFromTimestamp: NewInt64(12345), + EnableExport: NewPointer(true), + ExportFromTimestamp: NewPointer(int64(12345)), } mes.SetDefaults() @@ -665,7 +665,7 @@ func TestMessageExportSetDefaultsExportEnabledExportFromTimestampNonZero(t *test func TestMessageExportSetDefaultsExportDisabledExportFromTimestampNil(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(false), + EnableExport: NewPointer(false), } mes.SetDefaults() @@ -677,8 +677,8 @@ func TestMessageExportSetDefaultsExportDisabledExportFromTimestampNil(t *testing func TestMessageExportSetDefaultsExportDisabledExportFromTimestampZero(t *testing.T) { mes := &MessageExportSettings{ - EnableExport: NewBool(false), - ExportFromTimestamp: NewInt64(0), + EnableExport: NewPointer(false), + ExportFromTimestamp: NewPointer(int64(0)), } mes.SetDefaults() @@ -691,8 +691,8 @@ func TestMessageExportSetDefaultsExportDisabledExportFromTimestampZero(t *testin func TestMessageExportSetDefaultsExportDisabledExportFromTimestampNonZero(t *testing.T) { // Test retained as protection against regression of MM-13185 mes := &MessageExportSettings{ - EnableExport: NewBool(false), - ExportFromTimestamp: NewInt64(12345), + EnableExport: NewPointer(false), + ExportFromTimestamp: NewPointer(int64(12345)), } mes.SetDefaults() @@ -812,7 +812,7 @@ func TestListenAddressIsValidated(t *testing.T) { for key, expected := range testValues { ss := &ServiceSettings{ - ListenAddress: NewString(key), + ListenAddress: NewPointer(key), } ss.SetDefaults(true) if expected { @@ -925,133 +925,133 @@ func TestLdapSettingsIsValid(t *testing.T) { { Name: "disabled", LdapSettings: LdapSettings{ - Enable: NewBool(false), + Enable: NewPointer(false), }, ExpectError: false, }, { Name: "missing server", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString(""), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString(""), + Enable: NewPointer(true), + LdapServer: NewPointer(""), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer(""), }, ExpectError: true, }, { Name: "empty user filter", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString(""), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer(""), }, ExpectError: false, }, { Name: "valid user filter #1", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString("(property=value)"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer("(property=value)"), }, ExpectError: false, }, { Name: "invalid user filter #1", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString("("), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer("("), }, ExpectError: true, }, { Name: "invalid user filter #2", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString("()"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer("()"), }, ExpectError: true, }, { Name: "valid user filter #2", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString("(&(property=value)(otherthing=othervalue))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer("(&(property=value)(otherthing=othervalue))"), }, ExpectError: false, }, { Name: "valid user filter #3", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString("(&(property=value)(|(otherthing=othervalue)(other=thing)))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer("(&(property=value)(|(otherthing=othervalue)(other=thing)))"), }, ExpectError: false, }, { Name: "invalid user filter #3", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString("(&(property=value)(|(otherthing=othervalue)(other=thing))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer("(&(property=value)(|(otherthing=othervalue)(other=thing))"), }, ExpectError: true, }, { Name: "invalid user filter #4", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - UserFilter: NewString("(&(property=value)((otherthing=othervalue)(other=thing)))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + UserFilter: NewPointer("(&(property=value)((otherthing=othervalue)(other=thing)))"), }, ExpectError: true, }, @@ -1059,98 +1059,98 @@ func TestLdapSettingsIsValid(t *testing.T) { { Name: "valid guest filter #1", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - GuestFilter: NewString("(property=value)"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + GuestFilter: NewPointer("(property=value)"), }, ExpectError: false, }, { Name: "invalid guest filter #1", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - GuestFilter: NewString("("), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + GuestFilter: NewPointer("("), }, ExpectError: true, }, { Name: "invalid guest filter #2", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - GuestFilter: NewString("()"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + GuestFilter: NewPointer("()"), }, ExpectError: true, }, { Name: "valid guest filter #2", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - GuestFilter: NewString("(&(property=value)(otherthing=othervalue))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + GuestFilter: NewPointer("(&(property=value)(otherthing=othervalue))"), }, ExpectError: false, }, { Name: "valid guest filter #3", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - GuestFilter: NewString("(&(property=value)(|(otherthing=othervalue)(other=thing)))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + GuestFilter: NewPointer("(&(property=value)(|(otherthing=othervalue)(other=thing)))"), }, ExpectError: false, }, { Name: "invalid guest filter #3", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - GuestFilter: NewString("(&(property=value)(|(otherthing=othervalue)(other=thing))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + GuestFilter: NewPointer("(&(property=value)(|(otherthing=othervalue)(other=thing))"), }, ExpectError: true, }, { Name: "invalid guest filter #4", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - GuestFilter: NewString("(&(property=value)((otherthing=othervalue)(other=thing)))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + GuestFilter: NewPointer("(&(property=value)((otherthing=othervalue)(other=thing)))"), }, ExpectError: true, }, @@ -1158,98 +1158,98 @@ func TestLdapSettingsIsValid(t *testing.T) { { Name: "valid Admin filter #1", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - AdminFilter: NewString("(property=value)"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + AdminFilter: NewPointer("(property=value)"), }, ExpectError: false, }, { Name: "invalid Admin filter #1", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - AdminFilter: NewString("("), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + AdminFilter: NewPointer("("), }, ExpectError: true, }, { Name: "invalid Admin filter #2", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - AdminFilter: NewString("()"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + AdminFilter: NewPointer("()"), }, ExpectError: true, }, { Name: "valid Admin filter #2", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - AdminFilter: NewString("(&(property=value)(otherthing=othervalue))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + AdminFilter: NewPointer("(&(property=value)(otherthing=othervalue))"), }, ExpectError: false, }, { Name: "valid Admin filter #3", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - AdminFilter: NewString("(&(property=value)(|(otherthing=othervalue)(other=thing)))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + AdminFilter: NewPointer("(&(property=value)(|(otherthing=othervalue)(other=thing)))"), }, ExpectError: false, }, { Name: "invalid Admin filter #3", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - AdminFilter: NewString("(&(property=value)(|(otherthing=othervalue)(other=thing))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + AdminFilter: NewPointer("(&(property=value)(|(otherthing=othervalue)(other=thing))"), }, ExpectError: true, }, { Name: "invalid Admin filter #4", LdapSettings: LdapSettings{ - Enable: NewBool(true), - LdapServer: NewString("server"), - BaseDN: NewString("basedn"), - EmailAttribute: NewString("email"), - UsernameAttribute: NewString("username"), - IdAttribute: NewString("id"), - LoginIdAttribute: NewString("loginid"), - AdminFilter: NewString("(&(property=value)((otherthing=othervalue)(other=thing)))"), + Enable: NewPointer(true), + LdapServer: NewPointer("server"), + BaseDN: NewPointer("basedn"), + EmailAttribute: NewPointer("email"), + UsernameAttribute: NewPointer("username"), + IdAttribute: NewPointer("id"), + LoginIdAttribute: NewPointer("loginid"), + AdminFilter: NewPointer("(&(property=value)((otherthing=othervalue)(other=thing)))"), }, ExpectError: true, }, @@ -1388,9 +1388,9 @@ func TestConfigSanitize(t *testing.T) { c.SqlSettings.DataSourceReplicas = []string{"stuff"} c.SqlSettings.DataSourceSearchReplicas = []string{"stuff"} c.SqlSettings.ReplicaLagSettings = []*ReplicaLagSettings{{ - DataSource: NewString("DataSource"), - QueryAbsoluteLag: NewString("QueryAbsoluteLag"), - QueryTimeLag: NewString("QueryTimeLag"), + DataSource: NewPointer("DataSource"), + QueryAbsoluteLag: NewPointer("QueryAbsoluteLag"), + QueryTimeLag: NewPointer("QueryTimeLag"), }} c.Sanitize() @@ -1681,7 +1681,7 @@ func TestConfigGetMessageRetentionHours(t *testing.T) { name: "should return MessageRetentionHours config value", config: Config{ DataRetentionSettings: DataRetentionSettings{ - MessageRetentionHours: NewInt(48), + MessageRetentionHours: NewPointer(48), }, }, value: 48, @@ -1690,8 +1690,8 @@ func TestConfigGetMessageRetentionHours(t *testing.T) { name: "should return MessageRetentionHours config value", config: Config{ DataRetentionSettings: DataRetentionSettings{ - MessageRetentionDays: NewInt(50), - MessageRetentionHours: NewInt(48), + MessageRetentionDays: NewPointer(50), + MessageRetentionHours: NewPointer(48), }, }, value: 48, @@ -1700,8 +1700,8 @@ func TestConfigGetMessageRetentionHours(t *testing.T) { name: "should return MessageRetentionDays config value in hours", config: Config{ DataRetentionSettings: DataRetentionSettings{ - MessageRetentionDays: NewInt(50), - MessageRetentionHours: NewInt(0), + MessageRetentionDays: NewPointer(50), + MessageRetentionHours: NewPointer(0), }, }, value: 1200, @@ -1732,7 +1732,7 @@ func TestConfigGetFileRetentionHours(t *testing.T) { name: "should return FileRetentionHours config value", config: Config{ DataRetentionSettings: DataRetentionSettings{ - FileRetentionHours: NewInt(48), + FileRetentionHours: NewPointer(48), }, }, value: 48, @@ -1741,8 +1741,8 @@ func TestConfigGetFileRetentionHours(t *testing.T) { name: "should return FileRetentionHours config value", config: Config{ DataRetentionSettings: DataRetentionSettings{ - FileRetentionDays: NewInt(50), - FileRetentionHours: NewInt(48), + FileRetentionDays: NewPointer(50), + FileRetentionHours: NewPointer(48), }, }, value: 48, @@ -1751,8 +1751,8 @@ func TestConfigGetFileRetentionHours(t *testing.T) { name: "should return FileRetentionDays config value in hours", config: Config{ DataRetentionSettings: DataRetentionSettings{ - FileRetentionDays: NewInt(50), - FileRetentionHours: NewInt(0), + FileRetentionDays: NewPointer(50), + FileRetentionHours: NewPointer(0), }, }, value: 1200, diff --git a/server/public/model/example_channel_test.go b/server/public/model/example_channel_test.go index d6b676c9c8..e1e111a74c 100644 --- a/server/public/model/example_channel_test.go +++ b/server/public/model/example_channel_test.go @@ -145,10 +145,10 @@ func ExampleClient4_PatchChannel() { channelId := "channel_id" patch := &model.ChannelPatch{ - Name: model.NewString("new_name"), - DisplayName: model.NewString("New Display Name"), - Header: model.NewString("New header"), - Purpose: model.NewString("New purpose"), + Name: model.NewPointer("new_name"), + DisplayName: model.NewPointer("New Display Name"), + Header: model.NewPointer("New header"), + Purpose: model.NewPointer("New purpose"), } _, _, err := client.PatchChannel(context.Background(), channelId, patch) diff --git a/server/public/model/file_info.go b/server/public/model/file_info.go index b906e5a535..38c764d13d 100644 --- a/server/public/model/file_info.go +++ b/server/public/model/file_info.go @@ -88,7 +88,7 @@ func (fi *FileInfo) PreSave() { } if fi.RemoteId == nil { - fi.RemoteId = NewString("") + fi.RemoteId = NewPointer("") } } diff --git a/server/public/model/group_test.go b/server/public/model/group_test.go index cde022cef3..32f863c0b3 100644 --- a/server/public/model/group_test.go +++ b/server/public/model/group_test.go @@ -20,15 +20,15 @@ func TestGroupAuditable(t *testing.T) { now := GetMillis() g := Group{ Id: id, - Name: NewString("some name"), + Name: NewPointer("some name"), DisplayName: "some display name", Source: GroupSourceLdap, - RemoteId: NewString("some_remote"), + RemoteId: NewPointer("some_remote"), CreateAt: now, UpdateAt: now, DeleteAt: now, HasSyncables: true, - MemberCount: NewInt(10), + MemberCount: NewPointer(10), AllowReference: true, } m := g.Auditable() @@ -65,15 +65,15 @@ func TestGroupLogClone(t *testing.T) { now := GetMillis() g := Group{ Id: id, - Name: NewString("some name"), + Name: NewPointer("some name"), DisplayName: "some display name", Source: GroupSourceLdap, - RemoteId: NewString("some_remote"), + RemoteId: NewPointer("some_remote"), CreateAt: now, UpdateAt: now, DeleteAt: now, HasSyncables: true, - MemberCount: NewInt(10), + MemberCount: NewPointer(10), AllowReference: true, } l := g.LogClone() diff --git a/server/public/model/integrity.go b/server/public/model/integrity.go index 077d4ad836..7cc3d4e588 100644 --- a/server/public/model/integrity.go +++ b/server/public/model/integrity.go @@ -42,10 +42,10 @@ func (r *IntegrityCheckResult) UnmarshalJSON(b []byte) error { var record OrphanedRecord m := recData.(map[string]any) if val := m["parent_id"]; val != nil { - record.ParentId = NewString(val.(string)) + record.ParentId = NewPointer(val.(string)) } if val := m["child_id"]; val != nil { - record.ChildId = NewString(val.(string)) + record.ChildId = NewPointer(val.(string)) } rdata.Records = append(rdata.Records, record) } diff --git a/server/public/model/license.go b/server/public/model/license.go index 13f575b21f..bc2615371d 100644 --- a/server/public/model/license.go +++ b/server/public/model/license.go @@ -189,127 +189,127 @@ func (f *Features) ToMap() map[string]any { func (f *Features) SetDefaults() { if f.FutureFeatures == nil { - f.FutureFeatures = NewBool(true) + f.FutureFeatures = NewPointer(true) } if f.Users == nil { - f.Users = NewInt(0) + f.Users = NewPointer(0) } if f.LDAP == nil { - f.LDAP = NewBool(*f.FutureFeatures) + f.LDAP = NewPointer(*f.FutureFeatures) } if f.LDAPGroups == nil { - f.LDAPGroups = NewBool(*f.FutureFeatures) + f.LDAPGroups = NewPointer(*f.FutureFeatures) } if f.MFA == nil { - f.MFA = NewBool(*f.FutureFeatures) + f.MFA = NewPointer(*f.FutureFeatures) } if f.GoogleOAuth == nil { - f.GoogleOAuth = NewBool(*f.FutureFeatures) + f.GoogleOAuth = NewPointer(*f.FutureFeatures) } if f.Office365OAuth == nil { - f.Office365OAuth = NewBool(*f.FutureFeatures) + f.Office365OAuth = NewPointer(*f.FutureFeatures) } if f.OpenId == nil { - f.OpenId = NewBool(*f.FutureFeatures) + f.OpenId = NewPointer(*f.FutureFeatures) } if f.Compliance == nil { - f.Compliance = NewBool(*f.FutureFeatures) + f.Compliance = NewPointer(*f.FutureFeatures) } if f.Cluster == nil { - f.Cluster = NewBool(*f.FutureFeatures) + f.Cluster = NewPointer(*f.FutureFeatures) } if f.Metrics == nil { - f.Metrics = NewBool(*f.FutureFeatures) + f.Metrics = NewPointer(*f.FutureFeatures) } if f.MHPNS == nil { - f.MHPNS = NewBool(*f.FutureFeatures) + f.MHPNS = NewPointer(*f.FutureFeatures) } if f.SAML == nil { - f.SAML = NewBool(*f.FutureFeatures) + f.SAML = NewPointer(*f.FutureFeatures) } if f.Elasticsearch == nil { - f.Elasticsearch = NewBool(*f.FutureFeatures) + f.Elasticsearch = NewPointer(*f.FutureFeatures) } if f.Announcement == nil { - f.Announcement = NewBool(true) + f.Announcement = NewPointer(true) } if f.ThemeManagement == nil { - f.ThemeManagement = NewBool(true) + f.ThemeManagement = NewPointer(true) } if f.EmailNotificationContents == nil { - f.EmailNotificationContents = NewBool(*f.FutureFeatures) + f.EmailNotificationContents = NewPointer(*f.FutureFeatures) } if f.DataRetention == nil { - f.DataRetention = NewBool(*f.FutureFeatures) + f.DataRetention = NewPointer(*f.FutureFeatures) } if f.MessageExport == nil { - f.MessageExport = NewBool(*f.FutureFeatures) + f.MessageExport = NewPointer(*f.FutureFeatures) } if f.CustomPermissionsSchemes == nil { - f.CustomPermissionsSchemes = NewBool(*f.FutureFeatures) + f.CustomPermissionsSchemes = NewPointer(*f.FutureFeatures) } if f.GuestAccounts == nil { - f.GuestAccounts = NewBool(*f.FutureFeatures) + f.GuestAccounts = NewPointer(*f.FutureFeatures) } if f.GuestAccountsPermissions == nil { - f.GuestAccountsPermissions = NewBool(*f.FutureFeatures) + f.GuestAccountsPermissions = NewPointer(*f.FutureFeatures) } if f.CustomTermsOfService == nil { - f.CustomTermsOfService = NewBool(*f.FutureFeatures) + f.CustomTermsOfService = NewPointer(*f.FutureFeatures) } if f.IDLoadedPushNotifications == nil { - f.IDLoadedPushNotifications = NewBool(*f.FutureFeatures) + f.IDLoadedPushNotifications = NewPointer(*f.FutureFeatures) } if f.LockTeammateNameDisplay == nil { - f.LockTeammateNameDisplay = NewBool(*f.FutureFeatures) + f.LockTeammateNameDisplay = NewPointer(*f.FutureFeatures) } if f.EnterprisePlugins == nil { - f.EnterprisePlugins = NewBool(*f.FutureFeatures) + f.EnterprisePlugins = NewPointer(*f.FutureFeatures) } if f.AdvancedLogging == nil { - f.AdvancedLogging = NewBool(*f.FutureFeatures) + f.AdvancedLogging = NewPointer(*f.FutureFeatures) } if f.Cloud == nil { - f.Cloud = NewBool(false) + f.Cloud = NewPointer(false) } if f.SharedChannels == nil { - f.SharedChannels = NewBool(*f.FutureFeatures) + f.SharedChannels = NewPointer(*f.FutureFeatures) } if f.RemoteClusterService == nil { - f.RemoteClusterService = NewBool(*f.FutureFeatures) + f.RemoteClusterService = NewPointer(*f.FutureFeatures) } if f.OutgoingOAuthConnections == nil { - f.OutgoingOAuthConnections = NewBool(*f.FutureFeatures) + f.OutgoingOAuthConnections = NewPointer(*f.FutureFeatures) } } diff --git a/server/public/model/license_test.go b/server/public/model/license_test.go index 5d50c20c1b..900639e744 100644 --- a/server/public/model/license_test.go +++ b/server/public/model/license_test.go @@ -447,7 +447,7 @@ func TestLicenseHasSharedChannels(t *testing.T) { "licensed for shared channels", License{ Features: &Features{ - SharedChannels: NewBool(true), + SharedChannels: NewPointer(true), }, SkuShortName: "other", }, diff --git a/server/public/model/outgoing_oauth_connection_test.go b/server/public/model/outgoing_oauth_connection_test.go index cda8da0741..31229340d9 100644 --- a/server/public/model/outgoing_oauth_connection_test.go +++ b/server/public/model/outgoing_oauth_connection_test.go @@ -18,8 +18,8 @@ func newValidOutgoingOAuthConnection() *OutgoingOAuthConnection { Name: "Test Connection", ClientId: NewId(), ClientSecret: NewId(), - CredentialsUsername: NewString(NewId()), - CredentialsPassword: NewString(NewId()), + CredentialsUsername: NewPointer(NewId()), + CredentialsPassword: NewPointer(NewId()), OAuthTokenURL: "https://nowhere.com/oauth/token", GrantType: OutgoingOAuthConnectionGrantTypeClientCredentials, CreateAt: GetMillis(), diff --git a/server/public/model/post.go b/server/public/model/post.go index 21f4eb8308..75ecb9562b 100644 --- a/server/public/model/post.go +++ b/server/public/model/post.go @@ -310,7 +310,7 @@ func (o *Post) ShallowCopy(dst *Post) error { dst.LastReplyAt = o.LastReplyAt dst.Metadata = o.Metadata if o.IsFollowing != nil { - dst.IsFollowing = NewBool(*o.IsFollowing) + dst.IsFollowing = NewPointer(*o.IsFollowing) } dst.RemoteId = o.RemoteId return nil @@ -507,7 +507,7 @@ func (o *Post) SanitizeProps() { // Remove any input data from the post object that is not user controlled func (o *Post) SanitizeInput() { o.DeleteAt = 0 - o.RemoteId = NewString("") + o.RemoteId = NewPointer("") } func (o *Post) ContainsIntegrationsReservedProps() []string { diff --git a/server/public/model/reaction.go b/server/public/model/reaction.go index 0c3ba0380b..5acf763580 100644 --- a/server/public/model/reaction.go +++ b/server/public/model/reaction.go @@ -53,7 +53,7 @@ func (o *Reaction) PreSave() { o.DeleteAt = 0 if o.RemoteId == nil { - o.RemoteId = NewString("") + o.RemoteId = NewPointer("") } } @@ -61,7 +61,7 @@ func (o *Reaction) PreUpdate() { o.UpdateAt = GetMillis() if o.RemoteId == nil { - o.RemoteId = NewString("") + o.RemoteId = NewPointer("") } } diff --git a/server/public/model/role_test.go b/server/public/model/role_test.go index d6142841dc..be941721c9 100644 --- a/server/public/model/role_test.go +++ b/server/public/model/role_test.go @@ -94,7 +94,7 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(true)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(true)}, }, }, "members", @@ -106,7 +106,7 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Guests: NewBool(true)}, + Roles: &ChannelModeratedRolesPatch{Guests: NewPointer(true)}, }, }, "members", @@ -118,7 +118,7 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(true)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(true)}, }, }, "guests", @@ -130,15 +130,15 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(false)}, }, { Name: &manageMembers, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(false)}, }, { Name: &channelMentions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(false)}, }, }, "members", @@ -150,15 +150,15 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Guests: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Guests: NewPointer(false)}, }, { Name: &manageMembers, - Roles: &ChannelModeratedRolesPatch{Guests: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Guests: NewPointer(false)}, }, { Name: &channelMentions, - Roles: &ChannelModeratedRolesPatch{Guests: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Guests: NewPointer(false)}, }, }, "guests", @@ -170,19 +170,19 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(false)}, }, { Name: &manageMembers, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(false)}, }, { Name: &channelMentions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(true)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(true)}, }, { Name: &createPosts, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(true)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(true)}, }, }, "members", @@ -194,7 +194,7 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(true)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(true)}, }, }, "members", @@ -206,11 +206,11 @@ func TestRolePatchFromChannelModerationsPatch(t *testing.T) { []*ChannelModerationPatch{ { Name: &createReactions, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(false)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(false)}, }, { Name: &createPosts, - Roles: &ChannelModeratedRolesPatch{Members: NewBool(true)}, + Roles: &ChannelModeratedRolesPatch{Members: NewPointer(true)}, }, }, "members", diff --git a/server/public/model/user.go b/server/public/model/user.go index 5556b211a5..a461c32246 100644 --- a/server/public/model/user.go +++ b/server/public/model/user.go @@ -328,7 +328,7 @@ func (u UserSlice) FilterWithoutID(ids []string) UserSlice { func (u *User) DeepCopy() *User { copyUser := *u if u.AuthData != nil { - copyUser.AuthData = NewString(*u.AuthData) + copyUser.AuthData = NewPointer(*u.AuthData) } if u.Props != nil { copyUser.Props = CopyStringMap(u.Props) @@ -658,7 +658,7 @@ func (u *User) Etag(showFullName, showEmail bool) string { // Remove any private data from the user object func (u *User) Sanitize(options map[string]bool) { u.Password = "" - u.AuthData = NewString("") + u.AuthData = NewPointer("") u.MfaSecret = "" u.LastLogin = 0 @@ -681,11 +681,11 @@ func (u *User) Sanitize(options map[string]bool) { // Remove any input data from the user object that is not user controlled func (u *User) SanitizeInput(isAdmin bool) { if !isAdmin { - u.AuthData = NewString("") + u.AuthData = NewPointer("") u.AuthService = "" u.EmailVerified = false } - u.RemoteId = NewString("") + u.RemoteId = NewPointer("") u.CreateAt = 0 u.UpdateAt = 0 u.DeleteAt = 0 @@ -700,7 +700,7 @@ func (u *User) SanitizeInput(isAdmin bool) { func (u *User) ClearNonProfileFields(asAdmin bool) { u.Password = "" - u.AuthData = NewString("") + u.AuthData = NewPointer("") u.MfaSecret = "" u.EmailVerified = false u.AllowMarketing = false diff --git a/server/public/model/user_test.go b/server/public/model/user_test.go index 1c8340b6c3..5310eecbc6 100644 --- a/server/public/model/user_test.go +++ b/server/public/model/user_test.go @@ -35,7 +35,7 @@ func TestUserAuditable(t *testing.T) { DeleteAt: now, Username: "some user_name", Password: "some password", - AuthData: NewString("some_auth_data"), + AuthData: NewPointer("some_auth_data"), AuthService: UserAuthServiceLdap, Email: "test@example.org", EmailVerified: true, @@ -51,7 +51,7 @@ func TestUserAuditable(t *testing.T) { Locale: DefaultLocale, Timezone: timezones.DefaultUserTimezone(), MfaActive: true, - RemoteId: NewString("some_remote"), + RemoteId: NewPointer("some_remote"), } m := u.Auditable() @@ -115,7 +115,7 @@ func TestUserLogClone(t *testing.T) { DeleteAt: now, Username: "some user_name", Password: "some password", - AuthData: NewString("some_auth_data"), + AuthData: NewPointer("some_auth_data"), AuthService: UserAuthServiceLdap, Email: "test@example.org", EmailVerified: true, @@ -131,7 +131,7 @@ func TestUserLogClone(t *testing.T) { Locale: DefaultLocale, Timezone: timezones.DefaultUserTimezone(), MfaActive: true, - RemoteId: NewString("some_remote"), + RemoteId: NewPointer("some_remote"), } l := u.LogClone() @@ -173,7 +173,7 @@ func TestUserDeepCopy(t *testing.T) { mapKey := "key" mapValue := "key" - user := &User{Id: id, AuthData: NewString(authData), Props: map[string]string{}, NotifyProps: map[string]string{}, Timezone: map[string]string{}} + user := &User{Id: id, AuthData: NewPointer(authData), Props: map[string]string{}, NotifyProps: map[string]string{}, Timezone: map[string]string{}} user.Props[mapKey] = mapValue user.NotifyProps[mapKey] = mapValue user.Timezone[mapKey] = mapValue @@ -281,7 +281,7 @@ func TestUserIsValid(t *testing.T) { appErr = user.IsValid() require.True(t, HasExpectedUserIsValidError(appErr, "email", user.Id, user.Email), "expected user is valid error: %s", appErr.Error()) - user.RemoteId = NewString(NewId()) + user.RemoteId = NewPointer(NewId()) require.Nil(t, user.IsValid()) user.FirstName = strings.Repeat("a", 65) @@ -324,10 +324,10 @@ func TestUserSanitizeInput(t *testing.T) { user.Nickname = "nickname" user.FirstName = "firstname" user.LastName = "lastname" - user.RemoteId = NewString(NewId()) + user.RemoteId = NewPointer(NewId()) user.Position = "position" user.Roles = "system_admin" - user.AuthData = NewString("authdata") + user.AuthData = NewPointer("authdata") user.AuthService = "saml" user.EmailVerified = true user.FailedAttempts = 10 @@ -336,10 +336,10 @@ func TestUserSanitizeInput(t *testing.T) { user.SanitizeInput(false) // these fields should be reset - require.Equal(t, NewString(""), user.AuthData) + require.Equal(t, NewPointer(""), user.AuthData) require.Equal(t, "", user.AuthService) require.False(t, user.EmailVerified) - require.Equal(t, NewString(""), user.RemoteId) + require.Equal(t, NewPointer(""), user.RemoteId) require.Equal(t, int64(0), user.CreateAt) require.Equal(t, int64(0), user.UpdateAt) require.Equal(t, int64(0), user.DeleteAt) diff --git a/server/public/pluginapi/store_test.go b/server/public/pluginapi/store_test.go index 6e7ea70b9d..f76ad24c9a 100644 --- a/server/public/pluginapi/store_test.go +++ b/server/public/pluginapi/store_test.go @@ -37,9 +37,9 @@ func TestStore(t *testing.T) { t.Run("master db fallback", func(t *testing.T) { config := &model.Config{ SqlSettings: model.SqlSettings{ - DriverName: model.NewString("ramsql"), - DataSource: model.NewString("TestStore-master-db"), - ConnMaxLifetimeMilliseconds: model.NewInt(2), + DriverName: model.NewPointer("ramsql"), + DataSource: model.NewPointer("TestStore-master-db"), + ConnMaxLifetimeMilliseconds: model.NewPointer(2), }, } @@ -69,10 +69,10 @@ func TestStore(t *testing.T) { t.Run("replica db singleton", func(t *testing.T) { config := &model.Config{ SqlSettings: model.SqlSettings{ - DriverName: model.NewString("ramsql"), - DataSource: model.NewString("TestStore-master-db"), + DriverName: model.NewPointer("ramsql"), + DataSource: model.NewPointer("TestStore-master-db"), DataSourceReplicas: []string{"TestStore-master-db"}, - ConnMaxLifetimeMilliseconds: model.NewInt(2), + ConnMaxLifetimeMilliseconds: model.NewPointer(2), }, } diff --git a/server/public/utils/json_test.go b/server/public/utils/json_test.go index b00c5dfb0d..815f19fe54 100644 --- a/server/public/utils/json_test.go +++ b/server/public/utils/json_test.go @@ -322,27 +322,27 @@ func TestStringPtrToJSON(t *testing.T) { }, { "Zero length string", - model.NewString(""), + model.NewPointer(""), []byte("{}"), }, { "JSON map", - model.NewString("{\"foo\":7}"), + model.NewPointer("{\"foo\":7}"), []byte("{\"foo\":7}"), }, { "JSON array", - model.NewString("[1,2,3]"), + model.NewPointer("[1,2,3]"), []byte("[1,2,3]"), }, { "JSON string", - model.NewString("\"hello\""), + model.NewPointer("\"hello\""), []byte("\"hello\""), }, { "bare string", - model.NewString("hello"), + model.NewPointer("hello"), []byte("\"hello\""), }, }