From 04b27ce93c020d74aedfebe6fffc7ec4a1b285ef Mon Sep 17 00:00:00 2001 From: Claudio Costa Date: Tue, 17 Aug 2021 11:18:33 +0200 Subject: [PATCH] [MM-28985] Remove pointers to slice (part 1) (#18034) * Remove pointers to slice (part 1) * Remove use of pointers to slice from model package (#18045) * Fix after merge --- api4/channel.go | 4 +- api4/channel_category.go | 4 +- api4/channel_test.go | 88 ++--- api4/post_test.go | 10 +- api4/preference_test.go | 64 ++-- app/app_iface.go | 38 +-- app/channel.go | 74 ++-- app/channel_test.go | 42 +-- app/email/email_batching.go | 2 +- app/email/email_batching_test.go | 6 +- app/export_test.go | 2 +- app/import_functions.go | 16 +- app/import_functions_test.go | 6 +- app/oauth.go | 2 +- app/opentracing/opentracing_layer.go | 38 +-- app/plugin_api.go | 10 +- app/post.go | 2 +- app/preference.go | 6 +- app/product_notices.go | 2 +- app/slashcommands/command_expand_collapse.go | 2 +- app/slashcommands/command_leave.go | 4 +- app/status.go | 4 +- app/syncables_test.go | 4 +- app/team.go | 9 +- app/team_test.go | 12 +- app/user.go | 8 +- app/user_test.go | 22 +- manualtesting/manual_testing.go | 4 +- model/channel.go | 4 +- model/client4.go | 40 +-- model/custom_status.go | 29 +- plugin/api.go | 4 +- plugin/api_timer_layer_generated.go | 4 +- plugin/client_rpc_generated.go | 12 +- plugin/plugintest/api.go | 16 +- services/searchengine/bleveengine/search.go | 8 +- services/searchengine/interface.go | 4 +- .../mocks/SearchEngineInterface.go | 14 +- store/opentracinglayer/opentracinglayer.go | 50 +-- store/retrylayer/retrylayer.go | 50 +-- store/searchlayer/channel_layer.go | 8 +- store/searchlayer/user_layer.go | 2 +- store/searchtest/helper.go | 6 +- store/sqlstore/channel_store.go | 102 +++--- store/sqlstore/channel_store_categories.go | 8 +- store/sqlstore/integrity_test.go | 6 +- store/sqlstore/preference_store.go | 4 +- store/sqlstore/preference_store_test.go | 2 +- store/sqlstore/product_notices_store.go | 4 +- store/sqlstore/upgrade.go | 2 +- store/sqlstore/upgrade_test.go | 2 +- store/store.go | 50 +-- store/storetest/channel_store.go | 320 +++++++++--------- store/storetest/channel_store_categories.go | 12 +- store/storetest/compliance_store.go | 2 +- store/storetest/group_store.go | 4 +- store/storetest/mocks/ChannelStore.go | 176 +++++----- store/storetest/mocks/PreferenceStore.go | 4 +- store/storetest/mocks/ProductNoticesStore.go | 4 +- store/storetest/oauth_store.go | 4 +- store/storetest/post_store.go | 24 +- store/storetest/preference_store.go | 20 +- store/storetest/product_notices_store.go | 2 +- store/timerlayer/timerlayer.go | 50 +-- 64 files changed, 767 insertions(+), 771 deletions(-) diff --git a/api4/channel.go b/api4/channel.go index 5aa72633ea8..deeee292dd1 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -957,7 +957,7 @@ func searchChannelsForTeam(c *Context, w http.ResponseWriter, r *http.Request) { return } - var channels *model.ChannelList + var channels model.ChannelList var appErr *model.AppError if c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), c.Params.TeamId, model.PermissionListTeamChannels) { channels, appErr = c.App.SearchChannels(c.Params.TeamId, props.Term) @@ -996,7 +996,7 @@ func searchArchivedChannelsForTeam(c *Context, w http.ResponseWriter, r *http.Re return } - var channels *model.ChannelList + var channels model.ChannelList var appErr *model.AppError if c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), c.Params.TeamId, model.PermissionListTeamChannels) { channels, appErr = c.App.SearchArchivedChannels(c.Params.TeamId, props.Term, c.AppContext.Session().UserId) diff --git a/api4/channel_category.go b/api4/channel_category.go index 9313fffc663..c61f64006c3 100644 --- a/api4/channel_category.go +++ b/api4/channel_category.go @@ -208,12 +208,12 @@ func validateSidebarCategories(c *Context, teamId, userId string, categories []* return nil } -func validateSidebarCategoryChannels(userId string, channelIds []string, channels *model.ChannelList) []string { +func validateSidebarCategoryChannels(userId string, channelIds []string, channels model.ChannelList) []string { var filtered []string for _, channelId := range channelIds { found := false - for _, channel := range *channels { + for _, channel := range channels { if channel.Id == channelId { found = true break diff --git a/api4/channel_test.go b/api4/channel_test.go index dcea6af7e0b..4be43f519e4 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -543,7 +543,7 @@ func TestCreateGroupChannel(t *testing.T) { require.Equal(t, model.ChannelTypeGroup, rgc.Type, "should have created a channel of group type") m, _ := th.App.GetChannelMembersPage(rgc.Id, 0, 10) - require.Len(t, *m, 3, "should have 3 channel members") + require.Len(t, m, 3, "should have 3 channel members") // saving duplicate group channel rgc2, _, err := client.CreateGroupChannel([]string{user3.Id, user2.Id}) @@ -1044,48 +1044,48 @@ func TestGetAllChannels(t *testing.T) { require.NoError(t, err) // At least, all the not-deleted channels created during the InitBasic - require.True(t, len(*channels) >= 3) - for _, c := range *channels { + require.True(t, len(channels) >= 3) + for _, c := range channels { require.NotEqual(t, c.TeamId, "") } channels, _, err = client.GetAllChannels(0, 10, "") require.NoError(t, err) - require.True(t, len(*channels) >= 3) + require.True(t, len(channels) >= 3) channels, _, err = client.GetAllChannels(1, 1, "") require.NoError(t, err) - require.Len(t, *channels, 1) + require.Len(t, channels, 1) channels, _, err = client.GetAllChannels(10000, 10000, "") require.NoError(t, err) - require.Empty(t, *channels) + require.Empty(t, channels) channels, _, err = client.GetAllChannels(0, 10000, "") require.NoError(t, err) - beforeCount := len(*channels) + beforeCount := len(channels) - firstChannel := (*channels)[0].Channel + firstChannel := channels[0].Channel _, err = client.DeleteChannel(firstChannel.Id) require.NoError(t, err) channels, _, err = client.GetAllChannels(0, 10000, "") var ids []string - for _, item := range *channels { + for _, item := range channels { ids = append(ids, item.Channel.Id) } require.NoError(t, err) - require.Len(t, *channels, beforeCount-1) + require.Len(t, channels, beforeCount-1) require.NotContains(t, ids, firstChannel.Id) channels, _, err = client.GetAllChannelsIncludeDeleted(0, 10000, "") ids = []string{} - for _, item := range *channels { + for _, item := range channels { ids = append(ids, item.Channel.Id) } require.NoError(t, err) - require.True(t, len(*channels) > beforeCount) + require.True(t, len(channels) > beforeCount) require.Contains(t, ids, firstChannel.Id) }) @@ -1096,7 +1096,7 @@ func TestGetAllChannels(t *testing.T) { sysManagerChannels, resp, err := th.SystemManagerClient.GetAllChannels(0, 10000, "") require.NoError(t, err) CheckOKStatus(t, resp) - policyChannel := (*sysManagerChannels)[0] + policyChannel := (sysManagerChannels)[0] policy, err := th.App.Srv().Store.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", @@ -1115,7 +1115,7 @@ func TestGetAllChannels(t *testing.T) { require.NoError(t, err) CheckOKStatus(t, resp) found := false - for _, channel := range *channels { + for _, channel := range channels { if channel.Id == policyChannel.Id { found = true break @@ -1129,7 +1129,7 @@ func TestGetAllChannels(t *testing.T) { require.NoError(t, err) CheckOKStatus(t, resp) found := false - for _, channel := range *channels { + for _, channel := range channels { if channel.Id == policyChannel.Id { found = true require.Nil(t, channel.PolicyID) @@ -1144,7 +1144,7 @@ func TestGetAllChannels(t *testing.T) { require.NoError(t, err) CheckOKStatus(t, resp) found := false - for _, channel := range *channels { + for _, channel := range channels { if channel.Id == policyChannel.Id { found = true require.Equal(t, *channel.PolicyID, policy.ID) @@ -1164,23 +1164,23 @@ func TestGetAllChannelsWithCount(t *testing.T) { require.NoError(t, err) // At least, all the not-deleted channels created during the InitBasic - require.True(t, len(*channels) >= 3) - for _, c := range *channels { + require.True(t, len(channels) >= 3) + for _, c := range channels { require.NotEqual(t, c.TeamId, "") } require.Equal(t, int64(6), total) channels, _, _, err = th.SystemAdminClient.GetAllChannelsWithCount(0, 10, "") require.NoError(t, err) - require.True(t, len(*channels) >= 3) + require.True(t, len(channels) >= 3) channels, _, _, err = th.SystemAdminClient.GetAllChannelsWithCount(1, 1, "") require.NoError(t, err) - require.Len(t, *channels, 1) + require.Len(t, channels, 1) channels, _, _, err = th.SystemAdminClient.GetAllChannelsWithCount(10000, 10000, "") require.NoError(t, err) - require.Empty(t, *channels) + require.Empty(t, channels) _, _, resp, err := client.GetAllChannelsWithCount(0, 20, "") require.Error(t, err) @@ -1505,12 +1505,12 @@ func TestSearchAllChannels(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.Description, func(t *testing.T) { - var channels *model.ChannelListWithTeamData + var channels model.ChannelListWithTeamData channels, _, err = th.SystemAdminClient.SearchAllChannels(testCase.Search) require.NoError(t, err) - assert.Equal(t, len(testCase.ExpectedChannelIds), len(*channels)) + assert.Equal(t, len(testCase.ExpectedChannelIds), len(channels)) actualChannelIds := []string{} - for _, channelWithTeamData := range *channels { + for _, channelWithTeamData := range channels { actualChannelIds = append(actualChannelIds, channelWithTeamData.Channel.Id) } assert.ElementsMatch(t, testCase.ExpectedChannelIds, actualChannelIds) @@ -1520,7 +1520,7 @@ func TestSearchAllChannels(t *testing.T) { // Searching with no terms returns all default channels allChannels, _, err := th.SystemAdminClient.SearchAllChannels(&model.ChannelSearch{Term: ""}) require.NoError(t, err) - assert.True(t, len(*allChannels) >= 3) + assert.True(t, len(allChannels) >= 3) _, resp, err := client.SearchAllChannels(&model.ChannelSearch{Term: ""}) require.Error(t, err) @@ -1530,7 +1530,7 @@ func TestSearchAllChannels(t *testing.T) { sysManagerChannels, resp, err := th.SystemManagerClient.GetAllChannels(0, 10000, "") require.NoError(t, err) CheckOKStatus(t, resp) - policyChannel := (*sysManagerChannels)[0] + policyChannel := sysManagerChannels[0] policy, savePolicyErr := th.App.Srv().Store.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ RetentionPolicy: model.RetentionPolicy{ DisplayName: "Policy 1", @@ -1545,7 +1545,7 @@ func TestSearchAllChannels(t *testing.T) { require.NoError(t, err) CheckOKStatus(t, resp) found := false - for _, channel := range *channels { + for _, channel := range channels { if channel.Id == policyChannel.Id { found = true require.Nil(t, channel.PolicyID) @@ -1559,7 +1559,7 @@ func TestSearchAllChannels(t *testing.T) { require.NoError(t, err) CheckOKStatus(t, resp) found := false - for _, channel := range *channels { + for _, channel := range channels { if channel.Id == policyChannel.Id { found = true require.Equal(t, *channel.PolicyID, policy.ID) @@ -1581,7 +1581,7 @@ func TestSearchAllChannelsPaged(t *testing.T) { search.PerPage = model.NewInt(2) channelsWithCount, _, err := th.SystemAdminClient.SearchAllChannelsPaged(search) require.NoError(t, err) - require.Len(t, *channelsWithCount.Channels, 2) + require.Len(t, channelsWithCount.Channels, 2) search.Term = th.BasicChannel.Name _, resp, err := client.SearchAllChannels(search) @@ -2101,19 +2101,19 @@ func TestGetChannelMembers(t *testing.T) { th.TestForAllClients(t, func(t *testing.T, client *model.Client4) { members, _, err := client.GetChannelMembers(th.BasicChannel.Id, 0, 60, "") require.NoError(t, err) - require.Len(t, *members, 3, "should only be 3 users in channel") + require.Len(t, members, 3, "should only be 3 users in channel") members, _, err = client.GetChannelMembers(th.BasicChannel.Id, 0, 2, "") require.NoError(t, err) - require.Len(t, *members, 2, "should only be 2 users") + require.Len(t, members, 2, "should only be 2 users") members, _, err = client.GetChannelMembers(th.BasicChannel.Id, 1, 1, "") require.NoError(t, err) - require.Len(t, *members, 1, "should only be 1 user") + require.Len(t, members, 1, "should only be 1 user") members, _, err = client.GetChannelMembers(th.BasicChannel.Id, 1000, 100000, "") require.NoError(t, err) - require.Empty(t, *members, "should be 0 users") + require.Empty(t, members, "should be 0 users") _, resp, err := client.GetChannelMembers("junk", 0, 60, "") require.Error(t, err) @@ -2150,7 +2150,7 @@ func TestGetChannelMembersByIds(t *testing.T) { cm, _, err := client.GetChannelMembersByIds(th.BasicChannel.Id, []string{th.BasicUser.Id}) require.NoError(t, err) - require.Equal(t, th.BasicUser.Id, (*cm)[0].UserId, "returned wrong user") + require.Equal(t, th.BasicUser.Id, cm[0].UserId, "returned wrong user") _, resp, err := client.GetChannelMembersByIds(th.BasicChannel.Id, []string{}) require.Error(t, err) @@ -2158,15 +2158,15 @@ func TestGetChannelMembersByIds(t *testing.T) { cm1, _, err := client.GetChannelMembersByIds(th.BasicChannel.Id, []string{"junk"}) require.NoError(t, err) - require.Empty(t, *cm1, "no users should be returned") + require.Empty(t, cm1, "no users should be returned") cm1, _, err = client.GetChannelMembersByIds(th.BasicChannel.Id, []string{"junk", th.BasicUser.Id}) require.NoError(t, err) - require.Len(t, *cm1, 1, "1 member should be returned") + require.Len(t, cm1, 1, "1 member should be returned") cm1, _, err = client.GetChannelMembersByIds(th.BasicChannel.Id, []string{th.BasicUser2.Id, th.BasicUser.Id}) require.NoError(t, err) - require.Len(t, *cm1, 2, "2 members should be returned") + require.Len(t, cm1, 2, "2 members should be returned") _, resp, err = client.GetChannelMembersByIds("junk", []string{th.BasicUser.Id}) require.Error(t, err) @@ -2241,7 +2241,7 @@ func TestGetChannelMembersForUser(t *testing.T) { members, _, err := client.GetChannelMembersForUser(th.BasicUser.Id, th.BasicTeam.Id, "") require.NoError(t, err) - require.Len(t, *members, 6, "should have 6 members on team") + require.Len(t, members, 6, "should have 6 members on team") _, resp, err := client.GetChannelMembersForUser("", th.BasicTeam.Id, "") require.Error(t, err) @@ -3289,8 +3289,8 @@ func TestAutocompleteChannels(t *testing.T) { t.Run(tc.description, func(t *testing.T) { channels, _, err := th.Client.AutocompleteChannelsForTeam(tc.teamId, tc.fragment) require.NoError(t, err) - names := make([]string, len(*channels)) - for i, c := range *channels { + names := make([]string, len(channels)) + for i, c := range channels { names[i] = c.Name } for _, name := range tc.expectedIncludes { @@ -3404,8 +3404,8 @@ func TestAutocompleteChannelsForSearch(t *testing.T) { t.Run(tc.description, func(t *testing.T) { channels, _, err := th.Client.AutocompleteChannelsForTeamForSearch(tc.teamID, tc.fragment) require.NoError(t, err) - names := make([]string, len(*channels)) - for i, c := range *channels { + names := make([]string, len(channels)) + for i, c := range channels { names[i] = c.Name } for _, name := range tc.expectedIncludes { @@ -3536,8 +3536,8 @@ func TestAutocompleteChannelsForSearchGuestUsers(t *testing.T) { t.Run(tc.description, func(t *testing.T) { channels, _, err := th.Client.AutocompleteChannelsForTeamForSearch(tc.teamID, tc.fragment) require.NoError(t, err) - names := make([]string, len(*channels)) - for i, c := range *channels { + names := make([]string, len(channels)) + for i, c := range channels { names[i] = c.Name } for _, name := range tc.expectedIncludes { diff --git a/api4/post_test.go b/api4/post_test.go index 47b7d63c0f2..702ffcbfc45 100644 --- a/api4/post_test.go +++ b/api4/post_test.go @@ -1228,10 +1228,10 @@ func TestGetFlaggedPostsForUser(t *testing.T) { Name: post1.Id, Value: "true", } - _, err := client.UpdatePreferences(user.Id, &model.Preferences{preference}) + _, err := client.UpdatePreferences(user.Id, model.Preferences{preference}) require.NoError(t, err) preference.Name = post2.Id - _, err = client.UpdatePreferences(user.Id, &model.Preferences{preference}) + _, err = client.UpdatePreferences(user.Id, model.Preferences{preference}) require.NoError(t, err) opl := model.NewPostList() @@ -1292,7 +1292,7 @@ func TestGetFlaggedPostsForUser(t *testing.T) { post4 := th.CreatePostWithClient(client, channel3) preference.Name = post4.Id - client.UpdatePreferences(user.Id, &model.Preferences{preference}) + client.UpdatePreferences(user.Id, model.Preferences{preference}) opl.AddPost(post4) opl.AddOrder(post4.Id) @@ -1318,7 +1318,7 @@ func TestGetFlaggedPostsForUser(t *testing.T) { post5 := th.CreatePostWithClient(th.SystemAdminClient, channel4) preference.Name = post5.Id - resp, err := client.UpdatePreferences(user.Id, &model.Preferences{preference}) + resp, err := client.UpdatePreferences(user.Id, model.Preferences{preference}) require.Error(t, err) CheckForbiddenStatus(t, resp) @@ -1328,7 +1328,7 @@ func TestGetFlaggedPostsForUser(t *testing.T) { require.Equal(t, opl.Posts, rpl.Posts, "posts should have matched") th.AddUserToChannel(user, channel4) - _, err = client.UpdatePreferences(user.Id, &model.Preferences{preference}) + _, err = client.UpdatePreferences(user.Id, model.Preferences{preference}) require.NoError(t, err) rpl, _, err = client.GetFlaggedPostsForUser(user.Id, 0, 10) diff --git a/api4/preference_test.go b/api4/preference_test.go index c0c2e57da84..cd5b17d385a 100644 --- a/api4/preference_test.go +++ b/api4/preference_test.go @@ -44,7 +44,7 @@ func TestGetPreferences(t *testing.T) { }, } - client.UpdatePreferences(user1.Id, &preferences1) + client.UpdatePreferences(user1.Id, preferences1) prefs, _, err := client.GetPreferences(user1.Id) require.NoError(t, err) @@ -102,7 +102,7 @@ func TestGetPreferencesByCategory(t *testing.T) { }, } - client.UpdatePreferences(user1.Id, &preferences1) + client.UpdatePreferences(user1.Id, preferences1) prefs, _, err := client.GetPreferencesByCategory(user1.Id, category) require.NoError(t, err) @@ -160,7 +160,7 @@ func TestGetPreferenceByCategoryAndName(t *testing.T) { }, } - client.UpdatePreferences(user.Id, &preferences) + client.UpdatePreferences(user.Id, preferences) pref, _, err := client.GetPreferenceByCategoryAndName(user.Id, model.PreferenceCategoryDirectChannelShow, name) require.NoError(t, err) @@ -170,7 +170,7 @@ func TestGetPreferenceByCategoryAndName(t *testing.T) { require.Equal(t, preferences[0].Name, pref.Name, "Name preference not saved") preferences[0].Value = model.NewId() - client.UpdatePreferences(user.Id, &preferences) + client.UpdatePreferences(user.Id, preferences) _, resp, err := client.GetPreferenceByCategoryAndName(user.Id, "junk", preferences[0].Name) require.Error(t, err) @@ -221,7 +221,7 @@ func TestUpdatePreferences(t *testing.T) { }, } - _, err := client.UpdatePreferences(user1.Id, &preferences1) + _, err := client.UpdatePreferences(user1.Id, preferences1) require.NoError(t, err) preferences := model.Preferences{ @@ -232,7 +232,7 @@ func TestUpdatePreferences(t *testing.T) { }, } - resp, err := client.UpdatePreferences(user1.Id, &preferences) + resp, err := client.UpdatePreferences(user1.Id, preferences) require.Error(t, err) CheckForbiddenStatus(t, resp) @@ -243,16 +243,16 @@ func TestUpdatePreferences(t *testing.T) { }, } - resp, err = client.UpdatePreferences(user1.Id, &preferences) + resp, err = client.UpdatePreferences(user1.Id, preferences) require.Error(t, err) CheckBadRequestStatus(t, resp) - resp, err = client.UpdatePreferences(th.BasicUser2.Id, &preferences) + resp, err = client.UpdatePreferences(th.BasicUser2.Id, preferences) require.Error(t, err) CheckForbiddenStatus(t, resp) client.Logout() - resp, err = client.UpdatePreferences(user1.Id, &preferences1) + resp, err = client.UpdatePreferences(user1.Id, preferences1) require.Error(t, err) CheckUnauthorizedStatus(t, resp) } @@ -270,7 +270,7 @@ func TestUpdatePreferencesWebsocket(t *testing.T) { require.Equal(t, wsResp.Status, model.StatusOk, "expected OK from auth challenge") userId := th.BasicUser.Id - preferences := &model.Preferences{ + preferences := model.Preferences{ { UserId: userId, Category: model.NewId(), @@ -300,7 +300,7 @@ func TestUpdatePreferencesWebsocket(t *testing.T) { received, err := model.PreferencesFromJson(strings.NewReader(event.GetData()["preferences"].(string))) require.NoError(t, err) - for i, p := range *preferences { + for i, p := range preferences { require.Equal(t, received[i].UserId, p.UserId, "received incorrect UserId") require.Equal(t, received[i].Category, p.Category, "received incorrect Category") require.Equal(t, received[i].Name, p.Name, "received incorrect Name") @@ -338,7 +338,7 @@ func TestUpdateSidebarPreferences(t *testing.T) { require.Contains(t, categories.Categories[1].Channels, channel.Id) // Favorite the channel - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -357,7 +357,7 @@ func TestUpdateSidebarPreferences(t *testing.T) { assert.NotContains(t, categories.Categories[1].Channels, channel.Id) // And unfavorite the channel - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -391,7 +391,7 @@ func TestUpdateSidebarPreferences(t *testing.T) { dmChannel := th.CreateDmChannel(user2) // Favorite the channel - _, err := th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err := th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -417,7 +417,7 @@ func TestUpdateSidebarPreferences(t *testing.T) { assert.NotContains(t, categories.Categories[2].Channels, dmChannel.Id) // And unfavorite the channel - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -482,7 +482,7 @@ func TestUpdateSidebarPreferences(t *testing.T) { require.Contains(t, categories.Categories[1].Channels, channel.Id) // Favorite the channel - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -501,7 +501,7 @@ func TestUpdateSidebarPreferences(t *testing.T) { assert.Contains(t, categories.Categories[1].Channels, channel.Id) // Favorite the channel for the second user - _, err = client2.UpdatePreferences(user2.Id, &model.Preferences{ + _, err = client2.UpdatePreferences(user2.Id, model.Preferences{ { UserId: user2.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -520,7 +520,7 @@ func TestUpdateSidebarPreferences(t *testing.T) { assert.NotContains(t, categories.Categories[1].Channels, channel.Id) // And unfavorite the channel - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -561,21 +561,21 @@ func TestDeletePreferences(t *testing.T) { preferences = append(preferences, preference) } - client.UpdatePreferences(th.BasicUser.Id, &preferences) + client.UpdatePreferences(th.BasicUser.Id, preferences) // delete 10 preferences th.LoginBasic2() - resp, err := client.DeletePreferences(th.BasicUser2.Id, &preferences) + resp, err := client.DeletePreferences(th.BasicUser2.Id, preferences) require.Error(t, err) CheckForbiddenStatus(t, resp) th.LoginBasic() - _, err = client.DeletePreferences(th.BasicUser.Id, &preferences) + _, err = client.DeletePreferences(th.BasicUser.Id, preferences) require.NoError(t, err) - resp, err = client.DeletePreferences(th.BasicUser2.Id, &preferences) + resp, err = client.DeletePreferences(th.BasicUser2.Id, preferences) require.Error(t, err) CheckForbiddenStatus(t, resp) @@ -583,7 +583,7 @@ func TestDeletePreferences(t *testing.T) { require.Len(t, prefs, originalCount, "should've deleted preferences") client.Logout() - resp, err = client.DeletePreferences(th.BasicUser.Id, &preferences) + resp, err = client.DeletePreferences(th.BasicUser.Id, preferences) require.Error(t, err) CheckUnauthorizedStatus(t, resp) } @@ -593,7 +593,7 @@ func TestDeletePreferencesWebsocket(t *testing.T) { defer th.TearDown() userId := th.BasicUser.Id - preferences := &model.Preferences{ + preferences := model.Preferences{ { UserId: userId, Category: model.NewId(), @@ -632,7 +632,7 @@ func TestDeletePreferencesWebsocket(t *testing.T) { received, err := model.PreferencesFromJson(strings.NewReader(event.GetData()["preferences"].(string))) require.NoError(t, err) - for i, preference := range *preferences { + for i, preference := range preferences { require.Equal(t, preference.UserId, received[i].UserId) require.Equal(t, preference.Category, received[i].Category) require.Equal(t, preference.Name, received[i].Name) @@ -670,7 +670,7 @@ func TestDeleteSidebarPreferences(t *testing.T) { require.Contains(t, categories.Categories[1].Channels, channel.Id) // Favorite the channel - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -688,7 +688,7 @@ func TestDeleteSidebarPreferences(t *testing.T) { assert.NotContains(t, categories.Categories[1].Channels, channel.Id) // And unfavorite the channel by deleting the preference - _, err = th.Client.DeletePreferences(user.Id, &model.Preferences{ + _, err = th.Client.DeletePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -721,7 +721,7 @@ func TestDeleteSidebarPreferences(t *testing.T) { dmChannel := th.CreateDmChannel(user2) // Favorite the channel - _, err := th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err := th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -747,7 +747,7 @@ func TestDeleteSidebarPreferences(t *testing.T) { assert.NotContains(t, categories.Categories[2].Channels, dmChannel.Id) // And unfavorite the channel by deleting the preference - _, err = th.Client.DeletePreferences(user.Id, &model.Preferences{ + _, err = th.Client.DeletePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -811,7 +811,7 @@ func TestDeleteSidebarPreferences(t *testing.T) { require.Contains(t, categories.Categories[1].Channels, channel.Id) // Favorite the channel for both users - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -821,7 +821,7 @@ func TestDeleteSidebarPreferences(t *testing.T) { }) require.NoError(t, err) - _, err = client2.UpdatePreferences(user2.Id, &model.Preferences{ + _, err = client2.UpdatePreferences(user2.Id, model.Preferences{ { UserId: user2.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -840,7 +840,7 @@ func TestDeleteSidebarPreferences(t *testing.T) { assert.NotContains(t, categories.Categories[1].Channels, channel.Id) // And unfavorite the channel for the first user by deleting the preference - _, err = th.Client.UpdatePreferences(user.Id, &model.Preferences{ + _, err = th.Client.UpdatePreferences(user.Id, model.Preferences{ { UserId: user.Id, Category: model.PreferenceCategoryFavoriteChannel, diff --git a/app/app_iface.go b/app/app_iface.go index 364d989d77d..60a0f04a792 100644 --- a/app/app_iface.go +++ b/app/app_iface.go @@ -281,7 +281,7 @@ type AppIface interface { // SaveConfig replaces the active configuration, optionally notifying cluster peers. SaveConfig(newCfg *model.Config, sendConfigChangeClusterMessage bool) (*model.Config, *model.Config, *model.AppError) // SearchAllChannels returns a list of channels, the total count of the results of the search (if the paginate search option is true), and an error. - SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) + SearchAllChannels(term string, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, *model.AppError) // SearchAllTeams returns a team list and the total count of the results SearchAllTeams(searchOpts *model.TeamSearch) ([]*model.Team, int64, *model.AppError) // SendAdminUpgradeRequestEmail takes the username of user trying to alert admins and then applies rate limit of n (number of admins) emails per user per day @@ -410,8 +410,8 @@ type AppIface interface { AttachSessionCookies(c *request.Context, w http.ResponseWriter, r *http.Request) AuthenticateUserForLogin(c *request.Context, id, loginId, password, mfaToken, cwsToken string, ldapOnly bool) (user *model.User, err *model.AppError) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectURI string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError) - AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError) - AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) + AutocompleteChannels(teamID string, term string) (model.ChannelList, *model.AppError) + AutocompleteChannelsForSearch(teamID string, userID string, term string) (model.ChannelList, *model.AppError) AutocompleteUsersInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) AutocompleteUsersInTeam(teamID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError) BroadcastStatus(status *model.Status) @@ -543,14 +543,14 @@ type AppIface interface { FileModTime(path string) (time.Time, *model.AppError) FileSize(path string) (int64, *model.AppError) FillInChannelProps(channel *model.Channel) *model.AppError - FillInChannelsProps(channelList *model.ChannelList) *model.AppError + FillInChannelsProps(channelList model.ChannelList) *model.AppError FilterUsersByVisible(viewer *model.User, otherUsers []*model.User) ([]*model.User, *model.AppError) FindTeamByName(name string) bool GenerateMfaSecret(userID string) (*model.MfaSecret, *model.AppError) GeneratePublicLink(siteURL string, info *model.FileInfo) string GenerateSupportPacket() []model.FileData GetActivePluginManifests() ([]*model.Manifest, *model.AppError) - GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) + GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, *model.AppError) GetAllChannelsCount(opts model.ChannelSearchOpts) (int64, *model.AppError) GetAllPrivateTeams() ([]*model.Team, *model.AppError) GetAllPublicTeams() ([]*model.Team, *model.AppError) @@ -573,10 +573,10 @@ type AppIface interface { GetChannelGuestCount(channelID string) (int64, *model.AppError) GetChannelMember(ctx context.Context, channelID string, userID string) (*model.ChannelMember, *model.AppError) GetChannelMemberCount(channelID string) (int64, *model.AppError) - GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError) - GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError) + GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError) + GetChannelMembersForUser(teamID string, userID string) (model.ChannelMembers, *model.AppError) GetChannelMembersForUserWithPagination(teamID, userID string, page, perPage int) ([]*model.ChannelMember, *model.AppError) - GetChannelMembersPage(channelID string, page, perPage int) (*model.ChannelMembers, *model.AppError) + GetChannelMembersPage(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError) GetChannelMembersTimezones(channelID string) ([]string, *model.AppError) GetChannelPinnedPostCount(channelID string) (int64, *model.AppError) GetChannelPoliciesForUser(userID string, offset, limit int) (*model.RetentionPolicyForChannelList, *model.AppError) @@ -585,8 +585,8 @@ type AppIface interface { GetChannelsForRetentionPolicy(policyID string, offset, limit int) (*model.ChannelsWithCount, *model.AppError) GetChannelsForScheme(scheme *model.Scheme, offset int, limit int) (model.ChannelList, *model.AppError) GetChannelsForSchemePage(scheme *model.Scheme, page int, perPage int) (model.ChannelList, *model.AppError) - GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) - GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError) + GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, *model.AppError) + GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (model.ChannelList, *model.AppError) GetCloudSession(token string) (*model.Session, *model.AppError) GetClusterId() string GetClusterStatus() []*model.ClusterInfo @@ -597,7 +597,7 @@ type AppIface interface { GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError) GetCookieDomain() string GetDefaultProfileImage(user *model.User) ([]byte, *model.AppError) - GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError) + GetDeletedChannels(teamID string, offset int, limit int, userID string) (model.ChannelList, *model.AppError) GetEmoji(emojiId string) (*model.Emoji, *model.AppError) GetEmojiByName(emojiName string) (*model.Emoji, *model.AppError) GetEmojiImage(emojiId string) ([]byte, string, *model.AppError) @@ -690,10 +690,10 @@ type AppIface interface { GetPreferenceByCategoryForUser(userID string, category string) (model.Preferences, *model.AppError) GetPreferencesForUser(userID string) (model.Preferences, *model.AppError) GetPrevPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string - GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) + GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) GetProfileImage(user *model.User) ([]byte, bool, *model.AppError) - GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (*model.ChannelList, *model.AppError) - GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) + GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (model.ChannelList, *model.AppError) + GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) GetReactionsForPost(postID string) ([]*model.Reaction, *model.AppError) GetRecentlyActiveUsersForTeam(teamID string) (map[string]*model.User, *model.AppError) GetRecentlyActiveUsersForTeamPage(teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) @@ -947,14 +947,14 @@ type AppIface interface { SaveSharedChannelRemote(remote *model.SharedChannelRemote) (*model.SharedChannelRemote, error) SaveUserTermsOfService(userID, termsOfServiceId string, accepted bool) *model.AppError SchemesIterator(scope string, batchSize int) func() []*model.Scheme - SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError) - SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError) - SearchChannelsForUser(userID, teamID, term string) (*model.ChannelList, *model.AppError) - SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) + SearchArchivedChannels(teamID string, term string, userID string) (model.ChannelList, *model.AppError) + SearchChannels(teamID string, term string) (model.ChannelList, *model.AppError) + SearchChannelsForUser(userID, teamID, term string) (model.ChannelList, *model.AppError) + SearchChannelsUserNotIn(teamID string, userID string, term string) (model.ChannelList, *model.AppError) SearchEmoji(name string, prefixOnly bool, limit int) ([]*model.Emoji, *model.AppError) SearchEngine() *searchengine.Broker SearchFilesInTeamForUser(c *request.Context, terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.FileInfoList, *model.AppError) - SearchGroupChannels(userID, term string) (*model.ChannelList, *model.AppError) + SearchGroupChannels(userID, term string) (model.ChannelList, *model.AppError) SearchPostsInTeam(teamID string, paramsList []*model.SearchParams) (*model.PostList, *model.AppError) SearchPostsInTeamForUser(c *request.Context, terms string, userID string, teamID string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError) SearchPrivateTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError) diff --git a/app/channel.go b/app/channel.go index 310ef8c7c3e..cb3ae14b41c 100644 --- a/app/channel.go +++ b/app/channel.go @@ -1573,7 +1573,7 @@ func (a *App) AddDirectChannels(teamID string, user *model.User) *model.AppError } } - if err := a.Srv().Store.Preference().Save(&preferences); err != nil { + if err := a.Srv().Store.Preference().Save(preferences); err != nil { return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError) } @@ -1755,7 +1755,7 @@ func (a *App) GetChannelByNameForTeamName(channelName, teamName string, includeD return result, nil } -func (a *App) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) { +func (a *App) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, *model.AppError) { list, err := a.Srv().Store.Channel().GetChannels(teamID, userID, includeDeleted, lastDeleteAt) if err != nil { var nfErr *store.ErrNotFound @@ -1770,7 +1770,7 @@ func (a *App) GetChannelsForUser(teamID string, userID string, includeDeleted bo return list, nil } -func (a *App) GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) { +func (a *App) GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, *model.AppError) { if opts.ExcludeDefaultChannels { opts.ExcludeChannelNames = a.DefaultChannelNames() } @@ -1806,7 +1806,7 @@ func (a *App) GetAllChannelsCount(opts model.ChannelSearchOpts) (int64, *model.A return count, nil } -func (a *App) GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError) { +func (a *App) GetDeletedChannels(teamID string, offset int, limit int, userID string) (model.ChannelList, *model.AppError) { list, err := a.Srv().Store.Channel().GetDeleted(teamID, offset, limit, userID) if err != nil { var nfErr *store.ErrNotFound @@ -1821,7 +1821,7 @@ func (a *App) GetDeletedChannels(teamID string, offset int, limit int, userID st return list, nil } -func (a *App) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError) { +func (a *App) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (model.ChannelList, *model.AppError) { channels, err := a.Srv().Store.Channel().GetMoreChannels(teamID, userID, offset, limit) if err != nil { return nil, model.NewAppError("GetChannelsUserNotIn", "app.channel.get_more_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError) @@ -1829,7 +1829,7 @@ func (a *App) GetChannelsUserNotIn(teamID string, userID string, offset int, lim return channels, nil } -func (a *App) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (*model.ChannelList, *model.AppError) { +func (a *App) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (model.ChannelList, *model.AppError) { list, err := a.Srv().Store.Channel().GetPublicChannelsByIdsForTeam(teamID, channelIDs) if err != nil { var nfErr *store.ErrNotFound @@ -1844,7 +1844,7 @@ func (a *App) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) return list, nil } -func (a *App) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) { +func (a *App) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) { list, err := a.Srv().Store.Channel().GetPublicChannelsForTeam(teamID, offset, limit) if err != nil { return nil, model.NewAppError("GetPublicChannelsForTeam", "app.channel.get_public_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError) @@ -1853,7 +1853,7 @@ func (a *App) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*m return list, nil } -func (a *App) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) { +func (a *App) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) { list, err := a.Srv().Store.Channel().GetPrivateChannelsForTeam(teamID, offset, limit) if err != nil { return nil, model.NewAppError("GetPrivateChannelsForTeam", "app.channel.get_private_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError) @@ -1877,7 +1877,7 @@ func (a *App) GetChannelMember(ctx context.Context, channelID string, userID str return channelMember, nil } -func (a *App) GetChannelMembersPage(channelID string, page, perPage int) (*model.ChannelMembers, *model.AppError) { +func (a *App) GetChannelMembersPage(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError) { channelMembers, err := a.Srv().Store.Channel().GetMembers(channelID, page*perPage, perPage) if err != nil { return nil, model.NewAppError("GetChannelMembersPage", "app.channel.get_members.app_error", nil, err.Error(), http.StatusInternalServerError) @@ -1903,7 +1903,7 @@ func (a *App) GetChannelMembersTimezones(channelID string) ([]string, *model.App return model.RemoveDuplicateStrings(timezones), nil } -func (a *App) GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError) { +func (a *App) GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError) { members, err := a.Srv().Store.Channel().GetMembersByIds(channelID, userIDs) if err != nil { return nil, model.NewAppError("GetChannelMembersByIds", "app.channel.get_members_by_ids.app_error", nil, err.Error(), http.StatusInternalServerError) @@ -1912,7 +1912,7 @@ func (a *App) GetChannelMembersByIds(channelID string, userIDs []string) (*model return members, nil } -func (a *App) GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError) { +func (a *App) GetChannelMembersForUser(teamID string, userID string) (model.ChannelMembers, *model.AppError) { channelMembers, err := a.Srv().Store.Channel().GetMembersForUser(teamID, userID) if err != nil { return nil, model.NewAppError("GetChannelMembersForUser", "app.channel.get_members.app_error", nil, err.Error(), http.StatusInternalServerError) @@ -1928,11 +1928,9 @@ func (a *App) GetChannelMembersForUserWithPagination(teamID, userID string, page } members := make([]*model.ChannelMember, 0) - if m != nil { - for _, member := range *m { - member := member - members = append(members, &member) - } + for _, member := range m { + member := member + members = append(members, &member) } return members, nil } @@ -2322,7 +2320,7 @@ func (a *App) removeUserFromChannel(c *request.Context, userIDToRemove string, r if err != nil { return err } - if len(*currentMembers) == 0 { + if len(currentMembers) == 0 { teamMember, err := a.GetTeamMember(channel.TeamId, userIDToRemove) if err != nil { return model.NewAppError("removeUserFromChannel", "api.team.remove_user_from_team.missing.app_error", nil, err.Error(), http.StatusBadRequest) @@ -2405,7 +2403,7 @@ func (a *App) GetNumberOfChannelsOnTeam(teamID string) (int, *model.AppError) { return 0, model.NewAppError("GetNumberOfChannelsOnTeam", "app.channel.get_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError) } } - return len(*list), nil + return len(list), nil } func (a *App) SetActiveChannel(userID string, channelID string) *model.AppError { @@ -2678,7 +2676,7 @@ func (a *App) sendWebSocketPostUnreadEvent(channelUnread *model.ChannelUnreadAt, a.Publish(message) } -func (a *App) AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError) { +func (a *App) AutocompleteChannels(teamID string, term string) (model.ChannelList, *model.AppError) { includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels term = strings.TrimSpace(term) @@ -2690,7 +2688,7 @@ func (a *App) AutocompleteChannels(teamID string, term string) (*model.ChannelLi return channelList, nil } -func (a *App) AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) { +func (a *App) AutocompleteChannelsForSearch(teamID string, userID string, term string) (model.ChannelList, *model.AppError) { includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels term = strings.TrimSpace(term) @@ -2704,7 +2702,7 @@ func (a *App) AutocompleteChannelsForSearch(teamID string, userID string, term s } // SearchAllChannels returns a list of channels, the total count of the results of the search (if the paginate search option is true), and an error. -func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) { +func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, *model.AppError) { if opts.ExcludeDefaultChannels { opts.ExcludeChannelNames = a.DefaultChannelNames() } @@ -2735,7 +2733,7 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod return channelList, totalCount, nil } -func (a *App) SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError) { +func (a *App) SearchChannels(teamID string, term string) (model.ChannelList, *model.AppError) { includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels term = strings.TrimSpace(term) @@ -2748,7 +2746,7 @@ func (a *App) SearchChannels(teamID string, term string) (*model.ChannelList, *m return channelList, nil } -func (a *App) SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError) { +func (a *App) SearchArchivedChannels(teamID string, term string, userID string) (model.ChannelList, *model.AppError) { term = strings.TrimSpace(term) channelList, err := a.Srv().Store.Channel().SearchArchivedInTeam(teamID, term, userID) @@ -2759,7 +2757,7 @@ func (a *App) SearchArchivedChannels(teamID string, term string, userID string) return channelList, nil } -func (a *App) SearchChannelsForUser(userID, teamID, term string) (*model.ChannelList, *model.AppError) { +func (a *App) SearchChannelsForUser(userID, teamID, term string) (model.ChannelList, *model.AppError) { includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels term = strings.TrimSpace(term) @@ -2772,9 +2770,9 @@ func (a *App) SearchChannelsForUser(userID, teamID, term string) (*model.Channel return channelList, nil } -func (a *App) SearchGroupChannels(userID, term string) (*model.ChannelList, *model.AppError) { +func (a *App) SearchGroupChannels(userID, term string) (model.ChannelList, *model.AppError) { if term == "" { - return &model.ChannelList{}, nil + return model.ChannelList{}, nil } channelList, err := a.Srv().Store.Channel().SearchGroupChannels(userID, term) @@ -2784,7 +2782,7 @@ func (a *App) SearchGroupChannels(userID, term string) (*model.ChannelList, *mod return channelList, nil } -func (a *App) SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) { +func (a *App) SearchChannelsUserNotIn(teamID string, userID string, term string) (model.ChannelList, *model.AppError) { term = strings.TrimSpace(term) channelList, err := a.Srv().Store.Channel().SearchMore(userID, teamID, term) if err != nil { @@ -2948,7 +2946,7 @@ func (a *App) MoveChannel(c *request.Context, team *model.Team, channel *model.C } channelMemberIds := []string{} - for _, channelMember := range *channelMembers { + for _, channelMember := range channelMembers { channelMemberIds = append(channelMemberIds, channelMember.UserId) } @@ -2958,12 +2956,12 @@ func (a *App) MoveChannel(c *request.Context, team *model.Team, channel *model.C return err2 } - if len(teamMembers) != len(*channelMembers) { + if len(teamMembers) != len(channelMembers) { teamMembersMap := make(map[string]*model.TeamMember, len(teamMembers)) for _, teamMember := range teamMembers { teamMembersMap[teamMember.UserId] = teamMember } - for _, channelMember := range *channelMembers { + for _, channelMember := range channelMembers { if _, ok := teamMembersMap[channelMember.UserId]; !ok { mlog.Warn("Not member of the target team", mlog.String("userId", channelMember.UserId)) } @@ -3068,7 +3066,7 @@ func (a *App) RemoveUsersFromChannelNotMemberOfTeam(c *request.Context, remover channelMemberIds := []string{} channelMemberMap := make(map[string]struct{}) - for _, channelMember := range *channelMembers { + for _, channelMember := range channelMembers { channelMemberMap[channelMember.UserId] = struct{}{} channelMemberIds = append(channelMemberIds, channelMember.UserId) } @@ -3079,7 +3077,7 @@ func (a *App) RemoveUsersFromChannelNotMemberOfTeam(c *request.Context, remover return err } - if len(teamMembers) != len(*channelMembers) { + if len(teamMembers) != len(channelMembers) { for _, teamMember := range teamMembers { delete(channelMemberMap, teamMember.UserId) } @@ -3148,7 +3146,7 @@ func (a *App) setChannelsMuted(channelIDs []string, userID string, muted bool) ( } var membersToUpdate []*model.ChannelMember - for _, member := range *members { + for _, member := range members { if muted == member.IsChannelMuted() { continue } @@ -3189,13 +3187,13 @@ func (a *App) setChannelsMuted(channelIDs []string, userID string, muted bool) ( } func (a *App) FillInChannelProps(channel *model.Channel) *model.AppError { - return a.FillInChannelsProps(&model.ChannelList{channel}) + return a.FillInChannelsProps(model.ChannelList{channel}) } -func (a *App) FillInChannelsProps(channelList *model.ChannelList) *model.AppError { +func (a *App) FillInChannelsProps(channelList model.ChannelList) *model.AppError { // Group the channels by team and call GetChannelsByNames just once per team. channelsByTeam := make(map[string]model.ChannelList) - for _, channel := range *channelList { + for _, channel := range channelList { channelsByTeam[channel.TeamId] = append(channelsByTeam[channel.TeamId], channel) } @@ -3262,13 +3260,13 @@ func (a *App) forEachChannelMember(channelID string, f func(model.ChannelMember) return err } - for _, channelMember := range *channelMembers { + for _, channelMember := range channelMembers { if err = f(channelMember); err != nil { return err } } - length := len(*(channelMembers)) + length := len(channelMembers) if length < perPage { break } diff --git a/app/channel_test.go b/app/channel_test.go index a9c836668eb..1afb6ec0f8c 100644 --- a/app/channel_test.go +++ b/app/channel_test.go @@ -94,7 +94,7 @@ func TestRemoveAllDeactivatedMembersFromChannel(t *testing.T) { require.Nil(t, err) channelMembers, err := th.App.GetChannelMembersPage(channel.Id, 0, 10000000) require.Nil(t, err) - require.Len(t, *channelMembers, 2) + require.Len(t, channelMembers, 2) _, err = th.App.UpdateActive(th.Context, deacivatedUser, false) require.Nil(t, err) @@ -103,7 +103,7 @@ func TestRemoveAllDeactivatedMembersFromChannel(t *testing.T) { channelMembers, err = th.App.GetChannelMembersPage(channel.Id, 0, 10000000) require.Nil(t, err) - require.Len(t, *channelMembers, 1) + require.Len(t, channelMembers, 1) } func TestMoveChannel(t *testing.T) { @@ -254,9 +254,9 @@ func TestRemoveUsersFromChannelNotMemberOfTeam(t *testing.T) { channelMembers, err := th.App.GetChannelMembersPage(channel1.Id, 0, 10000000) require.Nil(t, err) - require.Len(t, *channelMembers, 1) - members := make([]model.ChannelMember, len(*channelMembers)) - for i, m := range *channelMembers { + require.Len(t, channelMembers, 1) + members := make([]model.ChannelMember, len(channelMembers)) + for i, m := range channelMembers { members[i] = m } require.Equal(t, members[0].UserId, th.BasicUser.Id) @@ -771,12 +771,12 @@ func TestFillInChannelProps(t *testing.T) { t.Run("multiple channels", func(t *testing.T) { testCases := []struct { Description string - Channels *model.ChannelList + Channels model.ChannelList ExpectedChannelProps map[string]interface{} }{ { "single channel on basic team", - &model.ChannelList{ + model.ChannelList{ { Name: "test", TeamId: th.BasicTeam.Id, @@ -796,7 +796,7 @@ func TestFillInChannelProps(t *testing.T) { }, { "multiple channels on basic team", - &model.ChannelList{ + model.ChannelList{ { Name: "test", TeamId: th.BasicTeam.Id, @@ -830,7 +830,7 @@ func TestFillInChannelProps(t *testing.T) { }, { "multiple channels across teams", - &model.ChannelList{ + model.ChannelList{ { Name: "test", TeamId: th.BasicTeam.Id, @@ -875,7 +875,7 @@ func TestFillInChannelProps(t *testing.T) { err = th.App.FillInChannelsProps(testCase.Channels) require.Nil(t, err) - for _, channel := range *testCase.Channels { + for _, channel := range testCase.Channels { assert.Equal(t, testCase.ExpectedChannelProps[channel.Name], channel.Props) } }) @@ -998,19 +998,19 @@ func TestGetChannelsForUser(t *testing.T) { channelList, err := th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false, 0) require.Nil(t, err) - require.Len(t, *channelList, 4) + require.Len(t, channelList, 4) th.App.DeleteChannel(th.Context, channel, th.BasicUser.Id) // Now we get all the non-archived channels for the user channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false, 0) require.Nil(t, err) - require.Len(t, *channelList, 3) + require.Len(t, channelList, 3) // Now we get all the channels, even though are archived, for the user channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, true, 0) require.Nil(t, err) - require.Len(t, *channelList, 4) + require.Len(t, channelList, 4) } func TestGetPublicChannelsForTeam(t *testing.T) { @@ -1053,7 +1053,7 @@ func TestGetPublicChannelsForTeam(t *testing.T) { channelList2, err := th.App.GetPublicChannelsForTeam(team.Id, 5, 5) require.Nil(t, err) - channels := append(*channelList, *channelList2...) + channels := append(channelList, channelList2...) assert.ElementsMatch(t, expectedChannels, channels) } @@ -1086,7 +1086,7 @@ func TestGetPrivateChannelsForTeam(t *testing.T) { channelList2, err := th.App.GetPrivateChannelsForTeam(team.Id, 5, 5) require.Nil(t, err) - channels := append(*channelList, *channelList2...) + channels := append(channelList, channelList2...) assert.ElementsMatch(t, expectedChannels, channels) } @@ -1213,10 +1213,10 @@ func TestSearchChannelsForUser(t *testing.T) { searchAndCheck := func(t *testing.T, term string, expectedDisplayNames []string) { res, searchErr := th.App.SearchChannelsForUser(th.BasicUser.Id, th.BasicTeam.Id, term) require.Nil(t, searchErr) - require.Len(t, *res, len(expectedDisplayNames)) + require.Len(t, res, len(expectedDisplayNames)) resultDisplayNames := []string{} - for _, c := range *res { + for _, c := range res { resultDisplayNames = append(resultDisplayNames, c.Name) } require.ElementsMatch(t, expectedDisplayNames, resultDisplayNames) @@ -2004,8 +2004,8 @@ func TestClearChannelMembersCache(t *testing.T) { ChannelId: "1", }) } - mockChannelStore.On("GetMembers", "channelID", 0, 100).Return(&cms, nil) - mockChannelStore.On("GetMembers", "channelID", 100, 100).Return(&model.ChannelMembers{ + mockChannelStore.On("GetMembers", "channelID", 0, 100).Return(cms, nil) + mockChannelStore.On("GetMembers", "channelID", 100, 100).Return(model.ChannelMembers{ model.ChannelMember{ ChannelId: "1", }}, nil) @@ -2061,7 +2061,7 @@ func TestViewChannelCollapsedThreadsTurnedOff(t *testing.T) { } var preferences model.Preferences preferences = append(preferences, preference) - err := th.App.Srv().Store.Preference().Save(&preferences) + err := th.App.Srv().Store.Preference().Save(preferences) require.NoError(t, err) // mention the user in a root post @@ -2137,7 +2137,7 @@ func TestMarkChannelAsUnreadFromPostCollapsedThreadsTurnedOff(t *testing.T) { } var preferences model.Preferences preferences = append(preferences, preference) - err := th.App.Srv().Store.Preference().Save(&preferences) + err := th.App.Srv().Store.Preference().Save(preferences) require.NoError(t, err) // user2: first root mention @user1 diff --git a/app/email/email_batching.go b/app/email/email_batching.go index 0876d8d13bd..43e929929a2 100644 --- a/app/email/email_batching.go +++ b/app/email/email_batching.go @@ -170,7 +170,7 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu continue } - for _, channelMember := range *channelMembers { + for _, channelMember := range channelMembers { if channelMember.LastViewedAt >= batchStartTime { mlog.Debug("Deleted notifications for user", mlog.String("user_id", userID)) delete(job.pendingNotifications, userID) diff --git a/app/email/email_batching_test.go b/app/email/email_batching_test.go index 2b1a334db6b..68b7b9451bd 100644 --- a/app/email/email_batching_test.go +++ b/app/email/email_batching_test.go @@ -96,7 +96,7 @@ func TestCheckPendingNotifications(t *testing.T) { _, err = th.store.Channel().UpdateMember(channelMember) require.NoError(t, err) - nErr := th.store.Preference().Save(&model.Preferences{{ + nErr := th.store.Preference().Save(model.Preferences{{ UserId: th.BasicUser.Id, Category: model.PreferenceCategoryNotifications, Name: model.PreferenceNameEmailInterval, @@ -118,7 +118,7 @@ func TestCheckPendingNotifications(t *testing.T) { require.NoError(t, err) // We reset the interval to something shorter - nErr = th.store.Preference().Save(&model.Preferences{{ + nErr = th.store.Preference().Save(model.Preferences{{ UserId: th.BasicUser.Id, Category: model.PreferenceCategoryNotifications, Name: model.PreferenceNameEmailInterval, @@ -254,7 +254,7 @@ func TestCheckPendingNotificationsCantParseInterval(t *testing.T) { require.NoError(t, err) // preference value is not an integer, so we'll fall back to the default 15min value - nErr := th.store.Preference().Save(&model.Preferences{{ + nErr := th.store.Preference().Save(model.Preferences{{ UserId: th.BasicUser.Id, Category: model.PreferenceCategoryNotifications, Name: model.PreferenceNameEmailInterval, diff --git a/app/export_test.go b/app/export_test.go index eecfa33d463..d103ce0b583 100644 --- a/app/export_test.go +++ b/app/export_test.go @@ -93,7 +93,7 @@ func TestExportUserChannels(t *testing.T) { } var preferences model.Preferences preferences = append(preferences, preference) - err := th.App.Srv().Store.Preference().Save(&preferences) + err := th.App.Srv().Store.Preference().Save(preferences) require.NoError(t, err) th.App.UpdateChannelMemberNotifyProps(notifyProps, channel.Id, user.Id) diff --git a/app/import_functions.go b/app/import_functions.go index dd5350a8685..69e49dadb7e 100644 --- a/app/import_functions.go +++ b/app/import_functions.go @@ -510,7 +510,7 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError { } pref := model.Preference{UserId: savedUser.Id, Category: model.PreferenceCategoryTutorialSteps, Name: savedUser.Id, Value: "0"} - if err := a.Srv().Store.Preference().Save(&model.Preferences{pref}); err != nil { + if err := a.Srv().Store.Preference().Save(model.Preferences{pref}); err != nil { mlog.Warn("Encountered error saving tutorial preference", mlog.Err(err)) } @@ -686,7 +686,7 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError { } if len(preferences) > 0 { - if err := a.Srv().Store.Preference().Save(&preferences); err != nil { + if err := a.Srv().Store.Preference().Save(preferences); err != nil { return model.NewAppError("BulkImport", "app.import.import_user.save_preferences.error", nil, err.Error(), http.StatusInternalServerError) } } @@ -840,7 +840,7 @@ func (a *App) importUserTeams(user *model.User, data *[]UserTeamImportData) *mod for _, team := range allTeams { if len(teamThemePreferencesByID[team.Id]) > 0 { pref := teamThemePreferencesByID[team.Id] - if err := a.Srv().Store.Preference().Save(&pref); err != nil { + if err := a.Srv().Store.Preference().Save(pref); err != nil { return model.NewAppError("BulkImport", "app.import.import_user_teams.save_preferences.error", nil, err.Error(), http.StatusInternalServerError) } } @@ -881,7 +881,7 @@ func (a *App) importUserChannels(user *model.User, team *model.Team, data *[]Use return model.NewAppError("importUserChannels", "app.channel.get_members.app_error", nil, nErr.Error(), http.StatusInternalServerError) } existingMembershipsByChannelId := map[string]model.ChannelMember{} - for _, channelMembership := range *existingMemberships { + for _, channelMembership := range existingMemberships { existingMembershipsByChannelId[channelMembership.ChannelId] = channelMembership } for _, cdata := range *data { @@ -1014,7 +1014,7 @@ func (a *App) importUserChannels(user *model.User, team *model.Team, data *[]Use for _, channel := range allChannels { if len(channelPreferencesByID[channel.Id]) > 0 { pref := channelPreferencesByID[channel.Id] - if err := a.Srv().Store.Preference().Save(&pref); err != nil { + if err := a.Srv().Store.Preference().Save(pref); err != nil { return model.NewAppError("BulkImport", "app.import.import_user_channels.save_preferences.error", nil, err.Error(), http.StatusInternalServerError) } } @@ -1455,7 +1455,7 @@ func (a *App) importMultiplePostLines(c *request.Context, lines []LineImportWork } if len(preferences) > 0 { - if err := a.Srv().Store.Preference().Save(&preferences); err != nil { + if err := a.Srv().Store.Preference().Save(preferences); err != nil { return postWithData.lineNumber, model.NewAppError("BulkImport", "app.import.import_post.save_preferences.error", nil, err.Error(), http.StatusInternalServerError) } } @@ -1563,7 +1563,7 @@ func (a *App) importDirectChannel(data *DirectChannelImportData, dryRun bool) *m } } - if err := a.Srv().Store.Preference().Save(&preferences); err != nil { + if err := a.Srv().Store.Preference().Save(preferences); err != nil { var appErr *model.AppError switch { case errors.As(err, &appErr): @@ -1749,7 +1749,7 @@ func (a *App) importMultipleDirectPostLines(c *request.Context, lines []LineImpo } if len(preferences) > 0 { - if err := a.Srv().Store.Preference().Save(&preferences); err != nil { + if err := a.Srv().Store.Preference().Save(preferences); err != nil { return postWithData.lineNumber, model.NewAppError("BulkImport", "app.import.import_post.save_preferences.error", nil, err.Error(), http.StatusInternalServerError) } } diff --git a/app/import_functions_test.go b/app/import_functions_test.go index 2cc06484abd..0b1a384aca0 100644 --- a/app/import_functions_test.go +++ b/app/import_functions_test.go @@ -1733,7 +1733,7 @@ func TestImportUserTeams(t *testing.T) { for _, teamMember := range teamMembers { channelMembers, err := th.App.Srv().Store.Channel().GetMembersForUser(teamMember.TeamId, user.Id) require.NoError(t, err) - totalMembers += len(*channelMembers) + totalMembers += len(channelMembers) } require.Equal(t, tc.expectedUserChannels, totalMembers) } @@ -1871,9 +1871,9 @@ func TestImportUserChannels(t *testing.T) { } channelMembers, err := th.App.Srv().Store.Channel().GetMembersForUser(th.BasicTeam.Id, user.Id) require.NoError(t, err) - require.Len(t, *channelMembers, tc.expectedUserChannels) + require.Len(t, channelMembers, tc.expectedUserChannels) if tc.expectedUserChannels == 1 { - channelMember := (*channelMembers)[0] + channelMember := channelMembers[0] require.Equal(t, tc.expectedExplicitRoles, channelMember.ExplicitRoles, "Not matching expected explicit roles") require.Equal(t, tc.expectedRoles, channelMember.Roles, "not matching expected roles") if tc.expectedNotifyProps != nil { diff --git a/app/oauth.go b/app/oauth.go index 83c1da2f799..c573877ab5a 100644 --- a/app/oauth.go +++ b/app/oauth.go @@ -221,7 +221,7 @@ func (a *App) AllowOAuthAppAccessToUser(userID string, authRequest *model.Author Value: authRequest.Scope, } - if nErr := a.Srv().Store.Preference().Save(&model.Preferences{authorizedApp}); nErr != nil { + if nErr := a.Srv().Store.Preference().Save(model.Preferences{authorizedApp}); nErr != nil { mlog.Warn("error saving store preference", mlog.Err(nErr)) return authRequest.RedirectURI + "?error=server_error&state=" + authRequest.State, nil } diff --git a/app/opentracing/opentracing_layer.go b/app/opentracing/opentracing_layer.go index b18d31c2e49..e2377b26259 100644 --- a/app/opentracing/opentracing_layer.go +++ b/app/opentracing/opentracing_layer.go @@ -768,7 +768,7 @@ func (a *OpenTracingAppLayer) AuthorizeOAuthUser(w http.ResponseWriter, r *http. return resultVar0, resultVar1, resultVar2, resultVar3, resultVar4 } -func (a *OpenTracingAppLayer) AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) AutocompleteChannels(teamID string, term string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AutocompleteChannels") @@ -790,7 +790,7 @@ func (a *OpenTracingAppLayer) AutocompleteChannels(teamID string, term string) ( return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) AutocompleteChannelsForSearch(teamID string, userID string, term string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AutocompleteChannelsForSearch") @@ -4085,7 +4085,7 @@ func (a *OpenTracingAppLayer) FillInChannelProps(channel *model.Channel) *model. return resultVar0 } -func (a *OpenTracingAppLayer) FillInChannelsProps(channelList *model.ChannelList) *model.AppError { +func (a *OpenTracingAppLayer) FillInChannelsProps(channelList model.ChannelList) *model.AppError { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FillInChannelsProps") @@ -4290,7 +4290,7 @@ func (a *OpenTracingAppLayer) GetActivePluginManifests() ([]*model.Manifest, *mo return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetAllChannels(page int, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) { +func (a *OpenTracingAppLayer) GetAllChannels(page int, perPage int, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllChannels") @@ -4879,7 +4879,7 @@ func (a *OpenTracingAppLayer) GetChannelMemberCount(channelID string) (int64, *m return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError) { +func (a *OpenTracingAppLayer) GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelMembersByIds") @@ -4901,7 +4901,7 @@ func (a *OpenTracingAppLayer) GetChannelMembersByIds(channelID string, userIDs [ return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetChannelMembersForUser(teamID string, userID string) (*model.ChannelMembers, *model.AppError) { +func (a *OpenTracingAppLayer) GetChannelMembersForUser(teamID string, userID string) (model.ChannelMembers, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelMembersForUser") @@ -4945,7 +4945,7 @@ func (a *OpenTracingAppLayer) GetChannelMembersForUserWithPagination(teamID stri return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetChannelMembersPage(channelID string, page int, perPage int) (*model.ChannelMembers, *model.AppError) { +func (a *OpenTracingAppLayer) GetChannelMembersPage(channelID string, page int, perPage int) (model.ChannelMembers, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelMembersPage") @@ -5165,7 +5165,7 @@ func (a *OpenTracingAppLayer) GetChannelsForSchemePage(scheme *model.Scheme, pag return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelsForUser") @@ -5187,7 +5187,7 @@ func (a *OpenTracingAppLayer) GetChannelsForUser(teamID string, userID string, i return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) GetChannelsUserNotIn(teamID string, userID string, offset int, limit int) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelsUserNotIn") @@ -5458,7 +5458,7 @@ func (a *OpenTracingAppLayer) GetDefaultProfileImage(user *model.User) ([]byte, return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) GetDeletedChannels(teamID string, offset int, limit int, userID string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetDeletedChannels") @@ -7701,7 +7701,7 @@ func (a *OpenTracingAppLayer) GetPrevPostIdFromPostList(postList *model.PostList return resultVar0 } -func (a *OpenTracingAppLayer) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPrivateChannelsForTeam") @@ -7767,7 +7767,7 @@ func (a *OpenTracingAppLayer) GetProfileImage(user *model.User) ([]byte, bool, * return resultVar0, resultVar1, resultVar2 } -func (a *OpenTracingAppLayer) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPublicChannelsByIdsForTeam") @@ -7789,7 +7789,7 @@ func (a *OpenTracingAppLayer) GetPublicChannelsByIdsForTeam(teamID string, chann return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPublicChannelsForTeam") @@ -13684,7 +13684,7 @@ func (a *OpenTracingAppLayer) SchemesIterator(scope string, batchSize int) func( return resultVar0 } -func (a *OpenTracingAppLayer) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) { +func (a *OpenTracingAppLayer) SearchAllChannels(term string, opts model.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchAllChannels") @@ -13728,7 +13728,7 @@ func (a *OpenTracingAppLayer) SearchAllTeams(searchOpts *model.TeamSearch) ([]*m return resultVar0, resultVar1, resultVar2 } -func (a *OpenTracingAppLayer) SearchArchivedChannels(teamID string, term string, userID string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) SearchArchivedChannels(teamID string, term string, userID string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchArchivedChannels") @@ -13750,7 +13750,7 @@ func (a *OpenTracingAppLayer) SearchArchivedChannels(teamID string, term string, return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) SearchChannels(teamID string, term string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) SearchChannels(teamID string, term string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchChannels") @@ -13772,7 +13772,7 @@ func (a *OpenTracingAppLayer) SearchChannels(teamID string, term string) (*model return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) SearchChannelsForUser(userID string, teamID string, term string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) SearchChannelsForUser(userID string, teamID string, term string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchChannelsForUser") @@ -13794,7 +13794,7 @@ func (a *OpenTracingAppLayer) SearchChannelsForUser(userID string, teamID string return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) SearchChannelsUserNotIn(teamID string, userID string, term string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) SearchChannelsUserNotIn(teamID string, userID string, term string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchChannelsUserNotIn") @@ -13877,7 +13877,7 @@ func (a *OpenTracingAppLayer) SearchFilesInTeamForUser(c *request.Context, terms return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) SearchGroupChannels(userID string, term string) (*model.ChannelList, *model.AppError) { +func (a *OpenTracingAppLayer) SearchGroupChannels(userID string, term string) (model.ChannelList, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchGroupChannels") diff --git a/app/plugin_api.go b/app/plugin_api.go index cf2e44e4a65..c1594060ec1 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -397,7 +397,7 @@ func (api *PluginAPI) GetPublicChannelsForTeam(teamID string, page, perPage int) if err != nil { return nil, err } - return *channels, err + return channels, err } func (api *PluginAPI) GetChannel(channelID string) (*model.Channel, *model.AppError) { @@ -417,7 +417,7 @@ func (api *PluginAPI) GetChannelsForTeamForUser(teamID, userID string, includeDe if err != nil { return nil, err } - return *channels, err + return channels, err } func (api *PluginAPI) GetChannelStats(channelID string) (*model.ChannelStats, *model.AppError) { @@ -449,7 +449,7 @@ func (api *PluginAPI) SearchChannels(teamID string, term string) ([]*model.Chann if err != nil { return nil, err } - return *channels, err + return channels, err } func (api *PluginAPI) CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { @@ -543,11 +543,11 @@ func (api *PluginAPI) GetChannelMember(channelID, userID string) (*model.Channel return api.app.GetChannelMember(context.Background(), channelID, userID) } -func (api *PluginAPI) GetChannelMembers(channelID string, page, perPage int) (*model.ChannelMembers, *model.AppError) { +func (api *PluginAPI) GetChannelMembers(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError) { return api.app.GetChannelMembersPage(channelID, page, perPage) } -func (api *PluginAPI) GetChannelMembersByIds(channelID string, userIDs []string) (*model.ChannelMembers, *model.AppError) { +func (api *PluginAPI) GetChannelMembersByIds(channelID string, userIDs []string) (model.ChannelMembers, *model.AppError) { return api.app.GetChannelMembersByIds(channelID, userIDs) } diff --git a/app/post.go b/app/post.go index 7ae15a63f8f..69cc3adbf8a 100644 --- a/app/post.go +++ b/app/post.go @@ -735,7 +735,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(post *model.Post, message *m return false, err } - for _, cm := range *channelMembers { + for _, cm := range channelMembers { postForUser := post.Clone() if !a.HasPermissionToReadChannel(cm.UserId, previewedChannel) { postForUser.Metadata.Embeds[0].Data = nil diff --git a/app/preference.go b/app/preference.go index 989b06fe9cd..2af92171606 100644 --- a/app/preference.go +++ b/app/preference.go @@ -46,7 +46,7 @@ func (a *App) UpdatePreferences(userID string, preferences model.Preferences) *m } } - if err := a.Srv().Store.Preference().Save(&preferences); err != nil { + if err := a.Srv().Store.Preference().Save(preferences); err != nil { var appErr *model.AppError switch { case errors.As(err, &appErr): @@ -56,7 +56,7 @@ func (a *App) UpdatePreferences(userID string, preferences model.Preferences) *m } } - if err := a.Srv().Store.Channel().UpdateSidebarChannelsByPreferences(&preferences); err != nil { + if err := a.Srv().Store.Channel().UpdateSidebarChannelsByPreferences(preferences); err != nil { return model.NewAppError("UpdatePreferences", "api.preference.update_preferences.update_sidebar.app_error", nil, err.Error(), http.StatusInternalServerError) } @@ -86,7 +86,7 @@ func (a *App) DeletePreferences(userID string, preferences model.Preferences) *m } } - if err := a.Srv().Store.Channel().DeleteSidebarChannelsByPreferences(&preferences); err != nil { + if err := a.Srv().Store.Channel().DeleteSidebarChannelsByPreferences(preferences); err != nil { return model.NewAppError("DeletePreferences", "api.preference.delete_preferences.update_sidebar.app_error", nil, err.Error(), http.StatusInternalServerError) } diff --git a/app/product_notices.go b/app/product_notices.go index af473e93872..8d706c4a22c 100644 --- a/app/product_notices.go +++ b/app/product_notices.go @@ -377,7 +377,7 @@ func (a *App) UpdateProductNotices() *model.AppError { return model.NewAppError("UpdateProductNotices", "api.system.update_notices.parse_failed", nil, err.Error(), http.StatusBadRequest) } - if err := a.Srv().Store.ProductNotices().ClearOldNotices(&cachedNotices); err != nil { + if err := a.Srv().Store.ProductNotices().ClearOldNotices(cachedNotices); err != nil { return model.NewAppError("UpdateProductNotices", "api.system.update_notices.clear_failed", nil, err.Error(), http.StatusBadRequest) } return nil diff --git a/app/slashcommands/command_expand_collapse.go b/app/slashcommands/command_expand_collapse.go index a4b75c759d8..08b324c283b 100644 --- a/app/slashcommands/command_expand_collapse.go +++ b/app/slashcommands/command_expand_collapse.go @@ -70,7 +70,7 @@ func setCollapsePreference(a *app.App, args *model.CommandArgs, isCollapse bool) Value: strconv.FormatBool(isCollapse), } - if err := a.Srv().Store.Preference().Save(&model.Preferences{pref}); err != nil { + if err := a.Srv().Store.Preference().Save(model.Preferences{pref}); err != nil { return &model.CommandResponse{Text: args.T("api.command_expand_collapse.fail.app_error"), ResponseType: model.CommandResponseTypeEphemeral} } diff --git a/app/slashcommands/command_leave.go b/app/slashcommands/command_leave.go index c01abf39425..ad3a80f0320 100644 --- a/app/slashcommands/command_leave.go +++ b/app/slashcommands/command_leave.go @@ -66,10 +66,10 @@ func (*LeaveProvider) DoCommand(a *app.App, c *request.Context, args *model.Comm if user.IsGuest() { members, err := a.GetChannelMembersForUser(team.Id, args.UserId) - if err != nil || len(*members) == 0 { + if err != nil || len(members) == 0 { return &model.CommandResponse{Text: args.T("api.command_leave.fail.app_error"), ResponseType: model.CommandResponseTypeEphemeral} } - channel, err := a.GetChannel((*members)[0].ChannelId) + channel, err := a.GetChannel(members[0].ChannelId) if err != nil { return &model.CommandResponse{Text: args.T("api.command_leave.fail.app_error"), ResponseType: model.CommandResponseTypeEphemeral} } diff --git a/app/status.go b/app/status.go index 860be8b1706..94fdf41f4e9 100644 --- a/app/status.go +++ b/app/status.go @@ -437,11 +437,11 @@ func (a *App) RemoveCustomStatus(userID string) *model.AppError { } func (a *App) addRecentCustomStatus(userID string, status *model.CustomStatus) *model.AppError { - var newRCS *model.RecentCustomStatuses + var newRCS model.RecentCustomStatuses pref, err := a.GetPreferenceByCategoryAndNameForUser(userID, model.PreferenceCategoryCustomStatus, model.PreferenceNameRecentCustomStatuses) if err != nil || pref.Value == "" { - newRCS = &model.RecentCustomStatuses{*status} + newRCS = model.RecentCustomStatuses{*status} } else { existingRCS := model.RecentCustomStatusesFromJson(strings.NewReader(pref.Value)) newRCS = existingRCS.Add(status) diff --git a/app/syncables_test.go b/app/syncables_test.go index 376b0e7a9a4..40cb5039a9b 100644 --- a/app/syncables_test.go +++ b/app/syncables_test.go @@ -440,8 +440,8 @@ func TestDeleteGroupMemberships(t *testing.T) { cmembers, err := th.App.GetChannelMembersPage(channel.Id, 0, 99) require.Nil(t, err) - require.Len(t, (*cmembers), 1) - require.Equal(t, th.SystemAdminUser.Id, (*cmembers)[0].UserId) + require.Len(t, cmembers, 1) + require.Equal(t, th.SystemAdminUser.Id, cmembers[0].UserId) } func TestSyncSyncableRoles(t *testing.T) { diff --git a/app/team.go b/app/team.go index a5e1063ebcd..28900cc7d88 100644 --- a/app/team.go +++ b/app/team.go @@ -1235,19 +1235,18 @@ func (a *App) LeaveTeam(c *request.Context, team *model.Team, user *model.User, return model.NewAppError("LeaveTeam", "api.team.remove_user_from_team.missing.app_error", nil, err.Error(), http.StatusBadRequest) } - var channelList *model.ChannelList - + var channelList model.ChannelList var nErr error if channelList, nErr = a.Srv().Store.Channel().GetChannels(team.Id, user.Id, true, 0); nErr != nil { var nfErr *store.ErrNotFound if errors.As(nErr, &nfErr) { - channelList = &model.ChannelList{} + channelList = model.ChannelList{} } else { return model.NewAppError("LeaveTeam", "app.channel.get_channels.get.app_error", nil, nErr.Error(), http.StatusInternalServerError) } } - for _, channel := range *channelList { + for _, channel := range channelList { if !channel.IsGroupOrDirect() { a.invalidateCacheForChannelMembers(channel.Id) if nErr = a.Srv().Store.Channel().RemoveMember(channel.Id, user.Id); nErr != nil { @@ -1739,7 +1738,7 @@ func (a *App) PermanentDeleteTeam(team *model.Team) *model.AppError { return model.NewAppError("PermanentDeleteTeam", "app.channel.get_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError) } } else { - for _, c := range *channels { + for _, c := range channels { a.PermanentDeleteChannel(c) } } diff --git a/app/team_test.go b/app/team_test.go index 7ecd71dda71..3de0107a690 100644 --- a/app/team_test.go +++ b/app/team_test.go @@ -264,7 +264,7 @@ func TestAddUserToTeamByToken(t *testing.T) { members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, ruser.Id) require.Nil(t, err) - assert.Len(t, *members, 2) + assert.Len(t, members, 2) }) t.Run("invalid add a guest using a regular invite", func(t *testing.T) { @@ -364,8 +364,8 @@ func TestAddUserToTeamByToken(t *testing.T) { members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, rguest.Id) require.Nil(t, err) - require.Len(t, *members, 1) - assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id) + require.Len(t, members, 1) + assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id) }) t.Run("group-constrained team", func(t *testing.T) { @@ -504,7 +504,7 @@ func TestPermanentDeleteTeam(t *testing.T) { channels, err := th.App.GetPublicChannelsForTeam(team.Id, 0, 1000) require.Nil(t, err) - for _, channel := range *channels { + for _, channel := range channels { err2 := th.App.PermanentDeleteChannel(channel) require.Nil(t, err2) } @@ -1001,8 +1001,8 @@ func TestGetTeamStats(t *testing.T) { require.NotNil(t, teamStats) members, err := th.App.GetChannelMembersPage(th.BasicChannel.Id, 0, 5) require.Nil(t, err) - assert.Equal(t, int64(len(*members)), teamStats.TotalMemberCount) - assert.Equal(t, int64(len(*members)), teamStats.ActiveMemberCount) + assert.Equal(t, int64(len(members)), teamStats.TotalMemberCount) + assert.Equal(t, int64(len(members)), teamStats.ActiveMemberCount) }) t.Run("with view restrictions to not see anything", func(t *testing.T) { diff --git a/app/user.go b/app/user.go index 30c7851d1a4..2f7c60420e6 100644 --- a/app/user.go +++ b/app/user.go @@ -261,7 +261,7 @@ func (a *App) createUserOrGuest(c *request.Context, user *model.User, guest bool recommendedNextStepsPref := model.Preference{UserId: ruser.Id, Category: model.PreferenceRecommendedNextSteps, Name: "hide", Value: "false"} tutorialStepPref := model.Preference{UserId: ruser.Id, Category: model.PreferenceCategoryTutorialSteps, Name: ruser.Id, Value: "0"} - if err := a.Srv().Store.Preference().Save(&model.Preferences{recommendedNextStepsPref, tutorialStepPref}); err != nil { + if err := a.Srv().Store.Preference().Save(model.Preferences{recommendedNextStepsPref, tutorialStepPref}); err != nil { mlog.Warn("Encountered error saving user preferences", mlog.Err(err)) } @@ -868,7 +868,7 @@ func (a *App) invalidateUserChannelMembersCaches(userID string) *model.AppError return err } - for _, channel := range *channelsForUser { + for _, channel := range channelsForUser { a.invalidateCacheForChannelMembers(channel.Id) } } @@ -2056,7 +2056,7 @@ func (a *App) PromoteGuestToUser(c *request.Context, user *model.User, requestor mlog.Warn("Failed to get channel members for user on promote guest to user", mlog.Err(err)) } - for _, member := range *channelMembers { + for _, member := range channelMembers { a.invalidateCacheForChannelMembers(member.ChannelId) evt := model.NewWebSocketEvent(model.WebsocketEventChannelMemberUpdated, "", "", user.Id, nil) @@ -2097,7 +2097,7 @@ func (a *App) DemoteUserToGuest(user *model.User) *model.AppError { continue } - for _, member := range *channelMembers { + for _, member := range channelMembers { a.invalidateCacheForChannelMembers(member.ChannelId) evt := model.NewWebSocketEvent(model.WebsocketEventChannelMemberUpdated, "", "", user.Id, nil) diff --git a/app/user_test.go b/app/user_test.go index d839ba628e7..ee3d0caba09 100644 --- a/app/user_test.go +++ b/app/user_test.go @@ -782,7 +782,7 @@ func TestCreateUserWithToken(t *testing.T) { members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newUser.Id) require.Nil(t, err) - assert.Len(t, *members, 2) + assert.Len(t, members, 2) }) t.Run("valid guest request", func(t *testing.T) { @@ -803,8 +803,8 @@ func TestCreateUserWithToken(t *testing.T) { members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newGuest.Id) require.Nil(t, err) - require.Len(t, *members, 1) - assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id) + require.Len(t, members, 1) + assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id) }) t.Run("create guest having email domain restrictions", func(t *testing.T) { @@ -848,8 +848,8 @@ func TestCreateUserWithToken(t *testing.T) { members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newGuest.Id) require.Nil(t, err) - require.Len(t, *members, 1) - assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id) + require.Len(t, members, 1) + assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id) }) t.Run("create guest having team and system email domain restrictions", func(t *testing.T) { @@ -885,8 +885,8 @@ func TestCreateUserWithToken(t *testing.T) { members, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, newGuest.Id) require.Nil(t, err) - require.Len(t, *members, 1) - assert.Equal(t, (*members)[0].ChannelId, th.BasicChannel.Id) + require.Len(t, members, 1) + assert.Equal(t, members[0].ChannelId, th.BasicChannel.Id) }) } @@ -1183,7 +1183,7 @@ func TestPromoteGuestToUser(t *testing.T) { channelMembers, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, guest.Id) require.Nil(t, err) - require.Len(t, *channelMembers, 1) + require.Len(t, channelMembers, 1) err = th.App.PromoteGuestToUser(th.Context, guest, th.BasicUser.Id) require.Nil(t, err) @@ -1201,7 +1201,7 @@ func TestPromoteGuestToUser(t *testing.T) { channelMembers, err = th.App.GetChannelMembersForUser(th.BasicTeam.Id, guest.Id) require.Nil(t, err) - assert.Len(t, *channelMembers, 3) + assert.Len(t, channelMembers, 3) }) t.Run("Must invalidate channel stats cache when promoting a guest", func(t *testing.T) { @@ -1346,7 +1346,7 @@ func TestDemoteUserToGuest(t *testing.T) { channelMembers, err := th.App.GetChannelMembersForUser(th.BasicTeam.Id, user.Id) require.Nil(t, err) - require.Len(t, *channelMembers, 3) + require.Len(t, channelMembers, 3) err = th.App.DemoteUserToGuest(user) require.Nil(t, err) @@ -1364,7 +1364,7 @@ func TestDemoteUserToGuest(t *testing.T) { channelMembers, err = th.App.GetChannelMembersForUser(th.BasicTeam.Id, user.Id) require.Nil(t, err) - assert.Len(t, *channelMembers, 3) + assert.Len(t, channelMembers, 3) }) t.Run("Must be removed as team and channel admin", func(t *testing.T) { diff --git a/manualtesting/manual_testing.go b/manualtesting/manual_testing.go index 0f80c479bfe..504a44d754d 100644 --- a/manualtesting/manual_testing.go +++ b/manualtesting/manual_testing.go @@ -184,11 +184,11 @@ func getChannelID(a app.AppIface, channelname string, teamid string, userid stri return "", false } - for _, channel := range *channels { + for _, channel := range channels { if channel.Name == channelname { return channel.Id, true } } - mlog.Debug("Could not find channel", mlog.String("Channel name", channelname), mlog.Int("Possibilities searched", len(*channels))) + mlog.Debug("Could not find channel", mlog.String("Channel name", channelname), mlog.Int("Possibilities searched", len(channels))) return "", false } diff --git a/model/channel.go b/model/channel.go index badae30ef9a..0ad8314a40f 100644 --- a/model/channel.go +++ b/model/channel.go @@ -67,8 +67,8 @@ type ChannelWithTeamData struct { } type ChannelsWithCount struct { - Channels *ChannelListWithTeamData `json:"channels"` - TotalCount int64 `json:"total_count"` + Channels ChannelListWithTeamData `json:"channels"` + TotalCount int64 `json:"total_count"` } type ChannelPatch struct { diff --git a/model/client4.go b/model/client4.go index 7b9c8b4d0b2..baa4317aef6 100644 --- a/model/client4.go +++ b/model/client4.go @@ -2398,22 +2398,22 @@ func (c *Client4) RemoveTeamIcon(teamId string) (*Response, error) { // Channel Section // GetAllChannels get all the channels. Must be a system administrator. -func (c *Client4) GetAllChannels(page int, perPage int, etag string) (*ChannelListWithTeamData, *Response, error) { +func (c *Client4) GetAllChannels(page int, perPage int, etag string) (ChannelListWithTeamData, *Response, error) { return c.getAllChannels(page, perPage, etag, ChannelSearchOpts{}) } // GetAllChannelsIncludeDeleted get all the channels. Must be a system administrator. -func (c *Client4) GetAllChannelsIncludeDeleted(page int, perPage int, etag string) (*ChannelListWithTeamData, *Response, error) { +func (c *Client4) GetAllChannelsIncludeDeleted(page int, perPage int, etag string) (ChannelListWithTeamData, *Response, error) { return c.getAllChannels(page, perPage, etag, ChannelSearchOpts{IncludeDeleted: true}) } // GetAllChannelsExcludePolicyConstrained gets all channels which are not part of a data retention policy. // Must be a system administrator. -func (c *Client4) GetAllChannelsExcludePolicyConstrained(page, perPage int, etag string) (*ChannelListWithTeamData, *Response, error) { +func (c *Client4) GetAllChannelsExcludePolicyConstrained(page, perPage int, etag string) (ChannelListWithTeamData, *Response, error) { return c.getAllChannels(page, perPage, etag, ChannelSearchOpts{ExcludePolicyConstrained: true}) } -func (c *Client4) getAllChannels(page int, perPage int, etag string, opts ChannelSearchOpts) (*ChannelListWithTeamData, *Response, error) { +func (c *Client4) getAllChannels(page int, perPage int, etag string, opts ChannelSearchOpts) (ChannelListWithTeamData, *Response, error) { query := fmt.Sprintf("?page=%v&per_page=%v&include_deleted=%v&exclude_policy_constrained=%v", page, perPage, opts.IncludeDeleted, opts.ExcludePolicyConstrained) r, err := c.DoAPIGet(c.channelsRoute()+query, etag) @@ -2422,7 +2422,7 @@ func (c *Client4) getAllChannels(page int, perPage int, etag string, opts Channe } defer closeBody(r) - var ch *ChannelListWithTeamData + var ch ChannelListWithTeamData err = json.NewDecoder(r.Body).Decode(&ch) if err != nil { return nil, BuildResponse(r), NewAppError("getAllChannels", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -2431,7 +2431,7 @@ func (c *Client4) getAllChannels(page int, perPage int, etag string, opts Channe } // GetAllChannelsWithCount get all the channels including the total count. Must be a system administrator. -func (c *Client4) GetAllChannelsWithCount(page int, perPage int, etag string) (*ChannelListWithTeamData, int64, *Response, error) { +func (c *Client4) GetAllChannelsWithCount(page int, perPage int, etag string) (ChannelListWithTeamData, int64, *Response, error) { query := fmt.Sprintf("?page=%v&per_page=%v&include_total_count="+c.boolString(true), page, perPage) r, err := c.DoAPIGet(c.channelsRoute()+query, etag) if err != nil { @@ -2746,14 +2746,14 @@ func (c *Client4) SearchArchivedChannels(teamId string, search *ChannelSearch) ( } // SearchAllChannels search in all the channels. Must be a system administrator. -func (c *Client4) SearchAllChannels(search *ChannelSearch) (*ChannelListWithTeamData, *Response, error) { +func (c *Client4) SearchAllChannels(search *ChannelSearch) (ChannelListWithTeamData, *Response, error) { r, err := c.DoAPIPost(c.channelsRoute()+"/search", search.ToJson()) if err != nil { return nil, BuildResponse(r), err } defer closeBody(r) - var ch *ChannelListWithTeamData + var ch ChannelListWithTeamData err = json.NewDecoder(r.Body).Decode(&ch) if err != nil { return nil, BuildResponse(r), NewAppError("SearchAllChannels", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -2898,7 +2898,7 @@ func (c *Client4) GetChannelByNameForTeamNameIncludeDeleted(channelName, teamNam } // GetChannelMembers gets a page of channel members. -func (c *Client4) GetChannelMembers(channelId string, page, perPage int, etag string) (*ChannelMembers, *Response, error) { +func (c *Client4) GetChannelMembers(channelId string, page, perPage int, etag string) (ChannelMembers, *Response, error) { query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) r, err := c.DoAPIGet(c.channelMembersRoute(channelId)+query, etag) if err != nil { @@ -2906,7 +2906,7 @@ func (c *Client4) GetChannelMembers(channelId string, page, perPage int, etag st } defer closeBody(r) - var ch *ChannelMembers + var ch ChannelMembers err = json.NewDecoder(r.Body).Decode(&ch) if err != nil { return nil, BuildResponse(r), NewAppError("GetChannelMembers", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -2915,14 +2915,14 @@ func (c *Client4) GetChannelMembers(channelId string, page, perPage int, etag st } // GetChannelMembersByIds gets the channel members in a channel for a list of user ids. -func (c *Client4) GetChannelMembersByIds(channelId string, userIds []string) (*ChannelMembers, *Response, error) { +func (c *Client4) GetChannelMembersByIds(channelId string, userIds []string) (ChannelMembers, *Response, error) { r, err := c.DoAPIPost(c.channelMembersRoute(channelId)+"/ids", ArrayToJson(userIds)) if err != nil { return nil, BuildResponse(r), err } defer closeBody(r) - var ch *ChannelMembers + var ch ChannelMembers err = json.NewDecoder(r.Body).Decode(&ch) if err != nil { return nil, BuildResponse(r), NewAppError("GetChannelMembersByIds", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -2947,14 +2947,14 @@ func (c *Client4) GetChannelMember(channelId, userId, etag string) (*ChannelMemb } // GetChannelMembersForUser gets all the channel members for a user on a team. -func (c *Client4) GetChannelMembersForUser(userId, teamId, etag string) (*ChannelMembers, *Response, error) { +func (c *Client4) GetChannelMembersForUser(userId, teamId, etag string) (ChannelMembers, *Response, error) { r, err := c.DoAPIGet(fmt.Sprintf(c.userRoute(userId)+"/teams/%v/channels/members", teamId), etag) if err != nil { return nil, BuildResponse(r), err } defer closeBody(r) - var ch *ChannelMembers + var ch ChannelMembers err = json.NewDecoder(r.Body).Decode(&ch) if err != nil { return nil, BuildResponse(r), NewAppError("GetChannelMembersForUser", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -3080,7 +3080,7 @@ func (c *Client4) RemoveUserFromChannel(channelId, userId string) (*Response, er } // AutocompleteChannelsForTeam will return an ordered list of channels autocomplete suggestions. -func (c *Client4) AutocompleteChannelsForTeam(teamId, name string) (*ChannelList, *Response, error) { +func (c *Client4) AutocompleteChannelsForTeam(teamId, name string) (ChannelList, *Response, error) { query := fmt.Sprintf("?name=%v", name) r, err := c.DoAPIGet(c.channelsForTeamRoute(teamId)+"/autocomplete"+query, "") if err != nil { @@ -3088,7 +3088,7 @@ func (c *Client4) AutocompleteChannelsForTeam(teamId, name string) (*ChannelList } defer closeBody(r) - var ch *ChannelList + var ch ChannelList err = json.NewDecoder(r.Body).Decode(&ch) if err != nil { return nil, BuildResponse(r), NewAppError("AutocompleteChannelsForTeam", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -3097,7 +3097,7 @@ func (c *Client4) AutocompleteChannelsForTeam(teamId, name string) (*ChannelList } // AutocompleteChannelsForTeamForSearch will return an ordered list of your channels autocomplete suggestions. -func (c *Client4) AutocompleteChannelsForTeamForSearch(teamId, name string) (*ChannelList, *Response, error) { +func (c *Client4) AutocompleteChannelsForTeamForSearch(teamId, name string) (ChannelList, *Response, error) { query := fmt.Sprintf("?name=%v", name) r, err := c.DoAPIGet(c.channelsForTeamRoute(teamId)+"/search_autocomplete"+query, "") if err != nil { @@ -3105,7 +3105,7 @@ func (c *Client4) AutocompleteChannelsForTeamForSearch(teamId, name string) (*Ch } defer closeBody(r) - var ch *ChannelList + var ch ChannelList err = json.NewDecoder(r.Body).Decode(&ch) if err != nil { return nil, BuildResponse(r), NewAppError("AutocompleteChannelsForTeamForSearch", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -4053,7 +4053,7 @@ func (c *Client4) GetPreferences(userId string) (Preferences, *Response, error) } // UpdatePreferences saves the user's preferences. -func (c *Client4) UpdatePreferences(userId string, preferences *Preferences) (*Response, error) { +func (c *Client4) UpdatePreferences(userId string, preferences Preferences) (*Response, error) { buf, err := json.Marshal(preferences) if err != nil { return nil, NewAppError("UpdatePreferences", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) @@ -4067,7 +4067,7 @@ func (c *Client4) UpdatePreferences(userId string, preferences *Preferences) (*R } // DeletePreferences deletes the user's preferences. -func (c *Client4) DeletePreferences(userId string, preferences *Preferences) (*Response, error) { +func (c *Client4) DeletePreferences(userId string, preferences Preferences) (*Response, error) { buf, err := json.Marshal(preferences) if err != nil { return nil, NewAppError("DeletePreferences", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) diff --git a/model/custom_status.go b/model/custom_status.go index 9898ce6c4da..7b3d484b273 100644 --- a/model/custom_status.go +++ b/model/custom_status.go @@ -79,7 +79,7 @@ func RuneToHexadecimalString(r rune) string { type RecentCustomStatuses []CustomStatus -func (rcs *RecentCustomStatuses) Contains(cs *CustomStatus) bool { +func (rcs RecentCustomStatuses) Contains(cs *CustomStatus) bool { var csJSON = cs.ToJson() // status is empty @@ -87,7 +87,7 @@ func (rcs *RecentCustomStatuses) Contains(cs *CustomStatus) bool { return false } - for _, status := range *rcs { + for _, status := range rcs { if status.ToJson() == csJSON { return true } @@ -96,11 +96,11 @@ func (rcs *RecentCustomStatuses) Contains(cs *CustomStatus) bool { return false } -func (rcs *RecentCustomStatuses) Add(cs *CustomStatus) *RecentCustomStatuses { - newRCS := (*rcs)[:0] +func (rcs RecentCustomStatuses) Add(cs *CustomStatus) RecentCustomStatuses { + newRCS := rcs[:0] // if same `text` exists in existing recent custom statuses, modify existing status - for _, status := range *rcs { + for _, status := range rcs { if status.Text != cs.Text { newRCS = append(newRCS, status) } @@ -109,33 +109,32 @@ func (rcs *RecentCustomStatuses) Add(cs *CustomStatus) *RecentCustomStatuses { if len(newRCS) > MaxRecentCustomStatuses { newRCS = newRCS[:MaxRecentCustomStatuses] } - return &newRCS + return newRCS } -func (rcs *RecentCustomStatuses) Remove(cs *CustomStatus) *RecentCustomStatuses { +func (rcs RecentCustomStatuses) Remove(cs *CustomStatus) RecentCustomStatuses { var csJSON = cs.ToJson() if csJSON == "" || (cs.Emoji == "" && cs.Text == "") { return rcs } - newRCS := (*rcs)[:0] - for _, status := range *rcs { + newRCS := rcs[:0] + for _, status := range rcs { if status.ToJson() != csJSON { newRCS = append(newRCS, status) } } - return &newRCS + return newRCS } -func (rcs *RecentCustomStatuses) ToJson() string { - rcsCopy := *rcs - b, _ := json.Marshal(rcsCopy) +func (rcs RecentCustomStatuses) ToJson() string { + b, _ := json.Marshal(rcs) return string(b) } -func RecentCustomStatusesFromJson(data io.Reader) *RecentCustomStatuses { - var rcs *RecentCustomStatuses +func RecentCustomStatusesFromJson(data io.Reader) RecentCustomStatuses { + var rcs RecentCustomStatuses _ = json.NewDecoder(data).Decode(&rcs) return rcs } diff --git a/plugin/api.go b/plugin/api.go index 107ae37ed76..54af3dfdc22 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -525,14 +525,14 @@ type API interface { // @tag Channel // @tag User // Minimum server version: 5.6 - GetChannelMembers(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError) + GetChannelMembers(channelId string, page, perPage int) (model.ChannelMembers, *model.AppError) // GetChannelMembersByIds gets a channel membership for a particular User // // @tag Channel // @tag User // Minimum server version: 5.6 - GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) + GetChannelMembersByIds(channelId string, userIds []string) (model.ChannelMembers, *model.AppError) // GetChannelMembersForUser returns all channel memberships on a team for a user. // diff --git a/plugin/api_timer_layer_generated.go b/plugin/api_timer_layer_generated.go index ba066a72671..827f60f2236 100644 --- a/plugin/api_timer_layer_generated.go +++ b/plugin/api_timer_layer_generated.go @@ -574,14 +574,14 @@ func (api *apiTimerLayer) GetChannelMember(channelId, userID string) (*model.Cha return _returnsA, _returnsB } -func (api *apiTimerLayer) GetChannelMembers(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError) { +func (api *apiTimerLayer) GetChannelMembers(channelId string, page, perPage int) (model.ChannelMembers, *model.AppError) { startTime := timePkg.Now() _returnsA, _returnsB := api.apiImpl.GetChannelMembers(channelId, page, perPage) api.recordTime(startTime, "GetChannelMembers", _returnsB == nil) return _returnsA, _returnsB } -func (api *apiTimerLayer) GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { +func (api *apiTimerLayer) GetChannelMembersByIds(channelId string, userIds []string) (model.ChannelMembers, *model.AppError) { startTime := timePkg.Now() _returnsA, _returnsB := api.apiImpl.GetChannelMembersByIds(channelId, userIds) api.recordTime(startTime, "GetChannelMembersByIds", _returnsB == nil) diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go index a55236aea8c..e6ba2e0d295 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -2828,11 +2828,11 @@ type Z_GetChannelMembersArgs struct { } type Z_GetChannelMembersReturns struct { - A *model.ChannelMembers + A model.ChannelMembers B *model.AppError } -func (g *apiRPCClient) GetChannelMembers(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError) { +func (g *apiRPCClient) GetChannelMembers(channelId string, page, perPage int) (model.ChannelMembers, *model.AppError) { _args := &Z_GetChannelMembersArgs{channelId, page, perPage} _returns := &Z_GetChannelMembersReturns{} if err := g.client.Call("Plugin.GetChannelMembers", _args, _returns); err != nil { @@ -2843,7 +2843,7 @@ func (g *apiRPCClient) GetChannelMembers(channelId string, page, perPage int) (* func (s *apiRPCServer) GetChannelMembers(args *Z_GetChannelMembersArgs, returns *Z_GetChannelMembersReturns) error { if hook, ok := s.impl.(interface { - GetChannelMembers(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError) + GetChannelMembers(channelId string, page, perPage int) (model.ChannelMembers, *model.AppError) }); ok { returns.A, returns.B = hook.GetChannelMembers(args.A, args.B, args.C) } else { @@ -2858,11 +2858,11 @@ type Z_GetChannelMembersByIdsArgs struct { } type Z_GetChannelMembersByIdsReturns struct { - A *model.ChannelMembers + A model.ChannelMembers B *model.AppError } -func (g *apiRPCClient) GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { +func (g *apiRPCClient) GetChannelMembersByIds(channelId string, userIds []string) (model.ChannelMembers, *model.AppError) { _args := &Z_GetChannelMembersByIdsArgs{channelId, userIds} _returns := &Z_GetChannelMembersByIdsReturns{} if err := g.client.Call("Plugin.GetChannelMembersByIds", _args, _returns); err != nil { @@ -2873,7 +2873,7 @@ func (g *apiRPCClient) GetChannelMembersByIds(channelId string, userIds []string func (s *apiRPCServer) GetChannelMembersByIds(args *Z_GetChannelMembersByIdsArgs, returns *Z_GetChannelMembersByIdsReturns) error { if hook, ok := s.impl.(interface { - GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) + GetChannelMembersByIds(channelId string, userIds []string) (model.ChannelMembers, *model.AppError) }); ok { returns.A, returns.B = hook.GetChannelMembersByIds(args.A, args.B) } else { diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index f00c38badf0..39efc942304 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -790,15 +790,15 @@ func (_m *API) GetChannelMember(channelId string, userID string) (*model.Channel } // GetChannelMembers provides a mock function with given fields: channelId, page, perPage -func (_m *API) GetChannelMembers(channelId string, page int, perPage int) (*model.ChannelMembers, *model.AppError) { +func (_m *API) GetChannelMembers(channelId string, page int, perPage int) (model.ChannelMembers, *model.AppError) { ret := _m.Called(channelId, page, perPage) - var r0 *model.ChannelMembers - if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelMembers); ok { + var r0 model.ChannelMembers + if rf, ok := ret.Get(0).(func(string, int, int) model.ChannelMembers); ok { r0 = rf(channelId, page, perPage) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelMembers) + r0 = ret.Get(0).(model.ChannelMembers) } } @@ -815,15 +815,15 @@ func (_m *API) GetChannelMembers(channelId string, page int, perPage int) (*mode } // GetChannelMembersByIds provides a mock function with given fields: channelId, userIds -func (_m *API) GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { +func (_m *API) GetChannelMembersByIds(channelId string, userIds []string) (model.ChannelMembers, *model.AppError) { ret := _m.Called(channelId, userIds) - var r0 *model.ChannelMembers - if rf, ok := ret.Get(0).(func(string, []string) *model.ChannelMembers); ok { + var r0 model.ChannelMembers + if rf, ok := ret.Get(0).(func(string, []string) model.ChannelMembers); ok { r0 = rf(channelId, userIds) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelMembers) + r0 = ret.Get(0).(model.ChannelMembers) } } diff --git a/services/searchengine/bleveengine/search.go b/services/searchengine/bleveengine/search.go index 2530923508d..85cd4eaae47 100644 --- a/services/searchengine/bleveengine/search.go +++ b/services/searchengine/bleveengine/search.go @@ -28,9 +28,9 @@ func (b *BleveEngine) IndexPost(post *model.Post, teamId string) *model.AppError return nil } -func (b *BleveEngine) SearchPosts(channels *model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, model.PostSearchMatches, *model.AppError) { +func (b *BleveEngine) SearchPosts(channels model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, model.PostSearchMatches, *model.AppError) { channelQueries := []query.Query{} - for _, channel := range *channels { + for _, channel := range channels { channelIdQ := bleve.NewTermQuery(channel.Id) channelIdQ.SetField("ChannelId") channelQueries = append(channelQueries, channelIdQ) @@ -520,9 +520,9 @@ func (b *BleveEngine) IndexFile(file *model.FileInfo, channelId string) *model.A return nil } -func (b *BleveEngine) SearchFiles(channels *model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, *model.AppError) { +func (b *BleveEngine) SearchFiles(channels model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, *model.AppError) { channelQueries := []query.Query{} - for _, channel := range *channels { + for _, channel := range channels { channelIdQ := bleve.NewTermQuery(channel.Id) channelIdQ.SetField("ChannelId") channelQueries = append(channelQueries, channelIdQ) diff --git a/services/searchengine/interface.go b/services/searchengine/interface.go index 7d5312e1340..929017bbe5c 100644 --- a/services/searchengine/interface.go +++ b/services/searchengine/interface.go @@ -23,7 +23,7 @@ type SearchEngineInterface interface { IsAutocompletionEnabled() bool IsIndexingSync() bool IndexPost(post *model.Post, teamId string) *model.AppError - SearchPosts(channels *model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, model.PostSearchMatches, *model.AppError) + SearchPosts(channels model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, model.PostSearchMatches, *model.AppError) DeletePost(post *model.Post) *model.AppError DeleteChannelPosts(channelID string) *model.AppError DeleteUserPosts(userID string) *model.AppError @@ -35,7 +35,7 @@ type SearchEngineInterface interface { SearchUsersInTeam(teamId string, restrictedToChannels []string, term string, options *model.UserSearchOptions) ([]string, *model.AppError) DeleteUser(user *model.User) *model.AppError IndexFile(file *model.FileInfo, channelId string) *model.AppError - SearchFiles(channels *model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, *model.AppError) + SearchFiles(channels model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, *model.AppError) DeleteFile(fileID string) *model.AppError DeletePostFiles(postID string) *model.AppError DeleteUserFiles(userID string) *model.AppError diff --git a/services/searchengine/mocks/SearchEngineInterface.go b/services/searchengine/mocks/SearchEngineInterface.go index ec65edb0278..582ba0f6d19 100644 --- a/services/searchengine/mocks/SearchEngineInterface.go +++ b/services/searchengine/mocks/SearchEngineInterface.go @@ -426,11 +426,11 @@ func (_m *SearchEngineInterface) SearchChannels(teamId string, term string) ([]s } // SearchFiles provides a mock function with given fields: channels, searchParams, page, perPage -func (_m *SearchEngineInterface) SearchFiles(channels *model.ChannelList, searchParams []*model.SearchParams, page int, perPage int) ([]string, *model.AppError) { +func (_m *SearchEngineInterface) SearchFiles(channels model.ChannelList, searchParams []*model.SearchParams, page int, perPage int) ([]string, *model.AppError) { ret := _m.Called(channels, searchParams, page, perPage) var r0 []string - if rf, ok := ret.Get(0).(func(*model.ChannelList, []*model.SearchParams, int, int) []string); ok { + if rf, ok := ret.Get(0).(func(model.ChannelList, []*model.SearchParams, int, int) []string); ok { r0 = rf(channels, searchParams, page, perPage) } else { if ret.Get(0) != nil { @@ -439,7 +439,7 @@ func (_m *SearchEngineInterface) SearchFiles(channels *model.ChannelList, search } var r1 *model.AppError - if rf, ok := ret.Get(1).(func(*model.ChannelList, []*model.SearchParams, int, int) *model.AppError); ok { + if rf, ok := ret.Get(1).(func(model.ChannelList, []*model.SearchParams, int, int) *model.AppError); ok { r1 = rf(channels, searchParams, page, perPage) } else { if ret.Get(1) != nil { @@ -451,11 +451,11 @@ func (_m *SearchEngineInterface) SearchFiles(channels *model.ChannelList, search } // SearchPosts provides a mock function with given fields: channels, searchParams, page, perPage -func (_m *SearchEngineInterface) SearchPosts(channels *model.ChannelList, searchParams []*model.SearchParams, page int, perPage int) ([]string, model.PostSearchMatches, *model.AppError) { +func (_m *SearchEngineInterface) SearchPosts(channels model.ChannelList, searchParams []*model.SearchParams, page int, perPage int) ([]string, model.PostSearchMatches, *model.AppError) { ret := _m.Called(channels, searchParams, page, perPage) var r0 []string - if rf, ok := ret.Get(0).(func(*model.ChannelList, []*model.SearchParams, int, int) []string); ok { + if rf, ok := ret.Get(0).(func(model.ChannelList, []*model.SearchParams, int, int) []string); ok { r0 = rf(channels, searchParams, page, perPage) } else { if ret.Get(0) != nil { @@ -464,7 +464,7 @@ func (_m *SearchEngineInterface) SearchPosts(channels *model.ChannelList, search } var r1 model.PostSearchMatches - if rf, ok := ret.Get(1).(func(*model.ChannelList, []*model.SearchParams, int, int) model.PostSearchMatches); ok { + if rf, ok := ret.Get(1).(func(model.ChannelList, []*model.SearchParams, int, int) model.PostSearchMatches); ok { r1 = rf(channels, searchParams, page, perPage) } else { if ret.Get(1) != nil { @@ -473,7 +473,7 @@ func (_m *SearchEngineInterface) SearchPosts(channels *model.ChannelList, search } var r2 *model.AppError - if rf, ok := ret.Get(2).(func(*model.ChannelList, []*model.SearchParams, int, int) *model.AppError); ok { + if rf, ok := ret.Get(2).(func(model.ChannelList, []*model.SearchParams, int, int) *model.AppError); ok { r2 = rf(channels, searchParams, page, perPage) } else { if ret.Get(2) != nil { diff --git a/store/opentracinglayer/opentracinglayer.go b/store/opentracinglayer/opentracinglayer.go index eb09a59ca17..31912204dec 100644 --- a/store/opentracinglayer/opentracinglayer.go +++ b/store/opentracinglayer/opentracinglayer.go @@ -570,7 +570,7 @@ func (s *OpenTracingLayerChannelStore) AnalyticsTypeCount(teamID string, channel return result, err } -func (s *OpenTracingLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeam") s.Root.Store.SetContext(newCtx) @@ -588,7 +588,7 @@ func (s *OpenTracingLayerChannelStore) AutocompleteInTeam(teamID string, term st return result, err } -func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeamForSearch") s.Root.Store.SetContext(newCtx) @@ -763,7 +763,7 @@ func (s *OpenTracingLayerChannelStore) DeleteSidebarCategory(categoryID string) return err } -func (s *OpenTracingLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s *OpenTracingLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences model.Preferences) error { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.DeleteSidebarChannelsByPreferences") s.Root.Store.SetContext(newCtx) @@ -853,7 +853,7 @@ func (s *OpenTracingLayerChannelStore) GetAllChannelMembersNotifyPropsForChannel return result, err } -func (s *OpenTracingLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) { +func (s *OpenTracingLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetAllChannels") s.Root.Store.SetContext(newCtx) @@ -1051,7 +1051,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelUnread(channelID string, userID return result, err } -func (s *OpenTracingLayerChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannels") s.Root.Store.SetContext(newCtx) @@ -1123,7 +1123,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelsByScheme(schemeID string, offs return result, err } -func (s *OpenTracingLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetDeleted") s.Root.Store.SetContext(newCtx) @@ -1298,7 +1298,7 @@ func (s *OpenTracingLayerChannelStore) GetMemberForPost(postID string, userID st return result, err } -func (s *OpenTracingLayerChannelStore) GetMembers(channelID string, offset int, limit int) (*model.ChannelMembers, error) { +func (s *OpenTracingLayerChannelStore) GetMembers(channelID string, offset int, limit int) (model.ChannelMembers, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembers") s.Root.Store.SetContext(newCtx) @@ -1316,7 +1316,7 @@ func (s *OpenTracingLayerChannelStore) GetMembers(channelID string, offset int, return result, err } -func (s *OpenTracingLayerChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (*model.ChannelMembers, error) { +func (s *OpenTracingLayerChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (model.ChannelMembers, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembersByChannelIds") s.Root.Store.SetContext(newCtx) @@ -1334,7 +1334,7 @@ func (s *OpenTracingLayerChannelStore) GetMembersByChannelIds(channelIds []strin return result, err } -func (s *OpenTracingLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (*model.ChannelMembers, error) { +func (s *OpenTracingLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (model.ChannelMembers, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembersByIds") s.Root.Store.SetContext(newCtx) @@ -1352,7 +1352,7 @@ func (s *OpenTracingLayerChannelStore) GetMembersByIds(channelID string, userIds return result, err } -func (s *OpenTracingLayerChannelStore) GetMembersForUser(teamID string, userID string) (*model.ChannelMembers, error) { +func (s *OpenTracingLayerChannelStore) GetMembersForUser(teamID string, userID string) (model.ChannelMembers, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembersForUser") s.Root.Store.SetContext(newCtx) @@ -1370,7 +1370,7 @@ func (s *OpenTracingLayerChannelStore) GetMembersForUser(teamID string, userID s return result, err } -func (s *OpenTracingLayerChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (*model.ChannelMembers, error) { +func (s *OpenTracingLayerChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (model.ChannelMembers, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembersForUserWithPagination") s.Root.Store.SetContext(newCtx) @@ -1388,7 +1388,7 @@ func (s *OpenTracingLayerChannelStore) GetMembersForUserWithPagination(teamID st return result, err } -func (s *OpenTracingLayerChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMoreChannels") s.Root.Store.SetContext(newCtx) @@ -1442,7 +1442,7 @@ func (s *OpenTracingLayerChannelStore) GetPinnedPosts(channelID string) (*model. return result, err } -func (s *OpenTracingLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetPrivateChannelsForTeam") s.Root.Store.SetContext(newCtx) @@ -1460,7 +1460,7 @@ func (s *OpenTracingLayerChannelStore) GetPrivateChannelsForTeam(teamID string, return result, err } -func (s *OpenTracingLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetPublicChannelsByIdsForTeam") s.Root.Store.SetContext(newCtx) @@ -1478,7 +1478,7 @@ func (s *OpenTracingLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID stri return result, err } -func (s *OpenTracingLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetPublicChannelsForTeam") s.Root.Store.SetContext(newCtx) @@ -1550,7 +1550,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategoryOrder(userID string, te return result, err } -func (s *OpenTracingLayerChannelStore) GetTeamChannels(teamID string) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) GetTeamChannels(teamID string) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetTeamChannels") s.Root.Store.SetContext(newCtx) @@ -1996,7 +1996,7 @@ func (s *OpenTracingLayerChannelStore) SaveMultipleMembers(members []*model.Chan return result, err } -func (s *OpenTracingLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) { +func (s *OpenTracingLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchAllChannels") s.Root.Store.SetContext(newCtx) @@ -2014,7 +2014,7 @@ func (s *OpenTracingLayerChannelStore) SearchAllChannels(term string, opts store return result, resultVar1, err } -func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchArchivedInTeam") s.Root.Store.SetContext(newCtx) @@ -2032,7 +2032,7 @@ func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamID string, term return result, err } -func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchForUserInTeam") s.Root.Store.SetContext(newCtx) @@ -2050,7 +2050,7 @@ func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userID string, teamID return result, err } -func (s *OpenTracingLayerChannelStore) SearchGroupChannels(userID string, term string) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) SearchGroupChannels(userID string, term string) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchGroupChannels") s.Root.Store.SetContext(newCtx) @@ -2068,7 +2068,7 @@ func (s *OpenTracingLayerChannelStore) SearchGroupChannels(userID string, term s return result, err } -func (s *OpenTracingLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchInTeam") s.Root.Store.SetContext(newCtx) @@ -2086,7 +2086,7 @@ func (s *OpenTracingLayerChannelStore) SearchInTeam(teamID string, term string, return result, err } -func (s *OpenTracingLayerChannelStore) SearchMore(userID string, teamID string, term string) (*model.ChannelList, error) { +func (s *OpenTracingLayerChannelStore) SearchMore(userID string, teamID string, term string) (model.ChannelList, error) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchMore") s.Root.Store.SetContext(newCtx) @@ -2302,7 +2302,7 @@ func (s *OpenTracingLayerChannelStore) UpdateSidebarChannelCategoryOnMove(channe return err } -func (s *OpenTracingLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s *OpenTracingLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences model.Preferences) error { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarChannelsByPreferences") s.Root.Store.SetContext(newCtx) @@ -5911,7 +5911,7 @@ func (s *OpenTracingLayerPreferenceStore) PermanentDeleteByUser(userID string) e return err } -func (s *OpenTracingLayerPreferenceStore) Save(preferences *model.Preferences) error { +func (s *OpenTracingLayerPreferenceStore) Save(preferences model.Preferences) error { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PreferenceStore.Save") s.Root.Store.SetContext(newCtx) @@ -5947,7 +5947,7 @@ func (s *OpenTracingLayerProductNoticesStore) Clear(notices []string) error { return err } -func (s *OpenTracingLayerProductNoticesStore) ClearOldNotices(currentNotices *model.ProductNotices) error { +func (s *OpenTracingLayerProductNoticesStore) ClearOldNotices(currentNotices model.ProductNotices) error { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ProductNoticesStore.ClearOldNotices") s.Root.Store.SetContext(newCtx) diff --git a/store/retrylayer/retrylayer.go b/store/retrylayer/retrylayer.go index f080798197a..90b67f7dc9f 100644 --- a/store/retrylayer/retrylayer.go +++ b/store/retrylayer/retrylayer.go @@ -608,7 +608,7 @@ func (s *RetryLayerChannelStore) AnalyticsTypeCount(teamID string, channelType m } -func (s *RetryLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { tries := 0 for { @@ -628,7 +628,7 @@ func (s *RetryLayerChannelStore) AutocompleteInTeam(teamID string, term string, } -func (s *RetryLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (model.ChannelList, error) { tries := 0 for { @@ -814,7 +814,7 @@ func (s *RetryLayerChannelStore) DeleteSidebarCategory(categoryID string) error } -func (s *RetryLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s *RetryLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences model.Preferences) error { tries := 0 for { @@ -914,7 +914,7 @@ func (s *RetryLayerChannelStore) GetAllChannelMembersNotifyPropsForChannel(chann } -func (s *RetryLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) { +func (s *RetryLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, error) { tries := 0 for { @@ -1134,7 +1134,7 @@ func (s *RetryLayerChannelStore) GetChannelUnread(channelID string, userID strin } -func (s *RetryLayerChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, error) { tries := 0 for { @@ -1214,7 +1214,7 @@ func (s *RetryLayerChannelStore) GetChannelsByScheme(schemeID string, offset int } -func (s *RetryLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (model.ChannelList, error) { tries := 0 for { @@ -1400,7 +1400,7 @@ func (s *RetryLayerChannelStore) GetMemberForPost(postID string, userID string) } -func (s *RetryLayerChannelStore) GetMembers(channelID string, offset int, limit int) (*model.ChannelMembers, error) { +func (s *RetryLayerChannelStore) GetMembers(channelID string, offset int, limit int) (model.ChannelMembers, error) { tries := 0 for { @@ -1420,7 +1420,7 @@ func (s *RetryLayerChannelStore) GetMembers(channelID string, offset int, limit } -func (s *RetryLayerChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (*model.ChannelMembers, error) { +func (s *RetryLayerChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (model.ChannelMembers, error) { tries := 0 for { @@ -1440,7 +1440,7 @@ func (s *RetryLayerChannelStore) GetMembersByChannelIds(channelIds []string, use } -func (s *RetryLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (*model.ChannelMembers, error) { +func (s *RetryLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (model.ChannelMembers, error) { tries := 0 for { @@ -1460,7 +1460,7 @@ func (s *RetryLayerChannelStore) GetMembersByIds(channelID string, userIds []str } -func (s *RetryLayerChannelStore) GetMembersForUser(teamID string, userID string) (*model.ChannelMembers, error) { +func (s *RetryLayerChannelStore) GetMembersForUser(teamID string, userID string) (model.ChannelMembers, error) { tries := 0 for { @@ -1480,7 +1480,7 @@ func (s *RetryLayerChannelStore) GetMembersForUser(teamID string, userID string) } -func (s *RetryLayerChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (*model.ChannelMembers, error) { +func (s *RetryLayerChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (model.ChannelMembers, error) { tries := 0 for { @@ -1500,7 +1500,7 @@ func (s *RetryLayerChannelStore) GetMembersForUserWithPagination(teamID string, } -func (s *RetryLayerChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (model.ChannelList, error) { tries := 0 for { @@ -1560,7 +1560,7 @@ func (s *RetryLayerChannelStore) GetPinnedPosts(channelID string) (*model.PostLi } -func (s *RetryLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { tries := 0 for { @@ -1580,7 +1580,7 @@ func (s *RetryLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset } -func (s *RetryLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (model.ChannelList, error) { tries := 0 for { @@ -1600,7 +1600,7 @@ func (s *RetryLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, ch } -func (s *RetryLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { tries := 0 for { @@ -1680,7 +1680,7 @@ func (s *RetryLayerChannelStore) GetSidebarCategoryOrder(userID string, teamID s } -func (s *RetryLayerChannelStore) GetTeamChannels(teamID string) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) GetTeamChannels(teamID string) (model.ChannelList, error) { tries := 0 for { @@ -2108,7 +2108,7 @@ func (s *RetryLayerChannelStore) SaveMultipleMembers(members []*model.ChannelMem } -func (s *RetryLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) { +func (s *RetryLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, error) { tries := 0 for { @@ -2128,7 +2128,7 @@ func (s *RetryLayerChannelStore) SearchAllChannels(term string, opts store.Chann } -func (s *RetryLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (model.ChannelList, error) { tries := 0 for { @@ -2148,7 +2148,7 @@ func (s *RetryLayerChannelStore) SearchArchivedInTeam(teamID string, term string } -func (s *RetryLayerChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (model.ChannelList, error) { tries := 0 for { @@ -2168,7 +2168,7 @@ func (s *RetryLayerChannelStore) SearchForUserInTeam(userID string, teamID strin } -func (s *RetryLayerChannelStore) SearchGroupChannels(userID string, term string) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) SearchGroupChannels(userID string, term string) (model.ChannelList, error) { tries := 0 for { @@ -2188,7 +2188,7 @@ func (s *RetryLayerChannelStore) SearchGroupChannels(userID string, term string) } -func (s *RetryLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { tries := 0 for { @@ -2208,7 +2208,7 @@ func (s *RetryLayerChannelStore) SearchInTeam(teamID string, term string, includ } -func (s *RetryLayerChannelStore) SearchMore(userID string, teamID string, term string) (*model.ChannelList, error) { +func (s *RetryLayerChannelStore) SearchMore(userID string, teamID string, term string) (model.ChannelList, error) { tries := 0 for { @@ -2448,7 +2448,7 @@ func (s *RetryLayerChannelStore) UpdateSidebarChannelCategoryOnMove(channel *mod } -func (s *RetryLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s *RetryLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences model.Preferences) error { tries := 0 for { @@ -6390,7 +6390,7 @@ func (s *RetryLayerPreferenceStore) PermanentDeleteByUser(userID string) error { } -func (s *RetryLayerPreferenceStore) Save(preferences *model.Preferences) error { +func (s *RetryLayerPreferenceStore) Save(preferences model.Preferences) error { tries := 0 for { @@ -6430,7 +6430,7 @@ func (s *RetryLayerProductNoticesStore) Clear(notices []string) error { } -func (s *RetryLayerProductNoticesStore) ClearOldNotices(currentNotices *model.ProductNotices) error { +func (s *RetryLayerProductNoticesStore) ClearOldNotices(currentNotices model.ProductNotices) error { tries := 0 for { diff --git a/store/searchlayer/channel_layer.go b/store/searchlayer/channel_layer.go index 4277a13b290..aeea020e142 100644 --- a/store/searchlayer/channel_layer.go +++ b/store/searchlayer/channel_layer.go @@ -132,8 +132,8 @@ func (c *SearchChannelStore) SaveDirectChannel(directchannel *model.Channel, mem return channel, err } -func (c *SearchChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) { - var channelList *model.ChannelList +func (c *SearchChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (model.ChannelList, error) { + var channelList model.ChannelList var err error allFailed := true @@ -165,7 +165,7 @@ func (c *SearchChannelStore) AutocompleteInTeam(teamId string, term string, incl return channelList, nil } -func (c *SearchChannelStore) searchAutocompleteChannels(engine searchengine.SearchEngineInterface, teamId, term string, includeDeleted bool) (*model.ChannelList, error) { +func (c *SearchChannelStore) searchAutocompleteChannels(engine searchengine.SearchEngineInterface, teamId, term string, includeDeleted bool) (model.ChannelList, error) { channelIds, err := engine.SearchChannels(teamId, term) if err != nil { return nil, err @@ -183,7 +183,7 @@ func (c *SearchChannelStore) searchAutocompleteChannels(engine searchengine.Sear } } - return &channelList, nil + return channelList, nil } func (c *SearchChannelStore) PermanentDeleteMembersByUser(userId string) error { diff --git a/store/searchlayer/user_layer.go b/store/searchlayer/user_layer.go index 4c5a820b254..2c63dabd3a8 100644 --- a/store/searchlayer/user_layer.go +++ b/store/searchlayer/user_layer.go @@ -171,7 +171,7 @@ func (s *SearchUserStore) getListOfAllowedChannelsForTeam(teamId string, viewRes if err != nil { return nil, errors.Wrap(err, "failed to get team channels") } - for _, channel := range *channels { + for _, channel := range channels { listOfAllowedChannels = append(listOfAllowedChannels, channel.Id) } return listOfAllowedChannels, nil diff --git a/store/searchtest/helper.go b/store/searchtest/helper.go index 933a9c3a8db..b0bc24b20e4 100644 --- a/store/searchtest/helper.go +++ b/store/searchtest/helper.go @@ -465,10 +465,10 @@ func (th *SearchTestHelper) checkFileInfoInSearchResults(t *testing.T, fileID st assert.Contains(t, fileIDS, fileID, "Did not find expected file in search results.") } -func (th *SearchTestHelper) checkChannelIdsMatch(t *testing.T, expected []string, results *model.ChannelList) { +func (th *SearchTestHelper) checkChannelIdsMatch(t *testing.T, expected []string, results model.ChannelList) { t.Helper() - channelIds := make([]string, len(*results)) - for i, channel := range *results { + channelIds := make([]string, len(results)) + for i, channel := range results { channelIds[i] = channel.Id } require.ElementsMatch(t, expected, channelIds) diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index 23c58e8fab7..1aeb57eaa98 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -250,14 +250,14 @@ func (db channelMemberWithSchemeRoles) ToModel() *model.ChannelMember { } } -func (db channelMemberWithSchemeRolesList) ToModel() *model.ChannelMembers { +func (db channelMemberWithSchemeRolesList) ToModel() model.ChannelMembers { cms := model.ChannelMembers{} for _, cm := range db { cms = append(cms, *cm.ToModel()) } - return &cms + return cms } type allChannelMember struct { @@ -945,7 +945,7 @@ func (s SqlChannelStore) PermanentDeleteMembersByChannel(channelId string) error return nil } -func (s SqlChannelStore) GetChannels(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) { +func (s SqlChannelStore) GetChannels(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, error) { query := s.getQueryBuilder(). Select("Channels.*"). From("Channels, ChannelMembers"). @@ -975,25 +975,25 @@ func (s SqlChannelStore) GetChannels(teamId string, userId string, includeDelete query = query.Where(sq.Eq{"DeleteAt": 0}) } - channels := &model.ChannelList{} + var channels model.ChannelList sql, args, err := query.ToSql() if err != nil { return nil, errors.Wrapf(err, "getchannels_tosql") } - _, err = s.GetReplica().Select(channels, sql, args...) + _, err = s.GetReplica().Select(&channels, sql, args...) if err != nil { return nil, errors.Wrapf(err, "failed to get channels with TeamId=%s and UserId=%s", teamId, userId) } - if len(*channels) == 0 { + if len(channels) == 0 { return nil, store.NewErrNotFound("Channel", "userId="+userId) } return channels, nil } -func (s SqlChannelStore) GetAllChannels(offset, limit int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) { +func (s SqlChannelStore) GetAllChannels(offset, limit int, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, error) { query := s.getAllChannelsQuery(opts, false) query = query.OrderBy("c.DisplayName, Teams.DisplayName").Limit(uint64(limit)).Offset(uint64(offset)) @@ -1003,8 +1003,8 @@ func (s SqlChannelStore) GetAllChannels(offset, limit int, opts store.ChannelSea return nil, errors.Wrap(err, "failed to create query") } - data := &model.ChannelListWithTeamData{} - _, err = s.GetReplica().Select(data, queryString, args...) + var data model.ChannelListWithTeamData + _, err = s.GetReplica().Select(&data, queryString, args...) if err != nil { return nil, errors.Wrap(err, "failed to get all channels") @@ -1071,9 +1071,9 @@ func (s SqlChannelStore) getAllChannelsQuery(opts store.ChannelSearchOpts, forCo return query } -func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error) { - channels := &model.ChannelList{} - _, err := s.GetReplica().Select(channels, ` +func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (model.ChannelList, error) { + var channels model.ChannelList + _, err := s.GetReplica().Select(&channels, ` SELECT Channels.* FROM @@ -1113,8 +1113,8 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset in return channels, nil } -func (s SqlChannelStore) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, error) { - channels := &model.ChannelList{} +func (s SqlChannelStore) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (model.ChannelList, error) { + var channels model.ChannelList builder := s.getQueryBuilder(). Select("*"). @@ -1129,16 +1129,16 @@ func (s SqlChannelStore) GetPrivateChannelsForTeam(teamId string, offset int, li return nil, errors.Wrap(err, "channels_tosql") } - _, err = s.GetReplica().Select(channels, query, args...) + _, err = s.GetReplica().Select(&channels, query, args...) if err != nil { return nil, errors.Wrapf(err, "failed to find chaneld with teamId=%s", teamId) } return channels, nil } -func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, error) { - channels := &model.ChannelList{} - _, err := s.GetReplica().Select(channels, ` +func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) (model.ChannelList, error) { + var channels model.ChannelList + _, err := s.GetReplica().Select(&channels, ` SELECT Channels.* FROM @@ -1164,7 +1164,7 @@ func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, lim return channels, nil } -func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, error) { +func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (model.ChannelList, error) { props := make(map[string]interface{}) props["teamId"] = teamId @@ -1179,8 +1179,8 @@ func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds idQuery += ":channelId" + strconv.Itoa(index) } - data := &model.ChannelList{} - _, err := s.GetReplica().Select(data, ` + var data model.ChannelList + _, err := s.GetReplica().Select(&data, ` SELECT Channels.* FROM @@ -1198,7 +1198,7 @@ func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds return nil, errors.Wrap(err, "failed to find Channels") } - if len(*data) == 0 { + if len(data) == 0 { return nil, store.NewErrNotFound("Channel", fmt.Sprintf("teamId=%s, channelIds=%v", teamId, channelIds)) } @@ -1231,15 +1231,15 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) (*model. return counts, nil } -func (s SqlChannelStore) GetTeamChannels(teamId string) (*model.ChannelList, error) { - data := &model.ChannelList{} - _, err := s.GetReplica().Select(data, "SELECT * FROM Channels WHERE TeamId = :TeamId And Type != 'D' ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId}) +func (s SqlChannelStore) GetTeamChannels(teamId string) (model.ChannelList, error) { + var data model.ChannelList + _, err := s.GetReplica().Select(&data, "SELECT * FROM Channels WHERE TeamId = :TeamId And Type != 'D' ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId}) if err != nil { return nil, errors.Wrapf(err, "failed to find Channels with teamId=%s", teamId) } - if len(*data) == 0 { + if len(data) == 0 { return nil, store.NewErrNotFound("Channel", fmt.Sprintf("teamId=%s", teamId)) } @@ -1364,8 +1364,8 @@ func (s SqlChannelStore) GetDeletedByName(teamId string, name string) (*model.Ch return &channel, nil } -func (s SqlChannelStore) GetDeleted(teamId string, offset int, limit int, userId string) (*model.ChannelList, error) { - channels := &model.ChannelList{} +func (s SqlChannelStore) GetDeleted(teamId string, offset int, limit int, userId string) (model.ChannelList, error) { + var channels model.ChannelList query := ` SELECT * FROM Channels @@ -1381,7 +1381,7 @@ func (s SqlChannelStore) GetDeleted(teamId string, offset int, limit int, userId ORDER BY DisplayName LIMIT :Limit OFFSET :Offset ` - if _, err := s.GetReplica().Select(channels, query, map[string]interface{}{"TeamId": teamId, "Limit": limit, "Offset": offset, "UserId": userId}); err != nil { + if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "Limit": limit, "Offset": offset, "UserId": userId}); err != nil { if err == sql.ErrNoRows { return nil, store.NewErrNotFound("Channel", fmt.Sprintf("TeamId=%s,UserId=%s", teamId, userId)) } @@ -1630,7 +1630,7 @@ func (s SqlChannelStore) UpdateMember(member *model.ChannelMember) (*model.Chann return updatedMembers[0], nil } -func (s SqlChannelStore) GetMembers(channelId string, offset, limit int) (*model.ChannelMembers, error) { +func (s SqlChannelStore) GetMembers(channelId string, offset, limit int) (model.ChannelMembers, error) { var dbMembers channelMemberWithSchemeRolesList _, err := s.GetReplica().Select(&dbMembers, ChannelMembersWithSchemeSelectQuery+"WHERE ChannelId = :ChannelId LIMIT :Limit OFFSET :Offset", map[string]interface{}{"ChannelId": channelId, "Limit": limit, "Offset": offset}) if err != nil { @@ -2388,7 +2388,7 @@ func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType st return v, nil } -func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, error) { +func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) (model.ChannelMembers, error) { var dbMembers channelMemberWithSchemeRolesList _, err := s.GetReplica().Select(&dbMembers, ChannelMembersWithSchemeSelectQuery+"WHERE ChannelMembers.UserId = :UserId AND (Teams.Id = :TeamId OR Teams.Id = '' OR Teams.Id IS NULL)", map[string]interface{}{"TeamId": teamId, "UserId": userId}) if err != nil { @@ -2398,7 +2398,7 @@ func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) (*model return dbMembers.ToModel(), nil } -func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (*model.ChannelMembers, error) { +func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (model.ChannelMembers, error) { var dbMembers channelMemberWithSchemeRolesList offset := page * perPage _, err := s.GetReplica().Select(&dbMembers, ChannelMembersWithSchemeSelectQuery+"WHERE ChannelMembers.UserId = :UserId Limit :Limit Offset :Offset", map[string]interface{}{"TeamId": teamId, "UserId": userId, "Limit": perPage, "Offset": offset}) @@ -2410,7 +2410,7 @@ func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, return dbMembers.ToModel(), nil } -func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (model.ChannelList, error) { deleteFilter := "AND Channels.DeleteAt = 0" if includeDeleted { deleteFilter = "" @@ -2451,10 +2451,10 @@ func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeD sort.Slice(channels, func(a, b int) bool { return strings.ToLower(channels[a].DisplayName) < strings.ToLower(channels[b].DisplayName) }) - return &channels, nil + return channels, nil } -func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (model.ChannelList, error) { deleteFilter := "AND DeleteAt = 0" if includeDeleted { deleteFilter = "" @@ -2503,7 +2503,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin sort.Slice(channels, func(a, b int) bool { return strings.ToLower(channels[a].DisplayName) < strings.ToLower(channels[b].DisplayName) }) - return &channels, nil + return channels, nil } func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string, term string) ([]*model.Channel, error) { @@ -2548,7 +2548,7 @@ func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string return channels, nil } -func (s SqlChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s SqlChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (model.ChannelList, error) { deleteFilter := "AND c.DeleteAt = 0" if includeDeleted { deleteFilter = "" @@ -2572,7 +2572,7 @@ func (s SqlChannelStore) SearchInTeam(teamId string, term string, includeDeleted }) } -func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) { +func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (model.ChannelList, error) { publicChannels, publicErr := s.performSearch(` SELECT Channels.* @@ -2621,13 +2621,13 @@ func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId return nil, outputErr } - output := *publicChannels - output = append(output, *privateChannels...) + output := publicChannels + output = append(output, privateChannels...) - return &output, nil + return output, nil } -func (s SqlChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s SqlChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (model.ChannelList, error) { deleteFilter := "AND c.DeleteAt = 0" if includeDeleted { deleteFilter = "" @@ -2758,7 +2758,7 @@ func (s SqlChannelStore) channelSearchQuery(opts *store.ChannelSearchOpts) sq.Se return query } -func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) { +func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, error) { opts.Term = term opts.IncludeTeamInfo = true queryString, args, err := s.channelSearchQuery(&opts).ToSql() @@ -2786,10 +2786,10 @@ func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearch totalCount = int64(len(channels)) } - return &channels, totalCount, nil + return channels, totalCount, nil } -func (s SqlChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error) { +func (s SqlChannelStore) SearchMore(userId string, teamId string, term string) (model.ChannelList, error) { return s.performSearch(` SELECT Channels.* @@ -2882,7 +2882,7 @@ func (s SqlChannelStore) buildFulltextClause(term string, searchColumns string) return } -func (s SqlChannelStore) performSearch(searchQuery string, term string, parameters map[string]interface{}) (*model.ChannelList, error) { +func (s SqlChannelStore) performSearch(searchQuery string, term string, parameters map[string]interface{}) (model.ChannelList, error) { likeClause, likeTerm := s.buildLIKEClause(term, "c.Name, c.DisplayName, c.Purpose") if likeTerm == "" { // If the likeTerm is empty after preparing, then don't bother searching. @@ -2900,7 +2900,7 @@ func (s SqlChannelStore) performSearch(searchQuery string, term string, paramete return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term) } - return &channels, nil + return channels, nil } func (s SqlChannelStore) getSearchGroupChannelsQuery(userId, term string, isPostgreSQL bool) (string, map[string]interface{}) { @@ -2991,7 +2991,7 @@ func (s SqlChannelStore) getSearchGroupChannelsQuery(userId, term string, isPost return query, args } -func (s SqlChannelStore) SearchGroupChannels(userId, term string) (*model.ChannelList, error) { +func (s SqlChannelStore) SearchGroupChannels(userId, term string) (model.ChannelList, error) { isPostgreSQL := s.DriverName() == model.DatabaseDriverPostgres queryString, args := s.getSearchGroupChannelsQuery(userId, term, isPostgreSQL) @@ -2999,10 +2999,10 @@ func (s SqlChannelStore) SearchGroupChannels(userId, term string) (*model.Channe if _, err := s.GetReplica().Select(&groupChannels, queryString, args); err != nil { return nil, errors.Wrapf(err, "failed to find Channels with term='%s' and userId=%s", term, userId) } - return &groupChannels, nil + return groupChannels, nil } -func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error) { +func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) (model.ChannelMembers, error) { var dbMembers channelMemberWithSchemeRolesList keys, props := MapStringsToQueryParams(userIds, "User") @@ -3015,7 +3015,7 @@ func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) (*m return dbMembers.ToModel(), nil } -func (s SqlChannelStore) GetMembersByChannelIds(channelIds []string, userId string) (*model.ChannelMembers, error) { +func (s SqlChannelStore) GetMembersByChannelIds(channelIds []string, userId string) (model.ChannelMembers, error) { var dbMembers channelMemberWithSchemeRolesList keys, props := MapStringsToQueryParams(channelIds, "Channel") diff --git a/store/sqlstore/channel_store_categories.go b/store/sqlstore/channel_store_categories.go index 1c6496b5ed3..b129793c90c 100644 --- a/store/sqlstore/channel_store_categories.go +++ b/store/sqlstore/channel_store_categories.go @@ -767,14 +767,14 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori // UpdateSidebarChannelsByPreferences is called when the Preference table is being updated to keep SidebarCategories in sync // At the moment, it's only handling Favorites and NOT DMs/GMs (those will be handled client side) -func (s SqlChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s SqlChannelStore) UpdateSidebarChannelsByPreferences(preferences model.Preferences) error { transaction, err := s.GetMaster().Begin() if err != nil { return errors.Wrap(err, "UpdateSidebarChannelsByPreferences: begin_transaction") } defer finalizeTransaction(transaction) - for _, preference := range *preferences { + for _, preference := range preferences { preference := preference if preference.Category != model.PreferenceCategoryFavoriteChannel { @@ -918,14 +918,14 @@ func (s SqlChannelStore) addChannelToFavoritesCategoryT(transaction *gorp.Transa // DeleteSidebarChannelsByPreferences is called when the Preference table is being updated to keep SidebarCategories in sync // At the moment, it's only handling Favorites and NOT DMs/GMs (those will be handled client side) -func (s SqlChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s SqlChannelStore) DeleteSidebarChannelsByPreferences(preferences model.Preferences) error { transaction, err := s.GetMaster().Begin() if err != nil { return errors.Wrap(err, "DeleteSidebarChannelsByPreferences: begin_transaction") } defer finalizeTransaction(transaction) - for _, preference := range *preferences { + for _, preference := range preferences { preference := preference if preference.Category != model.PreferenceCategoryFavoriteChannel { diff --git a/store/sqlstore/integrity_test.go b/store/sqlstore/integrity_test.go index 51d3f0263f5..a26bddace77 100644 --- a/store/sqlstore/integrity_test.go +++ b/store/sqlstore/integrity_test.go @@ -194,7 +194,7 @@ func createPostWithUserId(ss store.Store, id string) *model.Post { return createPost(ss, model.NewId(), id, "", "") } -func createPreferences(ss store.Store, userId string) *model.Preferences { +func createPreferences(ss store.Store, userId string) model.Preferences { preferences := model.Preferences{ { UserId: userId, @@ -203,8 +203,8 @@ func createPreferences(ss store.Store, userId string) *model.Preferences { Value: "somevalue", }, } - ss.Preference().Save(&preferences) - return &preferences + ss.Preference().Save(preferences) + return preferences } func createReaction(ss store.Store, userId, postId string) *model.Reaction { diff --git a/store/sqlstore/preference_store.go b/store/sqlstore/preference_store.go index 5ccd0591d24..c4b7f0d5a5b 100644 --- a/store/sqlstore/preference_store.go +++ b/store/sqlstore/preference_store.go @@ -50,7 +50,7 @@ func (s SqlPreferenceStore) deleteUnusedFeatures() { } } -func (s SqlPreferenceStore) Save(preferences *model.Preferences) error { +func (s SqlPreferenceStore) Save(preferences model.Preferences) error { // wrap in a transaction so that if one fails, everything fails transaction, err := s.GetMaster().Begin() if err != nil { @@ -58,7 +58,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) error { } defer finalizeTransaction(transaction) - for _, preference := range *preferences { + for _, preference := range preferences { preference := preference if upsertErr := s.save(transaction, &preference); upsertErr != nil { return upsertErr diff --git a/store/sqlstore/preference_store_test.go b/store/sqlstore/preference_store_test.go index 8241853fae3..c97f84cffc5 100644 --- a/store/sqlstore/preference_store_test.go +++ b/store/sqlstore/preference_store_test.go @@ -52,7 +52,7 @@ func TestDeleteUnusedFeatures(t *testing.T) { }, } - err := ss.Preference().Save(&features) + err := ss.Preference().Save(features) require.NoError(t, err) ss.Preference().(*SqlPreferenceStore).deleteUnusedFeatures() diff --git a/store/sqlstore/product_notices_store.go b/store/sqlstore/product_notices_store.go index a9b9e3b7c03..0e04ab51f1f 100644 --- a/store/sqlstore/product_notices_store.go +++ b/store/sqlstore/product_notices_store.go @@ -42,9 +42,9 @@ func (s SqlProductNoticesStore) Clear(notices []string) error { return nil } -func (s SqlProductNoticesStore) ClearOldNotices(currentNotices *model.ProductNotices) error { +func (s SqlProductNoticesStore) ClearOldNotices(currentNotices model.ProductNotices) error { var notices []string - for _, currentNotice := range *currentNotices { + for _, currentNotice := range currentNotices { notices = append(notices, currentNotice.ID) } sql, args, _ := s.getQueryBuilder().Delete("ProductNoticeViewState").Where(sq.NotEq{"NoticeId": notices}).ToSql() diff --git a/store/sqlstore/upgrade.go b/store/sqlstore/upgrade.go index 9343db541b2..23205eae00d 100644 --- a/store/sqlstore/upgrade.go +++ b/store/sqlstore/upgrade.go @@ -329,7 +329,7 @@ func upgradeDatabaseToVersion33(sqlStore *SqlStore) { data[i].Value = strings.Replace(data[i].Value, "solarized_", "solarized-", -1) } - sqlStore.Preference().Save(&data) + sqlStore.Preference().Save(data) } } diff --git a/store/sqlstore/upgrade_test.go b/store/sqlstore/upgrade_test.go index 1e2dcfbd611..9a358ddb321 100644 --- a/store/sqlstore/upgrade_test.go +++ b/store/sqlstore/upgrade_test.go @@ -241,7 +241,7 @@ func TestMsgCountRootMigration(t *testing.T) { members, err := ss.Channel().GetMembersByIds(channel.Id, userIds) require.NoError(t, err) - for _, m := range *members { + for _, m := range members { for i, uid := range userIds { if m.UserId == uid { assert.Equal(t, testChannel.ExpectedMembershipMsgCountRoot[i], m.MsgCountRoot) diff --git a/store/store.go b/store/store.go index f430c8281bc..4d2bbdb1461 100644 --- a/store/store.go +++ b/store/store.go @@ -177,16 +177,16 @@ type ChannelStore interface { GetByNames(team_id string, names []string, allowFromCache bool) ([]*model.Channel, error) GetByNameIncludeDeleted(team_id string, name string, allowFromCache bool) (*model.Channel, error) GetDeletedByName(team_id string, name string) (*model.Channel, error) - GetDeleted(team_id string, offset int, limit int, userID string) (*model.ChannelList, error) - GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) - GetAllChannels(page, perPage int, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, error) + GetDeleted(team_id string, offset int, limit int, userID string) (model.ChannelList, error) + GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, error) + GetAllChannels(page, perPage int, opts ChannelSearchOpts) (model.ChannelListWithTeamData, error) GetAllChannelsCount(opts ChannelSearchOpts) (int64, error) - GetMoreChannels(teamID string, userID string, offset int, limit int) (*model.ChannelList, error) - GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) - GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) - GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, error) + GetMoreChannels(teamID string, userID string, offset int, limit int) (model.ChannelList, error) + GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) + GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) + GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (model.ChannelList, error) GetChannelCounts(teamID string, userID string) (*model.ChannelCounts, error) - GetTeamChannels(teamID string) (*model.ChannelList, error) + GetTeamChannels(teamID string) (model.ChannelList, error) GetAll(teamID string) ([]*model.Channel, error) GetChannelsByIds(channelIds []string, includeDeleted bool) ([]*model.Channel, error) GetForPost(postID string) (*model.Channel, error) @@ -194,7 +194,7 @@ type ChannelStore interface { SaveMember(member *model.ChannelMember) (*model.ChannelMember, error) UpdateMember(member *model.ChannelMember) (*model.ChannelMember, error) UpdateMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) - GetMembers(channelID string, offset, limit int) (*model.ChannelMembers, error) + GetMembers(channelID string, offset, limit int) (model.ChannelMembers, error) GetMember(ctx context.Context, channelID string, userID string) (*model.ChannelMember, error) GetChannelMembersTimezones(channelID string) ([]model.StringMap, error) GetAllChannelMembersForUser(userID string, allowFromCache bool, includeDeleted bool) (map[string]string, error) @@ -221,18 +221,18 @@ type ChannelStore interface { CountPostsAfter(channelID string, timestamp int64, userID string) (int, int, error) IncrementMentionCount(channelID string, userID string, updateThreads, isRoot bool) error AnalyticsTypeCount(teamID string, channelType model.ChannelType) (int64, error) - GetMembersForUser(teamID string, userID string) (*model.ChannelMembers, error) - GetMembersForUserWithPagination(teamID, userID string, page, perPage int) (*model.ChannelMembers, error) - AutocompleteInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) - AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (*model.ChannelList, error) - SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) - SearchInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) - SearchArchivedInTeam(teamID string, term string, userID string) (*model.ChannelList, error) - SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (*model.ChannelList, error) - SearchMore(userID string, teamID string, term string) (*model.ChannelList, error) - SearchGroupChannels(userID, term string) (*model.ChannelList, error) - GetMembersByIds(channelID string, userIds []string) (*model.ChannelMembers, error) - GetMembersByChannelIds(channelIds []string, userID string) (*model.ChannelMembers, error) + GetMembersForUser(teamID string, userID string) (model.ChannelMembers, error) + GetMembersForUserWithPagination(teamID, userID string, page, perPage int) (model.ChannelMembers, error) + AutocompleteInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) + AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (model.ChannelList, error) + SearchAllChannels(term string, opts ChannelSearchOpts) (model.ChannelListWithTeamData, int64, error) + SearchInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) + SearchArchivedInTeam(teamID string, term string, userID string) (model.ChannelList, error) + SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (model.ChannelList, error) + SearchMore(userID string, teamID string, term string) (model.ChannelList, error) + SearchGroupChannels(userID, term string) (model.ChannelList, error) + GetMembersByIds(channelID string, userIds []string) (model.ChannelMembers, error) + GetMembersByChannelIds(channelIds []string, userID string) (model.ChannelMembers, error) AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error) GetChannelUnread(channelID, userID string) (*model.ChannelUnread, error) ClearCaches() @@ -248,8 +248,8 @@ type ChannelStore interface { CreateSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) UpdateSidebarCategoryOrder(userID, teamID string, categoryOrder []string) error UpdateSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) - UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error - DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error + UpdateSidebarChannelsByPreferences(preferences model.Preferences) error + DeleteSidebarChannelsByPreferences(preferences model.Preferences) error DeleteSidebarCategory(categoryID string) error GetAllChannelsForExportAfter(limit int, afterID string) ([]*model.ChannelForExport, error) GetAllDirectChannelsForExportAfter(limit int, afterID string) ([]*model.DirectChannelForExport, error) @@ -574,7 +574,7 @@ type CommandWebhookStore interface { } type PreferenceStore interface { - Save(preferences *model.Preferences) error + Save(preferences model.Preferences) error GetCategory(userID string, category string) (model.Preferences, error) Get(userID string, category string, name string) (*model.Preference, error) GetAll(userID string) (model.Preferences, error) @@ -746,7 +746,7 @@ type TermsOfServiceStore interface { type ProductNoticesStore interface { View(userID string, notices []string) error Clear(notices []string) error - ClearOldNotices(currentNotices *model.ProductNotices) error + ClearOldNotices(currentNotices model.ProductNotices) error GetViews(userID string) ([]model.ProductNoticeViewState, error) } diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index d916de976be..943e505d860 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -30,7 +30,7 @@ type SqlStore interface { func cleanupChannels(t *testing.T, ss store.Store) { list, err := ss.Channel().GetAllChannels(0, 100000, store.ChannelSearchOpts{IncludeDeleted: true}) require.NoError(t, err, "error cleaning all channels", err) - for _, channel := range *list { + for _, channel := range list { err = ss.Channel().PermanentDelete(channel.Id) assert.NoError(t, err) } @@ -206,7 +206,7 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlStore) members, nErr := ss.Channel().GetMembers(o1.Id, 0, 100) require.NoError(t, nErr) - require.Len(t, *members, 2, "should have saved 2 members") + require.Len(t, members, 2, "should have saved 2 members") _, nErr = ss.Channel().SaveDirectChannel(&o1, &m1, &m2) require.Error(t, nErr, "shoudn't be a able to update from save") @@ -242,7 +242,7 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlStore) members, nErr = ss.Channel().GetMembers(o1.Id, 0, 100) require.NoError(t, nErr) - require.Len(t, *members, 1, "should have saved just 1 member") + require.Len(t, members, 1, "should have saved just 1 member") // Manually truncate Channels table until testlib can handle cleanups s.GetMaster().Exec("TRUNCATE Channels") @@ -274,7 +274,7 @@ func testChannelStoreCreateDirectChannel(t *testing.T, ss store.Store) { members, nErr := ss.Channel().GetMembers(c1.Id, 0, 100) require.NoError(t, nErr) - require.Len(t, *members, 2, "should have saved 2 members") + require.Len(t, members, 2, "should have saved 2 members") } func testChannelStoreUpdate(t *testing.T, ss store.Store) { @@ -432,7 +432,7 @@ func testChannelStoreGet(t *testing.T, ss store.Store, s SqlStore) { channelsTeam, err := ss.Channel().GetTeamChannels(o1.TeamId) require.NoError(t, err, err) - require.Greater(t, len(*channelsTeam), 0, "too little") + require.Greater(t, len(channelsTeam), 0, "too little") // Manually truncate Channels table until testlib can handle cleanups s.GetMaster().Exec("TRUNCATE Channels") @@ -623,11 +623,11 @@ func testChannelStoreDelete(t *testing.T, ss store.Store) { list, nErr := ss.Channel().GetChannels(o1.TeamId, m1.UserId, false, 0) require.NoError(t, nErr) - require.Len(t, *list, 1, "invalid number of channels") + require.Len(t, list, 1, "invalid number of channels") list, nErr = ss.Channel().GetMoreChannels(o1.TeamId, m1.UserId, 0, 100) require.NoError(t, nErr) - require.Len(t, *list, 1, "invalid number of channels") + require.Len(t, list, 1, "invalid number of channels") cresult := ss.Channel().PermanentDelete(o2.Id) require.NoError(t, cresult) @@ -637,7 +637,7 @@ func testChannelStoreDelete(t *testing.T, ss store.Store) { var nfErr *store.ErrNotFound require.True(t, errors.As(nErr, &nfErr)) } else { - require.Equal(t, &model.ChannelList{}, list) + require.Equal(t, model.ChannelList{}, list) } nErr = ss.Channel().PermanentDeleteByTeam(o1.TeamId) @@ -771,8 +771,8 @@ func testChannelStoreGetDeleted(t *testing.T, ss store.Store) { list, nErr := ss.Channel().GetDeleted(o1.TeamId, 0, 100, userId) require.NoError(t, nErr, nErr) - require.Len(t, *list, 1, "wrong list") - require.Equal(t, o1.Name, (*list)[0].Name, "missing channel") + require.Len(t, list, 1, "wrong list") + require.Equal(t, o1.Name, list[0].Name, "missing channel") o2 := model.Channel{} o2.TeamId = o1.TeamId @@ -784,7 +784,7 @@ func testChannelStoreGetDeleted(t *testing.T, ss store.Store) { list, nErr = ss.Channel().GetDeleted(o1.TeamId, 0, 100, userId) require.NoError(t, nErr, nErr) - require.Len(t, *list, 1, "wrong list") + require.Len(t, list, 1, "wrong list") o3 := model.Channel{} o3.TeamId = o1.TeamId @@ -800,15 +800,15 @@ func testChannelStoreGetDeleted(t *testing.T, ss store.Store) { list, nErr = ss.Channel().GetDeleted(o1.TeamId, 0, 100, userId) require.NoError(t, nErr, nErr) - require.Len(t, *list, 2, "wrong list length") + require.Len(t, list, 2, "wrong list length") list, nErr = ss.Channel().GetDeleted(o1.TeamId, 0, 1, userId) require.NoError(t, nErr, nErr) - require.Len(t, *list, 1, "wrong list length") + require.Len(t, list, 1, "wrong list length") list, nErr = ss.Channel().GetDeleted(o1.TeamId, 1, 1, userId) require.NoError(t, nErr, nErr) - require.Len(t, *list, 1, "wrong list length") + require.Len(t, list, 1, "wrong list length") } @@ -3177,10 +3177,10 @@ func testChannelStoreGetChannels(t *testing.T, ss store.Store) { list, nErr := ss.Channel().GetChannels(o1.TeamId, m1.UserId, false, 0) require.NoError(t, nErr) - require.Len(t, *list, 3) - require.Equal(t, o1.Id, (*list)[0].Id, "missing channel") - require.Equal(t, o2.Id, (*list)[1].Id, "missing channel") - require.Equal(t, o3.Id, (*list)[2].Id, "missing channel") + require.Len(t, list, 3) + require.Equal(t, o1.Id, list[0].Id, "missing channel") + require.Equal(t, o2.Id, list[1].Id, "missing channel") + require.Equal(t, o3.Id, list[2].Id, "missing channel") ids, err := ss.Channel().GetAllChannelMembersForUser(m1.UserId, false, false) require.NoError(t, err) @@ -3211,31 +3211,31 @@ func testChannelStoreGetChannels(t *testing.T, ss store.Store) { // should return 1 list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, false, 0) require.NoError(t, nErr) - require.Len(t, *list, 1) - require.Equal(t, o1.Id, (*list)[0].Id, "missing channel") + require.Len(t, list, 1) + require.Equal(t, o1.Id, list[0].Id, "missing channel") // Should return all list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, true, 0) require.NoError(t, nErr) - require.Len(t, *list, 3) - require.Equal(t, o1.Id, (*list)[0].Id, "missing channel") - require.Equal(t, o2.Id, (*list)[1].Id, "missing channel") - require.Equal(t, o3.Id, (*list)[2].Id, "missing channel") + require.Len(t, list, 3) + require.Equal(t, o1.Id, list[0].Id, "missing channel") + require.Equal(t, o2.Id, list[1].Id, "missing channel") + require.Equal(t, o3.Id, list[2].Id, "missing channel") // Should still return all list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, true, 10) require.NoError(t, nErr) - require.Len(t, *list, 3) - require.Equal(t, o1.Id, (*list)[0].Id, "missing channel") - require.Equal(t, o2.Id, (*list)[1].Id, "missing channel") - require.Equal(t, o3.Id, (*list)[2].Id, "missing channel") + require.Len(t, list, 3) + require.Equal(t, o1.Id, list[0].Id, "missing channel") + require.Equal(t, o2.Id, list[1].Id, "missing channel") + require.Equal(t, o3.Id, list[2].Id, "missing channel") // Should return 2 list, nErr = ss.Channel().GetChannels(o1.TeamId, m1.UserId, true, 20) require.NoError(t, nErr) - require.Len(t, *list, 2) - require.Equal(t, o1.Id, (*list)[0].Id, "missing channel") - require.Equal(t, o3.Id, (*list)[1].Id, "missing channel") + require.Len(t, list, 2) + require.Equal(t, o1.Id, list[0].Id, "missing channel") + require.Equal(t, o3.Id, list[1].Id, "missing channel") require.True( t, @@ -3335,22 +3335,22 @@ func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlStore) { list, nErr := ss.Channel().GetAllChannels(0, 10, store.ChannelSearchOpts{}) require.NoError(t, nErr) - assert.Len(t, *list, 2) - assert.Equal(t, c1.Id, (*list)[0].Id) - assert.Equal(t, "Name", (*list)[0].TeamDisplayName) - assert.Equal(t, c3.Id, (*list)[1].Id) - assert.Equal(t, "Name2", (*list)[1].TeamDisplayName) + assert.Len(t, list, 2) + assert.Equal(t, c1.Id, list[0].Id) + assert.Equal(t, "Name", list[0].TeamDisplayName) + assert.Equal(t, c3.Id, list[1].Id) + assert.Equal(t, "Name2", list[1].TeamDisplayName) count1, nErr := ss.Channel().GetAllChannelsCount(store.ChannelSearchOpts{}) require.NoError(t, nErr) list, nErr = ss.Channel().GetAllChannels(0, 10, store.ChannelSearchOpts{IncludeDeleted: true}) require.NoError(t, nErr) - assert.Len(t, *list, 3) - assert.Equal(t, c1.Id, (*list)[0].Id) - assert.Equal(t, "Name", (*list)[0].TeamDisplayName) - assert.Equal(t, c2.Id, (*list)[1].Id) - assert.Equal(t, c3.Id, (*list)[2].Id) + assert.Len(t, list, 3) + assert.Equal(t, c1.Id, list[0].Id) + assert.Equal(t, "Name", list[0].TeamDisplayName) + assert.Equal(t, c2.Id, list[1].Id) + assert.Equal(t, c3.Id, list[2].Id) count2, nErr := ss.Channel().GetAllChannelsCount(store.ChannelSearchOpts{IncludeDeleted: true}) require.NoError(t, nErr) @@ -3360,19 +3360,19 @@ func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlStore) { list, nErr = ss.Channel().GetAllChannels(0, 1, store.ChannelSearchOpts{IncludeDeleted: true}) require.NoError(t, nErr) - assert.Len(t, *list, 1) - assert.Equal(t, c1.Id, (*list)[0].Id) - assert.Equal(t, "Name", (*list)[0].TeamDisplayName) + assert.Len(t, list, 1) + assert.Equal(t, c1.Id, list[0].Id) + assert.Equal(t, "Name", list[0].TeamDisplayName) // Not associated to group list, nErr = ss.Channel().GetAllChannels(0, 10, store.ChannelSearchOpts{NotAssociatedToGroup: group.Id}) require.NoError(t, nErr) - assert.Len(t, *list, 1) + assert.Len(t, list, 1) // Exclude channel names list, nErr = ss.Channel().GetAllChannels(0, 10, store.ChannelSearchOpts{ExcludeChannelNames: []string{c1.Name}}) require.NoError(t, nErr) - assert.Len(t, *list, 1) + assert.Len(t, list, 1) // Exclude policy constrained policy, nErr := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{ @@ -3385,21 +3385,21 @@ func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlStore) { require.NoError(t, nErr) list, nErr = ss.Channel().GetAllChannels(0, 10, store.ChannelSearchOpts{ExcludePolicyConstrained: true}) require.NoError(t, nErr) - assert.Len(t, *list, 1) - assert.Equal(t, c3.Id, (*list)[0].Id) + assert.Len(t, list, 1) + assert.Equal(t, c3.Id, list[0].Id) // Without the policy ID list, nErr = ss.Channel().GetAllChannels(0, 1, store.ChannelSearchOpts{}) require.NoError(t, nErr) - assert.Len(t, *list, 1) - assert.Equal(t, c1.Id, (*list)[0].Id) - assert.Nil(t, (*list)[0].PolicyID) + assert.Len(t, list, 1) + assert.Equal(t, c1.Id, list[0].Id) + assert.Nil(t, list[0].PolicyID) // With the policy ID list, nErr = ss.Channel().GetAllChannels(0, 1, store.ChannelSearchOpts{IncludePolicyID: true}) require.NoError(t, nErr) - assert.Len(t, *list, 1) - assert.Equal(t, c1.Id, (*list)[0].Id) - assert.Equal(t, *(*list)[0].PolicyID, policy.ID) + assert.Len(t, list, 1) + assert.Equal(t, c1.Id, list[0].Id) + assert.Equal(t, *list[0].PolicyID, policy.ID) // Manually truncate Channels table until testlib can handle cleanups s.GetMaster().Exec("TRUNCATE Channels") @@ -3494,7 +3494,7 @@ func testChannelStoreGetMoreChannels(t *testing.T, ss store.Store) { t.Run("only o3 listed in more channels", func(t *testing.T) { list, channelErr := ss.Channel().GetMoreChannels(teamId, userId, 0, 100) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&o3}, list) + require.Equal(t, model.ChannelList{&o3}, list) }) // o6 is another channel on the team to which the user does not belong, and would thus @@ -3525,19 +3525,19 @@ func testChannelStoreGetMoreChannels(t *testing.T, ss store.Store) { t.Run("both o3 and o6 listed in more channels", func(t *testing.T) { list, err := ss.Channel().GetMoreChannels(teamId, userId, 0, 100) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o3, &o6}, list) + require.Equal(t, model.ChannelList{&o3, &o6}, list) }) t.Run("only o3 listed in more channels with offset 0, limit 1", func(t *testing.T) { list, err := ss.Channel().GetMoreChannels(teamId, userId, 0, 1) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o3}, list) + require.Equal(t, model.ChannelList{&o3}, list) }) t.Run("only o6 listed in more channels with offset 1, limit 1", func(t *testing.T) { list, err := ss.Channel().GetMoreChannels(teamId, userId, 1, 1) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o6}, list) + require.Equal(t, model.ChannelList{&o6}, list) }) t.Run("verify analytics for open channels", func(t *testing.T) { @@ -3589,7 +3589,7 @@ func testChannelStoreGetPrivateChannelsForTeam(t *testing.T, ss store.Store) { t.Run("only p1 initially listed in private channels", func(t *testing.T) { list, channelErr := ss.Channel().GetPrivateChannelsForTeam(teamId, 0, 100) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&p1}, list) + require.Equal(t, model.ChannelList{&p1}, list) }) // p3 is another private channel on the team @@ -3617,19 +3617,19 @@ func testChannelStoreGetPrivateChannelsForTeam(t *testing.T, ss store.Store) { t.Run("both p1 and p3 listed in private channels", func(t *testing.T) { list, err := ss.Channel().GetPrivateChannelsForTeam(teamId, 0, 100) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&p1, &p3}, list) + require.Equal(t, model.ChannelList{&p1, &p3}, list) }) t.Run("only p1 listed in private channels with offset 0, limit 1", func(t *testing.T) { list, err := ss.Channel().GetPrivateChannelsForTeam(teamId, 0, 1) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&p1}, list) + require.Equal(t, model.ChannelList{&p1}, list) }) t.Run("only p3 listed in private channels with offset 1, limit 1", func(t *testing.T) { list, err := ss.Channel().GetPrivateChannelsForTeam(teamId, 1, 1) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&p3}, list) + require.Equal(t, model.ChannelList{&p3}, list) }) t.Run("verify analytics for private channels", func(t *testing.T) { @@ -3681,7 +3681,7 @@ func testChannelStoreGetPublicChannelsForTeam(t *testing.T, ss store.Store) { t.Run("only o1 initially listed in public channels", func(t *testing.T) { list, channelErr := ss.Channel().GetPublicChannelsForTeam(teamId, 0, 100) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&o1}, list) + require.Equal(t, model.ChannelList{&o1}, list) }) // o4 is another public channel on the team @@ -3709,19 +3709,19 @@ func testChannelStoreGetPublicChannelsForTeam(t *testing.T, ss store.Store) { t.Run("both o1 and o4 listed in public channels", func(t *testing.T) { list, err := ss.Channel().GetPublicChannelsForTeam(teamId, 0, 100) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o1, &o4}, list) + require.Equal(t, model.ChannelList{&o1, &o4}, list) }) t.Run("only o1 listed in public channels with offset 0, limit 1", func(t *testing.T) { list, err := ss.Channel().GetPublicChannelsForTeam(teamId, 0, 1) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o1}, list) + require.Equal(t, model.ChannelList{&o1}, list) }) t.Run("only o4 listed in public channels with offset 1, limit 1", func(t *testing.T) { list, err := ss.Channel().GetPublicChannelsForTeam(teamId, 1, 1) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o4}, list) + require.Equal(t, model.ChannelList{&o4}, list) }) t.Run("verify analytics for open channels", func(t *testing.T) { @@ -3773,13 +3773,13 @@ func testChannelStoreGetPublicChannelsByIdsForTeam(t *testing.T, ss store.Store) t.Run("oc1 by itself should be found as a public channel in the team", func(t *testing.T) { list, channelErr := ss.Channel().GetPublicChannelsByIdsForTeam(teamId, []string{oc1.Id}) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&oc1}, list) + require.Equal(t, model.ChannelList{&oc1}, list) }) t.Run("only oc1, among others, should be found as a public channel in the team", func(t *testing.T) { list, channelErr := ss.Channel().GetPublicChannelsByIdsForTeam(teamId, []string{oc1.Id, oc2.Id, model.NewId(), pc3.Id}) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&oc1}, list) + require.Equal(t, model.ChannelList{&oc1}, list) }) // oc4 is another public channel on the team @@ -3808,7 +3808,7 @@ func testChannelStoreGetPublicChannelsByIdsForTeam(t *testing.T, ss store.Store) t.Run("only oc1 and oc4, among others, should be found as a public channel in the team", func(t *testing.T) { list, err := ss.Channel().GetPublicChannelsByIdsForTeam(teamId, []string{oc1.Id, oc2.Id, model.NewId(), pc3.Id, oc4.Id}) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&oc1, &oc4}, list) + require.Equal(t, model.ChannelList{&oc1, &oc4}, list) }) t.Run("random channel id should not be found as a public channel in the team", func(t *testing.T) { @@ -3903,11 +3903,11 @@ func testChannelStoreGetMembersForUser(t *testing.T, ss store.Store) { require.NoError(t, err) t.Run("with channels", func(t *testing.T) { - var members *model.ChannelMembers + var members model.ChannelMembers members, err = ss.Channel().GetMembersForUser(o1.TeamId, m1.UserId) require.NoError(t, err) - assert.Len(t, *members, 2) + assert.Len(t, members, 2) }) t.Run("with channels and direct messages", func(t *testing.T) { @@ -3924,11 +3924,11 @@ func testChannelStoreGetMembersForUser(t *testing.T, ss store.Store) { _, nErr = ss.Channel().CreateDirectChannel(&u3, &u4) require.NoError(t, nErr) - var members *model.ChannelMembers + var members model.ChannelMembers members, err = ss.Channel().GetMembersForUser(o1.TeamId, m1.UserId) require.NoError(t, err) - assert.Len(t, *members, 4) + assert.Len(t, members, 4) }) t.Run("with channels, direct channels and group messages", func(t *testing.T) { @@ -3952,11 +3952,11 @@ func testChannelStoreGetMembersForUser(t *testing.T, ss store.Store) { _, err = ss.Channel().SaveMember(cm) require.NoError(t, err) } - var members *model.ChannelMembers + var members model.ChannelMembers members, err = ss.Channel().GetMembersForUser(o1.TeamId, m1.UserId) require.NoError(t, err) - assert.Len(t, *members, 5) + assert.Len(t, members, 5) }) } @@ -4001,11 +4001,11 @@ func testChannelStoreGetMembersForUserWithPagination(t *testing.T, ss store.Stor members, err := ss.Channel().GetMembersForUserWithPagination(o1.TeamId, m1.UserId, 0, 1) require.NoError(t, err) - assert.Len(t, *members, 1) + assert.Len(t, members, 1) members, err = ss.Channel().GetMembersForUserWithPagination(o1.TeamId, m1.UserId, 1, 1) require.NoError(t, err) - assert.Len(t, *members, 1) + assert.Len(t, members, 1) } func testCountPostsAfter(t *testing.T, ss store.Store) { @@ -4940,31 +4940,31 @@ func testChannelStoreSearchMore(t *testing.T, ss store.Store) { t.Run("three public channels matching 'ChannelA', but already a member of one and one deleted", func(t *testing.T) { channels, err := ss.Channel().SearchMore(m1.UserId, teamId, "ChannelA") require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o3}, channels) + require.Equal(t, model.ChannelList{&o3}, channels) }) t.Run("one public channels, but already a member", func(t *testing.T) { channels, err := ss.Channel().SearchMore(m1.UserId, teamId, o4.Name) require.NoError(t, err) - require.Equal(t, &model.ChannelList{}, channels) + require.Equal(t, model.ChannelList{}, channels) }) t.Run("three matching channels, but only two public", func(t *testing.T) { channels, err := ss.Channel().SearchMore(m1.UserId, teamId, "off-") require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o7, &o6}, channels) + require.Equal(t, model.ChannelList{&o7, &o6}, channels) }) t.Run("one channel matching 'off-topic'", func(t *testing.T) { channels, err := ss.Channel().SearchMore(m1.UserId, teamId, "off-topic") require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o6}, channels) + require.Equal(t, model.ChannelList{&o6}, channels) }) t.Run("search purpose", func(t *testing.T) { channels, err := ss.Channel().SearchMore(m1.UserId, teamId, "now searchable") require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o9}, channels) + require.Equal(t, model.ChannelList{&o9}, channels) }) } @@ -5159,23 +5159,23 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) { TeamId string Term string IncludeDeleted bool - ExpectedResults *model.ChannelList + ExpectedResults model.ChannelList }{ - {"ChannelA", teamId, "ChannelA", false, &model.ChannelList{&o1, &o3}}, - {"ChannelA, include deleted", teamId, "ChannelA", true, &model.ChannelList{&o1, &o3, &o13}}, - {"ChannelA, other team", otherTeamId, "ChannelA", false, &model.ChannelList{&o2}}, - {"empty string", teamId, "", false, &model.ChannelList{&o1, &o3, &o12, &o11, &o7, &o6, &o10, &o9}}, - {"no matches", teamId, "blargh", false, &model.ChannelList{}}, - {"prefix", teamId, "off-", false, &model.ChannelList{&o7, &o6}}, - {"full match with dash", teamId, "off-topic", false, &model.ChannelList{&o6}}, - {"town square", teamId, "town square", false, &model.ChannelList{&o9}}, - {"the in name", teamId, "thename", false, &model.ChannelList{&o10}}, - {"Mobile", teamId, "Mobile", false, &model.ChannelList{&o11}}, - {"search purpose", teamId, "now searchable", false, &model.ChannelList{&o12}}, - {"pipe ignored", teamId, "town square |", false, &model.ChannelList{&o9}}, + {"ChannelA", teamId, "ChannelA", false, model.ChannelList{&o1, &o3}}, + {"ChannelA, include deleted", teamId, "ChannelA", true, model.ChannelList{&o1, &o3, &o13}}, + {"ChannelA, other team", otherTeamId, "ChannelA", false, model.ChannelList{&o2}}, + {"empty string", teamId, "", false, model.ChannelList{&o1, &o3, &o12, &o11, &o7, &o6, &o10, &o9}}, + {"no matches", teamId, "blargh", false, model.ChannelList{}}, + {"prefix", teamId, "off-", false, model.ChannelList{&o7, &o6}}, + {"full match with dash", teamId, "off-topic", false, model.ChannelList{&o6}}, + {"town square", teamId, "town square", false, model.ChannelList{&o9}}, + {"the in name", teamId, "thename", false, model.ChannelList{&o10}}, + {"Mobile", teamId, "Mobile", false, model.ChannelList{&o11}}, + {"search purpose", teamId, "now searchable", false, model.ChannelList{&o12}}, + {"pipe ignored", teamId, "town square |", false, model.ChannelList{&o9}}, } - for name, search := range map[string]func(teamId string, term string, includeDeleted bool) (*model.ChannelList, error){ + for name, search := range map[string]func(teamId string, term string, includeDeleted bool) (model.ChannelList, error){ "AutocompleteInTeam": ss.Channel().AutocompleteInTeam, "SearchInTeam": ss.Channel().SearchInTeam, } { @@ -5186,7 +5186,7 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) { // AutoCompleteInTeam doesn't currently sort its output results. if name == "AutocompleteInTeam" { - sort.Sort(ByChannelDisplayName(*channels)) + sort.Sort(ByChannelDisplayName(channels)) } require.Equal(t, testCase.ExpectedResults, channels) @@ -5259,10 +5259,10 @@ func testChannelStoreSearchForUserInTeam(t *testing.T, ss store.Store) { searchAndCheck := func(t *testing.T, term string, includeDeleted bool, expectedDisplayNames []string) { res, searchErr := ss.Channel().SearchForUserInTeam(userId, teamId, term, includeDeleted) require.NoError(t, searchErr) - require.Len(t, *res, len(expectedDisplayNames)) + require.Len(t, res, len(expectedDisplayNames)) resultDisplayNames := []string{} - for _, c := range *res { + for _, c := range res { resultDisplayNames = append(resultDisplayNames, c.DisplayName) } require.ElementsMatch(t, expectedDisplayNames, resultDisplayNames) @@ -5502,54 +5502,54 @@ func testChannelStoreSearchAllChannels(t *testing.T, ss store.Store) { Description string Term string Opts store.ChannelSearchOpts - ExpectedResults *model.ChannelList + ExpectedResults model.ChannelList TotalCount int }{ - {"Search FooBar by display name", "bardisplay", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o14}, 1}, - {"Search FooBar by display name2", "foobar", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o14}, 1}, - {"Search FooBar by display name3", "displayname", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o14}, 1}, - {"Search FooBar by name", "what", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o14}, 1}, - {"Search FooBar by name2", "ever", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o14}, 1}, - {"ChannelA", "ChannelA", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o1, &o2, &o3}, 0}, - {"ChannelA, include deleted", "ChannelA", store.ChannelSearchOpts{IncludeDeleted: true}, &model.ChannelList{&o1, &o2, &o3, &o13}, 0}, - {"empty string", "", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o1, &o2, &o3, &o4, &o5, &o6, &o7, &o8, &o9, &o10, &o11, &o12, &o14}, 0}, - {"no matches", "blargh", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{}, 0}, - {"prefix", "off-", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o6, &o7, &o8}, 0}, - {"full match with dash", "off-topic", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o6}, 0}, - {"town square", "town square", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o9}, 0}, - {"which in name", "which", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o10}, 0}, - {"Mobile", "Mobile", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o11}, 0}, - {"search purpose", "now searchable", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o12}, 0}, - {"pipe ignored", "town square |", store.ChannelSearchOpts{IncludeDeleted: false}, &model.ChannelList{&o9}, 0}, - {"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}, - {"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}, - {"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 FooBar by display name", "bardisplay", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o14}, 1}, + {"Search FooBar by display name2", "foobar", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o14}, 1}, + {"Search FooBar by display name3", "displayname", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o14}, 1}, + {"Search FooBar by name", "what", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o14}, 1}, + {"Search FooBar by name2", "ever", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o14}, 1}, + {"ChannelA", "ChannelA", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o1, &o2, &o3}, 0}, + {"ChannelA, include deleted", "ChannelA", store.ChannelSearchOpts{IncludeDeleted: true}, model.ChannelList{&o1, &o2, &o3, &o13}, 0}, + {"empty string", "", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o1, &o2, &o3, &o4, &o5, &o6, &o7, &o8, &o9, &o10, &o11, &o12, &o14}, 0}, + {"no matches", "blargh", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{}, 0}, + {"prefix", "off-", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o6, &o7, &o8}, 0}, + {"full match with dash", "off-topic", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o6}, 0}, + {"town square", "town square", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o9}, 0}, + {"which in name", "which", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o10}, 0}, + {"Mobile", "Mobile", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o11}, 0}, + {"search purpose", "now searchable", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o12}, 0}, + {"pipe ignored", "town square |", store.ChannelSearchOpts{IncludeDeleted: false}, model.ChannelList{&o9}, 0}, + {"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}, + {"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}, + {"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}, } for _, testCase := range testCases { t.Run(testCase.Description, func(t *testing.T) { channels, count, err := ss.Channel().SearchAllChannels(testCase.Term, testCase.Opts) require.NoError(t, err) - require.Equal(t, len(*testCase.ExpectedResults), len(*channels)) - for i, expected := range *testCase.ExpectedResults { - require.Equal(t, expected.Id, (*channels)[i].Id) + require.Equal(t, len(testCase.ExpectedResults), len(channels)) + for i, expected := range testCase.ExpectedResults { + require.Equal(t, expected.Id, channels[i].Id) } if testCase.Opts.Page != nil || testCase.Opts.PerPage != nil { require.Equal(t, int64(testCase.TotalCount), count) @@ -5571,10 +5571,10 @@ func testChannelStoreGetMembersByIds(t *testing.T, ss store.Store) { _, err := ss.Channel().SaveMember(m1) require.NoError(t, err) - var members *model.ChannelMembers + var members model.ChannelMembers members, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId}) require.NoError(t, nErr, nErr) - rm1 := (*members)[0] + rm1 := members[0] require.Equal(t, m1.ChannelId, rm1.ChannelId, "bad team id") require.Equal(t, m1.UserId, rm1.UserId, "bad user id") @@ -5585,7 +5585,7 @@ func testChannelStoreGetMembersByIds(t *testing.T, ss store.Store) { members, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId, m2.UserId, model.NewId()}) require.NoError(t, nErr, nErr) - require.Len(t, *members, 2, "return wrong number of results") + require.Len(t, members, 2, "return wrong number of results") _, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{}) require.Error(t, nErr, "empty user ids - should have failed") @@ -5628,24 +5628,24 @@ func testChannelStoreGetMembersByChannelIds(t *testing.T, ss store.Store) { t.Run("should return the user's members for the given channels", func(t *testing.T) { result, nErr := ss.Channel().GetMembersByChannelIds([]string{channel1.Id, channel2.Id}, userId) require.NoError(t, nErr) - assert.Len(t, *result, 2) + assert.Len(t, result, 2) - assert.Equal(t, userId, (*result)[0].UserId) - assert.True(t, (*result)[0].ChannelId == channel1.Id || (*result)[1].ChannelId == channel1.Id) - assert.Equal(t, userId, (*result)[1].UserId) - assert.True(t, (*result)[0].ChannelId == channel2.Id || (*result)[1].ChannelId == channel2.Id) + assert.Equal(t, userId, result[0].UserId) + assert.True(t, result[0].ChannelId == channel1.Id || result[1].ChannelId == channel1.Id) + assert.Equal(t, userId, result[1].UserId) + assert.True(t, result[0].ChannelId == channel2.Id || result[1].ChannelId == channel2.Id) }) t.Run("should not error or return anything for invalid channel IDs", func(t *testing.T) { result, nErr := ss.Channel().GetMembersByChannelIds([]string{model.NewId(), model.NewId()}, userId) require.NoError(t, nErr) - assert.Len(t, *result, 0) + assert.Len(t, result, 0) }) t.Run("should not error or return anything for invalid user IDs", func(t *testing.T) { result, nErr := ss.Channel().GetMembersByChannelIds([]string{channel1.Id, channel2.Id}, model.NewId()) require.NoError(t, nErr) - assert.Len(t, *result, 0) + assert.Len(t, result, 0) }) } @@ -5794,7 +5794,7 @@ func testChannelStoreSearchGroupChannels(t *testing.T, ss store.Store) { require.NoError(t, err) resultIds := []string{} - for _, gc := range *result { + for _, gc := range result { resultIds = append(resultIds, gc.Id) } @@ -6315,7 +6315,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) { t.Run("o1 and o2 initially listed in public channels", func(t *testing.T) { channels, channelErr := ss.Channel().SearchInTeam(teamId, "", true) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&o1, &o2}, channels) + require.Equal(t, model.ChannelList{&o1, &o2}, channels) }) o1.DeleteAt = model.GetMillis() @@ -6327,7 +6327,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) { t.Run("o1 still listed in public channels when marked as deleted", func(t *testing.T) { channels, channelErr := ss.Channel().SearchInTeam(teamId, "", true) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&o1, &o2}, channels) + require.Equal(t, model.ChannelList{&o1, &o2}, channels) }) ss.Channel().PermanentDelete(o1.Id) @@ -6335,7 +6335,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) { t.Run("o1 no longer listed in public channels when permanently deleted", func(t *testing.T) { channels, channelErr := ss.Channel().SearchInTeam(teamId, "", true) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&o2}, channels) + require.Equal(t, model.ChannelList{&o2}, channels) }) o2.Type = model.ChannelTypePrivate @@ -6345,7 +6345,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) { t.Run("o2 no longer listed since now private", func(t *testing.T) { channels, channelErr := ss.Channel().SearchInTeam(teamId, "", true) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{}, channels) + require.Equal(t, model.ChannelList{}, channels) }) o2.Type = model.ChannelTypeOpen @@ -6355,7 +6355,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) { t.Run("o2 listed once again since now public", func(t *testing.T) { channels, channelErr := ss.Channel().SearchInTeam(teamId, "", true) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&o2}, channels) + require.Equal(t, model.ChannelList{&o2}, channels) }) // o3 is a public channel on the team that already existed in the PublicChannels table. @@ -6411,7 +6411,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) { t.Run("verify o3 INSERT converted to UPDATE", func(t *testing.T) { channels, channelErr := ss.Channel().SearchInTeam(teamId, "", true) require.NoError(t, channelErr) - require.Equal(t, &model.ChannelList{&o2, &o3}, channels) + require.Equal(t, model.ChannelList{&o2, &o3}, channels) }) // o4 is a public channel on the team that existed in the Channels table but was omitted from the PublicChannels table. @@ -6442,7 +6442,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) { t.Run("verify o4 UPDATE converted to INSERT", func(t *testing.T) { channels, err := ss.Channel().SearchInTeam(teamId, "", true) require.NoError(t, err) - require.Equal(t, &model.ChannelList{&o2, &o3, &o4}, channels) + require.Equal(t, model.ChannelList{&o2, &o3, &o4}, channels) }) } @@ -6594,7 +6594,7 @@ func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store, s // Get all the channel members. Check there are 3. d1, err := ss.Channel().GetMembers(c1.Id, 0, 1000) assert.NoError(t, err) - assert.Len(t, *d1, 3) + assert.Len(t, d1, 3) // Deactivate users 1 & 2. u1.DeleteAt = model.GetMillis() @@ -6610,8 +6610,8 @@ func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store, s // Get all the channel members. Check there is now only 1: m3. d2, err := ss.Channel().GetMembers(c1.Id, 0, 1000) assert.NoError(t, err) - assert.Len(t, *d2, 1) - assert.Equal(t, u3.Id, (*d2)[0].UserId) + assert.Len(t, d2, 1) + assert.Equal(t, u3.Id, d2[0].UserId) // Manually truncate Channels table until testlib can handle cleanups s.GetMaster().Exec("TRUNCATE Channels") diff --git a/store/storetest/channel_store_categories.go b/store/storetest/channel_store_categories.go index a7874febb15..8ae188f52d4 100644 --- a/store/storetest/channel_store_categories.go +++ b/store/storetest/channel_store_categories.go @@ -165,7 +165,7 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) { }) require.NoError(t, err) - nErr = ss.Preference().Save(&model.Preferences{ + nErr = ss.Preference().Save(model.Preferences{ { UserId: userId, Category: model.PreferenceCategoryFavoriteChannel, @@ -223,7 +223,7 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) { }) require.NoError(t, err) - nErr = ss.Preference().Save(&model.Preferences{ + nErr = ss.Preference().Save(model.Preferences{ { UserId: userId, Category: model.PreferenceCategoryFavoriteChannel, @@ -292,7 +292,7 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) { ) require.NoError(t, err) - err = ss.Preference().Save(&model.Preferences{ + err = ss.Preference().Save(model.Preferences{ { UserId: userId, Category: model.PreferenceCategoryFavoriteChannel, @@ -336,7 +336,7 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) { }) require.NoError(t, err) - nErr = ss.Preference().Save(&model.Preferences{ + nErr = ss.Preference().Save(model.Preferences{ { UserId: userId, Category: model.PreferenceCategoryFavoriteChannel, @@ -2028,7 +2028,7 @@ func testUpdateSidebarChannelsByPreferences(t *testing.T, ss store.Store) { }, 10) require.NoError(t, nErr) - err := ss.Channel().UpdateSidebarChannelsByPreferences(&model.Preferences{ + err := ss.Channel().UpdateSidebarChannelsByPreferences(model.Preferences{ model.Preference{ Name: channel.Id, Category: model.PreferenceCategoryFavoriteChannel, @@ -2047,7 +2047,7 @@ func testUpdateSidebarChannelsByPreferences(t *testing.T, ss store.Store) { require.NotEmpty(t, res) require.NotPanics(t, func() { - _ = ss.Channel().UpdateSidebarChannelsByPreferences(&model.Preferences{ + _ = ss.Channel().UpdateSidebarChannelsByPreferences(model.Preferences{ model.Preference{ Name: "fakeid", Category: model.PreferenceCategoryFavoriteChannel, diff --git a/store/storetest/compliance_store.go b/store/storetest/compliance_store.go index 8d66d26ccac..c768ffb268b 100644 --- a/store/storetest/compliance_store.go +++ b/store/storetest/compliance_store.go @@ -31,7 +31,7 @@ func cleanupStoreState(t *testing.T, ss store.Store) { //remove existing channels allChannels, nErr := ss.Channel().GetAllChannels(0, 100000, store.ChannelSearchOpts{IncludeDeleted: true}) require.NoError(t, nErr, "error cleaning all test channels", nErr) - for _, channel := range *allChannels { + for _, channel := range allChannels { nErr = ss.Channel().PermanentDelete(channel.Id) require.NoError(t, nErr, "failed cleaning up test channel %s", channel.Id) } diff --git a/store/storetest/group_store.go b/store/storetest/group_store.go index ea5d0b76902..122958b3653 100644 --- a/store/storetest/group_store.go +++ b/store/storetest/group_store.go @@ -4401,9 +4401,9 @@ func groupTestpUpdateMembersRoleChannel(t *testing.T, ss store.Store) { members, err := ss.Channel().GetMembers(channel.Id, 0, 100) require.NoError(t, err) - require.GreaterOrEqual(t, len(*members), 4) // sanity check for channel membership + require.GreaterOrEqual(t, len(members), 4) // sanity check for channel membership - for _, member := range *members { + for _, member := range members { if utils.StringInSlice(member.UserId, tt.inUserIDs) { require.True(t, member.SchemeAdmin) } else { diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go index 3417f16396a..6b70fbfe691 100644 --- a/store/storetest/mocks/ChannelStore.go +++ b/store/storetest/mocks/ChannelStore.go @@ -61,15 +61,15 @@ func (_m *ChannelStore) AnalyticsTypeCount(teamID string, channelType model.Chan } // AutocompleteInTeam provides a mock function with given fields: teamID, term, includeDeleted -func (_m *ChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (_m *ChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { ret := _m.Called(teamID, term, includeDeleted) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, bool) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, bool) model.ChannelList); ok { r0 = rf(teamID, term, includeDeleted) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -84,15 +84,15 @@ func (_m *ChannelStore) AutocompleteInTeam(teamID string, term string, includeDe } // AutocompleteInTeamForSearch provides a mock function with given fields: teamID, userID, term, includeDeleted -func (_m *ChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (_m *ChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (model.ChannelList, error) { ret := _m.Called(teamID, userID, term, includeDeleted) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, string, bool) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, string, bool) model.ChannelList); ok { r0 = rf(teamID, userID, term, includeDeleted) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -272,11 +272,11 @@ func (_m *ChannelStore) DeleteSidebarCategory(categoryID string) error { } // DeleteSidebarChannelsByPreferences provides a mock function with given fields: preferences -func (_m *ChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (_m *ChannelStore) DeleteSidebarChannelsByPreferences(preferences model.Preferences) error { ret := _m.Called(preferences) var r0 error - if rf, ok := ret.Get(0).(func(*model.Preferences) error); ok { + if rf, ok := ret.Get(0).(func(model.Preferences) error); ok { r0 = rf(preferences) } else { r0 = ret.Error(0) @@ -378,15 +378,15 @@ func (_m *ChannelStore) GetAllChannelMembersNotifyPropsForChannel(channelID stri } // GetAllChannels provides a mock function with given fields: page, perPage, opts -func (_m *ChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) { +func (_m *ChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, error) { ret := _m.Called(page, perPage, opts) - var r0 *model.ChannelListWithTeamData - if rf, ok := ret.Get(0).(func(int, int, store.ChannelSearchOpts) *model.ChannelListWithTeamData); ok { + var r0 model.ChannelListWithTeamData + if rf, ok := ret.Get(0).(func(int, int, store.ChannelSearchOpts) model.ChannelListWithTeamData); ok { r0 = rf(page, perPage, opts) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelListWithTeamData) + r0 = ret.Get(0).(model.ChannelListWithTeamData) } } @@ -629,15 +629,15 @@ func (_m *ChannelStore) GetChannelUnread(channelID string, userID string) (*mode } // GetChannels provides a mock function with given fields: teamID, userID, includeDeleted, lastDeleteAt -func (_m *ChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) { +func (_m *ChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, error) { ret := _m.Called(teamID, userID, includeDeleted, lastDeleteAt) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, bool, int) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, bool, int) model.ChannelList); ok { r0 = rf(teamID, userID, includeDeleted, lastDeleteAt) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -721,15 +721,15 @@ func (_m *ChannelStore) GetChannelsByScheme(schemeID string, offset int, limit i } // GetDeleted provides a mock function with given fields: team_id, offset, limit, userID -func (_m *ChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (*model.ChannelList, error) { +func (_m *ChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (model.ChannelList, error) { ret := _m.Called(team_id, offset, limit, userID) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, int, int, string) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, int, int, string) model.ChannelList); ok { r0 = rf(team_id, offset, limit, userID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -938,15 +938,15 @@ func (_m *ChannelStore) GetMemberForPost(postID string, userID string) (*model.C } // GetMembers provides a mock function with given fields: channelID, offset, limit -func (_m *ChannelStore) GetMembers(channelID string, offset int, limit int) (*model.ChannelMembers, error) { +func (_m *ChannelStore) GetMembers(channelID string, offset int, limit int) (model.ChannelMembers, error) { ret := _m.Called(channelID, offset, limit) - var r0 *model.ChannelMembers - if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelMembers); ok { + var r0 model.ChannelMembers + if rf, ok := ret.Get(0).(func(string, int, int) model.ChannelMembers); ok { r0 = rf(channelID, offset, limit) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelMembers) + r0 = ret.Get(0).(model.ChannelMembers) } } @@ -961,15 +961,15 @@ func (_m *ChannelStore) GetMembers(channelID string, offset int, limit int) (*mo } // GetMembersByChannelIds provides a mock function with given fields: channelIds, userID -func (_m *ChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (*model.ChannelMembers, error) { +func (_m *ChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (model.ChannelMembers, error) { ret := _m.Called(channelIds, userID) - var r0 *model.ChannelMembers - if rf, ok := ret.Get(0).(func([]string, string) *model.ChannelMembers); ok { + var r0 model.ChannelMembers + if rf, ok := ret.Get(0).(func([]string, string) model.ChannelMembers); ok { r0 = rf(channelIds, userID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelMembers) + r0 = ret.Get(0).(model.ChannelMembers) } } @@ -984,15 +984,15 @@ func (_m *ChannelStore) GetMembersByChannelIds(channelIds []string, userID strin } // GetMembersByIds provides a mock function with given fields: channelID, userIds -func (_m *ChannelStore) GetMembersByIds(channelID string, userIds []string) (*model.ChannelMembers, error) { +func (_m *ChannelStore) GetMembersByIds(channelID string, userIds []string) (model.ChannelMembers, error) { ret := _m.Called(channelID, userIds) - var r0 *model.ChannelMembers - if rf, ok := ret.Get(0).(func(string, []string) *model.ChannelMembers); ok { + var r0 model.ChannelMembers + if rf, ok := ret.Get(0).(func(string, []string) model.ChannelMembers); ok { r0 = rf(channelID, userIds) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelMembers) + r0 = ret.Get(0).(model.ChannelMembers) } } @@ -1007,15 +1007,15 @@ func (_m *ChannelStore) GetMembersByIds(channelID string, userIds []string) (*mo } // GetMembersForUser provides a mock function with given fields: teamID, userID -func (_m *ChannelStore) GetMembersForUser(teamID string, userID string) (*model.ChannelMembers, error) { +func (_m *ChannelStore) GetMembersForUser(teamID string, userID string) (model.ChannelMembers, error) { ret := _m.Called(teamID, userID) - var r0 *model.ChannelMembers - if rf, ok := ret.Get(0).(func(string, string) *model.ChannelMembers); ok { + var r0 model.ChannelMembers + if rf, ok := ret.Get(0).(func(string, string) model.ChannelMembers); ok { r0 = rf(teamID, userID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelMembers) + r0 = ret.Get(0).(model.ChannelMembers) } } @@ -1030,15 +1030,15 @@ func (_m *ChannelStore) GetMembersForUser(teamID string, userID string) (*model. } // GetMembersForUserWithPagination provides a mock function with given fields: teamID, userID, page, perPage -func (_m *ChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (*model.ChannelMembers, error) { +func (_m *ChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (model.ChannelMembers, error) { ret := _m.Called(teamID, userID, page, perPage) - var r0 *model.ChannelMembers - if rf, ok := ret.Get(0).(func(string, string, int, int) *model.ChannelMembers); ok { + var r0 model.ChannelMembers + if rf, ok := ret.Get(0).(func(string, string, int, int) model.ChannelMembers); ok { r0 = rf(teamID, userID, page, perPage) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelMembers) + r0 = ret.Get(0).(model.ChannelMembers) } } @@ -1053,15 +1053,15 @@ func (_m *ChannelStore) GetMembersForUserWithPagination(teamID string, userID st } // GetMoreChannels provides a mock function with given fields: teamID, userID, offset, limit -func (_m *ChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (*model.ChannelList, error) { +func (_m *ChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (model.ChannelList, error) { ret := _m.Called(teamID, userID, offset, limit) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, int, int) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, int, int) model.ChannelList); ok { r0 = rf(teamID, userID, offset, limit) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1120,15 +1120,15 @@ func (_m *ChannelStore) GetPinnedPosts(channelID string) (*model.PostList, error } // GetPrivateChannelsForTeam provides a mock function with given fields: teamID, offset, limit -func (_m *ChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (_m *ChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { ret := _m.Called(teamID, offset, limit) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, int, int) model.ChannelList); ok { r0 = rf(teamID, offset, limit) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1143,15 +1143,15 @@ func (_m *ChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, lim } // GetPublicChannelsByIdsForTeam provides a mock function with given fields: teamID, channelIds -func (_m *ChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, error) { +func (_m *ChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (model.ChannelList, error) { ret := _m.Called(teamID, channelIds) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, []string) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, []string) model.ChannelList); ok { r0 = rf(teamID, channelIds) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1166,15 +1166,15 @@ func (_m *ChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds } // GetPublicChannelsForTeam provides a mock function with given fields: teamID, offset, limit -func (_m *ChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (_m *ChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { ret := _m.Called(teamID, offset, limit) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, int, int) model.ChannelList); ok { r0 = rf(teamID, offset, limit) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1258,15 +1258,15 @@ func (_m *ChannelStore) GetSidebarCategoryOrder(userID string, teamID string) ([ } // GetTeamChannels provides a mock function with given fields: teamID -func (_m *ChannelStore) GetTeamChannels(teamID string) (*model.ChannelList, error) { +func (_m *ChannelStore) GetTeamChannels(teamID string) (model.ChannelList, error) { ret := _m.Called(teamID) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string) model.ChannelList); ok { r0 = rf(teamID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1643,15 +1643,15 @@ func (_m *ChannelStore) SaveMultipleMembers(members []*model.ChannelMember) ([]* } // SearchAllChannels provides a mock function with given fields: term, opts -func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) { +func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, error) { ret := _m.Called(term, opts) - var r0 *model.ChannelListWithTeamData - if rf, ok := ret.Get(0).(func(string, store.ChannelSearchOpts) *model.ChannelListWithTeamData); ok { + var r0 model.ChannelListWithTeamData + if rf, ok := ret.Get(0).(func(string, store.ChannelSearchOpts) model.ChannelListWithTeamData); ok { r0 = rf(term, opts) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelListWithTeamData) + r0 = ret.Get(0).(model.ChannelListWithTeamData) } } @@ -1673,15 +1673,15 @@ func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchO } // SearchArchivedInTeam provides a mock function with given fields: teamID, term, userID -func (_m *ChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (*model.ChannelList, error) { +func (_m *ChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (model.ChannelList, error) { ret := _m.Called(teamID, term, userID) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, string) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, string) model.ChannelList); ok { r0 = rf(teamID, term, userID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1696,15 +1696,15 @@ func (_m *ChannelStore) SearchArchivedInTeam(teamID string, term string, userID } // SearchForUserInTeam provides a mock function with given fields: userID, teamID, term, includeDeleted -func (_m *ChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (_m *ChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (model.ChannelList, error) { ret := _m.Called(userID, teamID, term, includeDeleted) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, string, bool) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, string, bool) model.ChannelList); ok { r0 = rf(userID, teamID, term, includeDeleted) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1719,15 +1719,15 @@ func (_m *ChannelStore) SearchForUserInTeam(userID string, teamID string, term s } // SearchGroupChannels provides a mock function with given fields: userID, term -func (_m *ChannelStore) SearchGroupChannels(userID string, term string) (*model.ChannelList, error) { +func (_m *ChannelStore) SearchGroupChannels(userID string, term string) (model.ChannelList, error) { ret := _m.Called(userID, term) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string) model.ChannelList); ok { r0 = rf(userID, term) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1742,15 +1742,15 @@ func (_m *ChannelStore) SearchGroupChannels(userID string, term string) (*model. } // SearchInTeam provides a mock function with given fields: teamID, term, includeDeleted -func (_m *ChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (_m *ChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { ret := _m.Called(teamID, term, includeDeleted) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, bool) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, bool) model.ChannelList); ok { r0 = rf(teamID, term, includeDeleted) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -1765,15 +1765,15 @@ func (_m *ChannelStore) SearchInTeam(teamID string, term string, includeDeleted } // SearchMore provides a mock function with given fields: userID, teamID, term -func (_m *ChannelStore) SearchMore(userID string, teamID string, term string) (*model.ChannelList, error) { +func (_m *ChannelStore) SearchMore(userID string, teamID string, term string) (model.ChannelList, error) { ret := _m.Called(userID, teamID, term) - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, string) *model.ChannelList); ok { + var r0 model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, string) model.ChannelList); ok { r0 = rf(userID, teamID, term) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) + r0 = ret.Get(0).(model.ChannelList) } } @@ -2005,11 +2005,11 @@ func (_m *ChannelStore) UpdateSidebarChannelCategoryOnMove(channel *model.Channe } // UpdateSidebarChannelsByPreferences provides a mock function with given fields: preferences -func (_m *ChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (_m *ChannelStore) UpdateSidebarChannelsByPreferences(preferences model.Preferences) error { ret := _m.Called(preferences) var r0 error - if rf, ok := ret.Get(0).(func(*model.Preferences) error); ok { + if rf, ok := ret.Get(0).(func(model.Preferences) error); ok { r0 = rf(preferences) } else { r0 = ret.Error(0) diff --git a/store/storetest/mocks/PreferenceStore.go b/store/storetest/mocks/PreferenceStore.go index beae0ed7910..45d02cf5f92 100644 --- a/store/storetest/mocks/PreferenceStore.go +++ b/store/storetest/mocks/PreferenceStore.go @@ -182,11 +182,11 @@ func (_m *PreferenceStore) PermanentDeleteByUser(userID string) error { } // Save provides a mock function with given fields: preferences -func (_m *PreferenceStore) Save(preferences *model.Preferences) error { +func (_m *PreferenceStore) Save(preferences model.Preferences) error { ret := _m.Called(preferences) var r0 error - if rf, ok := ret.Get(0).(func(*model.Preferences) error); ok { + if rf, ok := ret.Get(0).(func(model.Preferences) error); ok { r0 = rf(preferences) } else { r0 = ret.Error(0) diff --git a/store/storetest/mocks/ProductNoticesStore.go b/store/storetest/mocks/ProductNoticesStore.go index 1cd3c61d81b..7e125e25c51 100644 --- a/store/storetest/mocks/ProductNoticesStore.go +++ b/store/storetest/mocks/ProductNoticesStore.go @@ -29,11 +29,11 @@ func (_m *ProductNoticesStore) Clear(notices []string) error { } // ClearOldNotices provides a mock function with given fields: currentNotices -func (_m *ProductNoticesStore) ClearOldNotices(currentNotices *model.ProductNotices) error { +func (_m *ProductNoticesStore) ClearOldNotices(currentNotices model.ProductNotices) error { ret := _m.Called(currentNotices) var r0 error - if rf, ok := ret.Get(0).(func(*model.ProductNotices) error); ok { + if rf, ok := ret.Get(0).(func(model.ProductNotices) error); ok { r0 = rf(currentNotices) } else { r0 = ret.Error(0) diff --git a/store/storetest/oauth_store.go b/store/storetest/oauth_store.go index 294fe6db237..991dc431aca 100644 --- a/store/storetest/oauth_store.go +++ b/store/storetest/oauth_store.go @@ -305,7 +305,7 @@ func testOAuthGetAuthorizedApps(t *testing.T, ss store.Store) { p.Category = model.PreferenceCategoryAuthorizedOAuthApp p.Name = a1.Id p.Value = "true" - nErr := ss.Preference().Save(&model.Preferences{p}) + nErr := ss.Preference().Save(model.Preferences{p}) require.NoError(t, nErr) apps, err = ss.OAuth().GetAuthorizedApps(a1.CreatorId, 0, 1000) @@ -328,7 +328,7 @@ func testOAuthGetAccessDataByUserForApp(t *testing.T, ss store.Store) { p.Category = model.PreferenceCategoryAuthorizedOAuthApp p.Name = a1.Id p.Value = "true" - nErr := ss.Preference().Save(&model.Preferences{p}) + nErr := ss.Preference().Save(model.Preferences{p}) require.NoError(t, nErr) apps, err := ss.OAuth().GetAuthorizedApps(a1.CreatorId, 0, 1000) diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go index 30bf7470b6d..d3cd69f2c41 100644 --- a/store/storetest/post_store.go +++ b/store/storetest/post_store.go @@ -1939,7 +1939,7 @@ func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStor }, } - err = ss.Preference().Save(&preferences) + err = ss.Preference().Save(preferences) require.NoError(t, err) r2, err := ss.Post().GetFlaggedPostsForTeam(o1.UserId, c1.TeamId, 0, 2) @@ -1955,7 +1955,7 @@ func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStor }, } - err = ss.Preference().Save(&preferences) + err = ss.Preference().Save(preferences) require.NoError(t, err) r3, err := ss.Post().GetFlaggedPostsForTeam(o1.UserId, c1.TeamId, 0, 1) @@ -1983,7 +1983,7 @@ func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStor }, } - err = ss.Preference().Save(&preferences) + err = ss.Preference().Save(preferences) require.NoError(t, err) r4, err = ss.Post().GetFlaggedPostsForTeam(o1.UserId, c1.TeamId, 0, 2) @@ -1998,7 +1998,7 @@ func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStor Value: "true", }, } - err = ss.Preference().Save(&preferences) + err = ss.Preference().Save(preferences) require.NoError(t, err) r4, err = ss.Post().GetFlaggedPostsForTeam(o1.UserId, c1.TeamId, 0, 2) @@ -2017,7 +2017,7 @@ func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStor Value: "true", }, } - err = ss.Preference().Save(&preferences) + err = ss.Preference().Save(preferences) require.NoError(t, err) r4, err = ss.Post().GetFlaggedPostsForTeam(o1.UserId, c1.TeamId, 0, 10) @@ -2067,7 +2067,7 @@ func testPostStoreGetFlaggedPosts(t *testing.T, ss store.Store) { }, } - nErr := ss.Preference().Save(&preferences) + nErr := ss.Preference().Save(preferences) require.NoError(t, nErr) r2, err := ss.Post().GetFlaggedPosts(o1.UserId, 0, 2) @@ -2083,7 +2083,7 @@ func testPostStoreGetFlaggedPosts(t *testing.T, ss store.Store) { }, } - nErr = ss.Preference().Save(&preferences) + nErr = ss.Preference().Save(preferences) require.NoError(t, nErr) r3, err := ss.Post().GetFlaggedPosts(o1.UserId, 0, 1) @@ -2111,7 +2111,7 @@ func testPostStoreGetFlaggedPosts(t *testing.T, ss store.Store) { }, } - nErr = ss.Preference().Save(&preferences) + nErr = ss.Preference().Save(preferences) require.NoError(t, nErr) r4, err = ss.Post().GetFlaggedPosts(o1.UserId, 0, 2) @@ -2165,7 +2165,7 @@ func testPostStoreGetFlaggedPostsForChannel(t *testing.T, ss store.Store) { Value: "true", } - nErr := ss.Preference().Save(&model.Preferences{preference}) + nErr := ss.Preference().Save(model.Preferences{preference}) require.NoError(t, nErr) r, err = ss.Post().GetFlaggedPostsForChannel(o1.UserId, o1.ChannelId, 0, 10) @@ -2173,11 +2173,11 @@ func testPostStoreGetFlaggedPostsForChannel(t *testing.T, ss store.Store) { require.Len(t, r.Order, 1, "should have 1 post") preference.Name = o2.Id - nErr = ss.Preference().Save(&model.Preferences{preference}) + nErr = ss.Preference().Save(model.Preferences{preference}) require.NoError(t, nErr) preference.Name = o3.Id - nErr = ss.Preference().Save(&model.Preferences{preference}) + nErr = ss.Preference().Save(model.Preferences{preference}) require.NoError(t, nErr) r, err = ss.Post().GetFlaggedPostsForChannel(o1.UserId, o1.ChannelId, 0, 1) @@ -2197,7 +2197,7 @@ func testPostStoreGetFlaggedPostsForChannel(t *testing.T, ss store.Store) { require.Len(t, r.Order, 2, "should have 2 posts") preference.Name = o4.Id - nErr = ss.Preference().Save(&model.Preferences{preference}) + nErr = ss.Preference().Save(model.Preferences{preference}) require.NoError(t, nErr) r, err = ss.Post().GetFlaggedPostsForChannel(o1.UserId, o4.ChannelId, 0, 10) diff --git a/store/storetest/preference_store.go b/store/storetest/preference_store.go index 15b8165ed3a..ebd66dde8d0 100644 --- a/store/storetest/preference_store.go +++ b/store/storetest/preference_store.go @@ -42,7 +42,7 @@ func testPreferenceSave(t *testing.T, ss store.Store) { Value: "value1b", }, } - err := ss.Preference().Save(&preferences) + err := ss.Preference().Save(preferences) require.NoError(t, err, "saving preference returned error") for _, preference := range preferences { @@ -52,7 +52,7 @@ func testPreferenceSave(t *testing.T, ss store.Store) { preferences[0].Value = "value2a" preferences[1].Value = "value2b" - err = ss.Preference().Save(&preferences) + err = ss.Preference().Save(preferences) require.NoError(t, err, "saving preference returned error") for _, preference := range preferences { @@ -89,7 +89,7 @@ func testPreferenceGet(t *testing.T, ss store.Store) { }, } - err := ss.Preference().Save(&preferences) + err := ss.Preference().Save(preferences) require.NoError(t, err) data, err := ss.Preference().Get(userId, category, name) @@ -132,7 +132,7 @@ func testPreferenceGetCategory(t *testing.T, ss store.Store) { }, } - err := ss.Preference().Save(&preferences) + err := ss.Preference().Save(preferences) require.NoError(t, err) preferencesByCategory, err := ss.Preference().GetCategory(userId, category) @@ -181,7 +181,7 @@ func testPreferenceGetAll(t *testing.T, ss store.Store) { }, } - err := ss.Preference().Save(&preferences) + err := ss.Preference().Save(preferences) require.NoError(t, err) result, err := ss.Preference().GetAll(userId) @@ -225,7 +225,7 @@ func testPreferenceDeleteByUser(t *testing.T, ss store.Store) { }, } - err := ss.Preference().Save(&preferences) + err := ss.Preference().Save(preferences) require.NoError(t, err) err = ss.Preference().PermanentDeleteByUser(userId) @@ -240,7 +240,7 @@ func testPreferenceDelete(t *testing.T, ss store.Store) { Value: "value1a", } - err := ss.Preference().Save(&model.Preferences{preference}) + err := ss.Preference().Save(model.Preferences{preference}) require.NoError(t, err) preferences, err := ss.Preference().GetAll(preference.UserId) @@ -272,7 +272,7 @@ func testPreferenceDeleteCategory(t *testing.T, ss store.Store) { Value: "value1a", } - err := ss.Preference().Save(&model.Preferences{preference1, preference2}) + err := ss.Preference().Save(model.Preferences{preference1, preference2}) require.NoError(t, err) preferences, err := ss.Preference().GetAll(userId) @@ -307,7 +307,7 @@ func testPreferenceDeleteCategoryAndName(t *testing.T, ss store.Store) { Value: "value1a", } - err := ss.Preference().Save(&model.Preferences{preference1, preference2}) + err := ss.Preference().Save(model.Preferences{preference1, preference2}) require.NoError(t, err) preferences, err := ss.Preference().GetAll(userId) @@ -378,7 +378,7 @@ func testPreferenceDeleteOrphanedRows(t *testing.T, ss store.Store) { Value: "true", } - nErr := ss.Preference().Save(&model.Preferences{preference1, preference2}) + nErr := ss.Preference().Save(model.Preferences{preference1, preference2}) require.NoError(t, nErr) _, _, nErr = ss.Post().PermanentDeleteBatchForRetentionPolicies(0, 2000, limit, model.RetentionPolicyCursor{}) diff --git a/store/storetest/product_notices_store.go b/store/storetest/product_notices_store.go index b539aabc4f4..fd3e945f1ce 100644 --- a/store/storetest/product_notices_store.go +++ b/store/storetest/product_notices_store.go @@ -64,7 +64,7 @@ func testClearOld(t *testing.T, ss store.Store) { err := ss.ProductNotices().View("testuser", noticesA) require.NoError(t, err) - err = ss.ProductNotices().ClearOldNotices(&model.ProductNotices{ + err = ss.ProductNotices().ClearOldNotices(model.ProductNotices{ { ID: "noticeA", }, diff --git a/store/timerlayer/timerlayer.go b/store/timerlayer/timerlayer.go index ba05bc1a11d..ba062a9de42 100644 --- a/store/timerlayer/timerlayer.go +++ b/store/timerlayer/timerlayer.go @@ -550,7 +550,7 @@ func (s *TimerLayerChannelStore) AnalyticsTypeCount(teamID string, channelType m return result, err } -func (s *TimerLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.AutocompleteInTeam(teamID, term, includeDeleted) @@ -566,7 +566,7 @@ func (s *TimerLayerChannelStore) AutocompleteInTeam(teamID string, term string, return result, err } -func (s *TimerLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userID string, term string, includeDeleted bool) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.AutocompleteInTeamForSearch(teamID, userID, term, includeDeleted) @@ -725,7 +725,7 @@ func (s *TimerLayerChannelStore) DeleteSidebarCategory(categoryID string) error return err } -func (s *TimerLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s *TimerLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences model.Preferences) error { start := timemodule.Now() err := s.ChannelStore.DeleteSidebarChannelsByPreferences(preferences) @@ -805,7 +805,7 @@ func (s *TimerLayerChannelStore) GetAllChannelMembersNotifyPropsForChannel(chann return result, err } -func (s *TimerLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) { +func (s *TimerLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, error) { start := timemodule.Now() result, err := s.ChannelStore.GetAllChannels(page, perPage, opts) @@ -981,7 +981,7 @@ func (s *TimerLayerChannelStore) GetChannelUnread(channelID string, userID strin return result, err } -func (s *TimerLayerChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) GetChannels(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.GetChannels(teamID, userID, includeDeleted, lastDeleteAt) @@ -1045,7 +1045,7 @@ func (s *TimerLayerChannelStore) GetChannelsByScheme(schemeID string, offset int return result, err } -func (s *TimerLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userID string) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.GetDeleted(team_id, offset, limit, userID) @@ -1205,7 +1205,7 @@ func (s *TimerLayerChannelStore) GetMemberForPost(postID string, userID string) return result, err } -func (s *TimerLayerChannelStore) GetMembers(channelID string, offset int, limit int) (*model.ChannelMembers, error) { +func (s *TimerLayerChannelStore) GetMembers(channelID string, offset int, limit int) (model.ChannelMembers, error) { start := timemodule.Now() result, err := s.ChannelStore.GetMembers(channelID, offset, limit) @@ -1221,7 +1221,7 @@ func (s *TimerLayerChannelStore) GetMembers(channelID string, offset int, limit return result, err } -func (s *TimerLayerChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (*model.ChannelMembers, error) { +func (s *TimerLayerChannelStore) GetMembersByChannelIds(channelIds []string, userID string) (model.ChannelMembers, error) { start := timemodule.Now() result, err := s.ChannelStore.GetMembersByChannelIds(channelIds, userID) @@ -1237,7 +1237,7 @@ func (s *TimerLayerChannelStore) GetMembersByChannelIds(channelIds []string, use return result, err } -func (s *TimerLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (*model.ChannelMembers, error) { +func (s *TimerLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (model.ChannelMembers, error) { start := timemodule.Now() result, err := s.ChannelStore.GetMembersByIds(channelID, userIds) @@ -1253,7 +1253,7 @@ func (s *TimerLayerChannelStore) GetMembersByIds(channelID string, userIds []str return result, err } -func (s *TimerLayerChannelStore) GetMembersForUser(teamID string, userID string) (*model.ChannelMembers, error) { +func (s *TimerLayerChannelStore) GetMembersForUser(teamID string, userID string) (model.ChannelMembers, error) { start := timemodule.Now() result, err := s.ChannelStore.GetMembersForUser(teamID, userID) @@ -1269,7 +1269,7 @@ func (s *TimerLayerChannelStore) GetMembersForUser(teamID string, userID string) return result, err } -func (s *TimerLayerChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (*model.ChannelMembers, error) { +func (s *TimerLayerChannelStore) GetMembersForUserWithPagination(teamID string, userID string, page int, perPage int) (model.ChannelMembers, error) { start := timemodule.Now() result, err := s.ChannelStore.GetMembersForUserWithPagination(teamID, userID, page, perPage) @@ -1285,7 +1285,7 @@ func (s *TimerLayerChannelStore) GetMembersForUserWithPagination(teamID string, return result, err } -func (s *TimerLayerChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) GetMoreChannels(teamID string, userID string, offset int, limit int) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.GetMoreChannels(teamID, userID, offset, limit) @@ -1333,7 +1333,7 @@ func (s *TimerLayerChannelStore) GetPinnedPosts(channelID string) (*model.PostLi return result, err } -func (s *TimerLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.GetPrivateChannelsForTeam(teamID, offset, limit) @@ -1349,7 +1349,7 @@ func (s *TimerLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset return result, err } -func (s *TimerLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.GetPublicChannelsByIdsForTeam(teamID, channelIds) @@ -1365,7 +1365,7 @@ func (s *TimerLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, ch return result, err } -func (s *TimerLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.GetPublicChannelsForTeam(teamID, offset, limit) @@ -1429,7 +1429,7 @@ func (s *TimerLayerChannelStore) GetSidebarCategoryOrder(userID string, teamID s return result, err } -func (s *TimerLayerChannelStore) GetTeamChannels(teamID string) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) GetTeamChannels(teamID string) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.GetTeamChannels(teamID) @@ -1854,7 +1854,7 @@ func (s *TimerLayerChannelStore) SaveMultipleMembers(members []*model.ChannelMem return result, err } -func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) { +func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (model.ChannelListWithTeamData, int64, error) { start := timemodule.Now() result, resultVar1, err := s.ChannelStore.SearchAllChannels(term, opts) @@ -1870,7 +1870,7 @@ func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts store.Chann return result, resultVar1, err } -func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userID string) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.SearchArchivedInTeam(teamID, term, userID) @@ -1886,7 +1886,7 @@ func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamID string, term string return result, err } -func (s *TimerLayerChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) SearchForUserInTeam(userID string, teamID string, term string, includeDeleted bool) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.SearchForUserInTeam(userID, teamID, term, includeDeleted) @@ -1902,7 +1902,7 @@ func (s *TimerLayerChannelStore) SearchForUserInTeam(userID string, teamID strin return result, err } -func (s *TimerLayerChannelStore) SearchGroupChannels(userID string, term string) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) SearchGroupChannels(userID string, term string) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.SearchGroupChannels(userID, term) @@ -1918,7 +1918,7 @@ func (s *TimerLayerChannelStore) SearchGroupChannels(userID string, term string) return result, err } -func (s *TimerLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.SearchInTeam(teamID, term, includeDeleted) @@ -1934,7 +1934,7 @@ func (s *TimerLayerChannelStore) SearchInTeam(teamID string, term string, includ return result, err } -func (s *TimerLayerChannelStore) SearchMore(userID string, teamID string, term string) (*model.ChannelList, error) { +func (s *TimerLayerChannelStore) SearchMore(userID string, teamID string, term string) (model.ChannelList, error) { start := timemodule.Now() result, err := s.ChannelStore.SearchMore(userID, teamID, term) @@ -2126,7 +2126,7 @@ func (s *TimerLayerChannelStore) UpdateSidebarChannelCategoryOnMove(channel *mod return err } -func (s *TimerLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error { +func (s *TimerLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences model.Preferences) error { start := timemodule.Now() err := s.ChannelStore.UpdateSidebarChannelsByPreferences(preferences) @@ -5353,7 +5353,7 @@ func (s *TimerLayerPreferenceStore) PermanentDeleteByUser(userID string) error { return err } -func (s *TimerLayerPreferenceStore) Save(preferences *model.Preferences) error { +func (s *TimerLayerPreferenceStore) Save(preferences model.Preferences) error { start := timemodule.Now() err := s.PreferenceStore.Save(preferences) @@ -5385,7 +5385,7 @@ func (s *TimerLayerProductNoticesStore) Clear(notices []string) error { return err } -func (s *TimerLayerProductNoticesStore) ClearOldNotices(currentNotices *model.ProductNotices) error { +func (s *TimerLayerProductNoticesStore) ClearOldNotices(currentNotices model.ProductNotices) error { start := timemodule.Now() err := s.ProductNoticesStore.ClearOldNotices(currentNotices)