* Migration finished

* Change error var name

* Fix imports

* Fix tests

* Merge with master

* Doing some suggestions

* More suggestions

* Fix i18n

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Этот коммит содержится в:
Rodrigo Villablanca
2020-10-04 01:42:29 -03:00
коммит произвёл GitHub
родитель 5353bceaea
Коммит bb4df5a68e
23 изменённых файлов: 1187 добавлений и 716 удалений

Просмотреть файл

@@ -1783,7 +1783,12 @@ func (a *App) GetChannelMembersTimezones(channelId string) ([]string, *model.App
} }
func (a *App) GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { func (a *App) GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) {
return a.Srv().Store.Channel().GetMembersByIds(channelId, userIds) 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)
}
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) {
@@ -1850,7 +1855,13 @@ func (a *App) GetChannelCounts(teamId string, userId string) (*model.ChannelCoun
func (a *App) GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError) { func (a *App) GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError) {
channelUnread, err := a.Srv().Store.Channel().GetChannelUnread(channelId, userId) channelUnread, err := a.Srv().Store.Channel().GetChannelUnread(channelId, userId)
if err != nil { if err != nil {
return nil, err var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("GetChannelUnread", "app.channel.get_unread.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("GetChannelUnread", "app.channel.get_unread.app_error", nil, err.Error(), http.StatusInternalServerError)
}
} }
if channelUnread.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] == model.CHANNEL_MARK_UNREAD_MENTION { if channelUnread.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] == model.CHANNEL_MARK_UNREAD_MENTION {
@@ -2329,7 +2340,12 @@ func (a *App) AutocompleteChannels(teamId string, term string) (*model.ChannelLi
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
term = strings.TrimSpace(term) term = strings.TrimSpace(term)
return a.Srv().Store.Channel().AutocompleteInTeam(teamId, term, includeDeleted) channelList, err := a.Srv().Store.Channel().AutocompleteInTeam(teamId, term, includeDeleted)
if err != nil {
return nil, model.NewAppError("AutocompleteChannels", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
}
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) {
@@ -2337,7 +2353,12 @@ func (a *App) AutocompleteChannelsForSearch(teamId string, userId string, term s
term = strings.TrimSpace(term) term = strings.TrimSpace(term)
return a.Srv().Store.Channel().AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted) channelList, err := a.Srv().Store.Channel().AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted)
if err != nil {
return nil, model.NewAppError("AutocompleteChannelsForSearch", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return channelList, nil
} }
// 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 returns a list of channels, the total count of the results of the search (if the paginate search option is true), and an error.
@@ -2361,7 +2382,12 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod
term = strings.TrimSpace(term) term = strings.TrimSpace(term)
return a.Srv().Store.Channel().SearchAllChannels(term, storeOpts) channelList, totalCount, err := a.Srv().Store.Channel().SearchAllChannels(term, storeOpts)
if err != nil {
return nil, 0, model.NewAppError("SearchAllChannels", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
}
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) {
@@ -2369,13 +2395,23 @@ func (a *App) SearchChannels(teamId string, term string) (*model.ChannelList, *m
term = strings.TrimSpace(term) term = strings.TrimSpace(term)
return a.Srv().Store.Channel().SearchInTeam(teamId, term, includeDeleted) channelList, err := a.Srv().Store.Channel().SearchInTeam(teamId, term, includeDeleted)
if err != nil {
return nil, model.NewAppError("SearchChannels", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
}
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) term = strings.TrimSpace(term)
return a.Srv().Store.Channel().SearchArchivedInTeam(teamId, term, userId) channelList, err := a.Srv().Store.Channel().SearchArchivedInTeam(teamId, term, userId)
if err != nil {
return nil, model.NewAppError("SearchArchivedChannels", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
}
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) {
@@ -2383,7 +2419,12 @@ func (a *App) SearchChannelsForUser(userId, teamId, term string) (*model.Channel
term = strings.TrimSpace(term) term = strings.TrimSpace(term)
return a.Srv().Store.Channel().SearchForUserInTeam(userId, teamId, term, includeDeleted) channelList, err := a.Srv().Store.Channel().SearchForUserInTeam(userId, teamId, term, includeDeleted)
if err != nil {
return nil, model.NewAppError("SearchChannelsForUser", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
}
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) {
@@ -2393,14 +2434,19 @@ func (a *App) SearchGroupChannels(userId, term string) (*model.ChannelList, *mod
channelList, err := a.Srv().Store.Channel().SearchGroupChannels(userId, term) channelList, err := a.Srv().Store.Channel().SearchGroupChannels(userId, term)
if err != nil { if err != nil {
return nil, err return nil, model.NewAppError("SearchGroupChannels", "app.channel.search_group_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
return channelList, nil 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) term = strings.TrimSpace(term)
return a.Srv().Store.Channel().SearchMore(userId, teamId, term) channelList, err := a.Srv().Store.Channel().SearchMore(userId, teamId, term)
if err != nil {
return nil, model.NewAppError("SearchChannelsUserNotIn", "app.channel.search.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return channelList, nil
} }
func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSessionId string) (map[string]int64, *model.AppError) { func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSessionId string) (map[string]int64, *model.AppError) {
@@ -2523,7 +2569,12 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
} }
func (a *App) RemoveAllDeactivatedMembersFromChannel(channel *model.Channel) *model.AppError { func (a *App) RemoveAllDeactivatedMembersFromChannel(channel *model.Channel) *model.AppError {
return a.Srv().Store.Channel().RemoveAllDeactivatedMembers(channel.Id) err := a.Srv().Store.Channel().RemoveAllDeactivatedMembers(channel.Id)
if err != nil {
return model.NewAppError("RemoveAllDeactivatedMembersFromChannel", "app.channel.remove_all_deactivated_members.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return nil
} }
// MoveChannel method is prone to data races if someone joins to channel during the move process. However this // MoveChannel method is prone to data races if someone joins to channel during the move process. However this

Просмотреть файл

@@ -4,9 +4,12 @@
package app package app
import ( import (
"errors"
"net/http" "net/http"
"time" "time"
"github.com/mattermost/mattermost-server/v5/store"
"github.com/mattermost/mattermost-server/v5/mlog" "github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
) )
@@ -26,20 +29,30 @@ func (a *App) GetSidebarCategories(userId, teamId string) (*model.OrderedSidebar
if err == nil && len(categories.Categories) == 0 { if err == nil && len(categories.Categories) == 0 {
// A user must always have categories, so migration must not have happened yet, and we should run it ourselves // A user must always have categories, so migration must not have happened yet, and we should run it ourselves
nErr := a.createInitialSidebarCategories(userId, teamId) appErr := a.createInitialSidebarCategories(userId, teamId)
if nErr != nil { if appErr != nil {
return nil, nErr return nil, appErr
} }
categories, err = a.waitForSidebarCategories(userId, teamId) categories, err = a.waitForSidebarCategories(userId, teamId)
} }
return categories, err if err != nil {
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("GetSidebarCategories", "app.channel.sidebar_categories.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("GetSidebarCategories", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
}
}
return categories, nil
} }
// waitForSidebarCategories is used to get a user's sidebar categories after they've been created since there may be // waitForSidebarCategories is used to get a user's sidebar categories after they've been created since there may be
// replication lag if any database replicas exist. It will wait until results are available to return them. // replication lag if any database replicas exist. It will wait until results are available to return them.
func (a *App) waitForSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, *model.AppError) { func (a *App) waitForSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, error) {
if len(a.Config().SqlSettings.DataSourceReplicas) == 0 { if len(a.Config().SqlSettings.DataSourceReplicas) == 0 {
// The categories should be available immediately on a single database // The categories should be available immediately on a single database
return a.Srv().Store.Channel().GetSidebarCategories(userId, teamId) return a.Srv().Store.Channel().GetSidebarCategories(userId, teamId)
@@ -64,17 +77,45 @@ func (a *App) waitForSidebarCategories(userId, teamId string) (*model.OrderedSid
} }
func (a *App) GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError) { func (a *App) GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError) {
return a.Srv().Store.Channel().GetSidebarCategoryOrder(userId, teamId) categories, err := a.Srv().Store.Channel().GetSidebarCategoryOrder(userId, teamId)
if err != nil {
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("GetSidebarCategoryOrder", "app.channel.sidebar_categories.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("GetSidebarCategoryOrder", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
}
}
return categories, nil
} }
func (a *App) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) { func (a *App) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) {
return a.Srv().Store.Channel().GetSidebarCategory(categoryId) category, err := a.Srv().Store.Channel().GetSidebarCategory(categoryId)
if err != nil {
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("GetSidebarCategory", "app.channel.sidebar_categories.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("GetSidebarCategory", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
}
}
return category, nil
} }
func (a *App) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (a *App) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
category, err := a.Srv().Store.Channel().CreateSidebarCategory(userId, teamId, newCategory) category, err := a.Srv().Store.Channel().CreateSidebarCategory(userId, teamId, newCategory)
if err != nil { if err != nil {
return nil, err var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("CreateSidebarCategory", "app.channel.sidebar_categories.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("CreateSidebarCategory", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
}
} }
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_CREATED, teamId, "", userId, nil) message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_CREATED, teamId, "", userId, nil)
message.Add("category_id", category.Id) message.Add("category_id", category.Id)
@@ -85,7 +126,16 @@ func (a *App) CreateSidebarCategory(userId, teamId string, newCategory *model.Si
func (a *App) UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) *model.AppError { func (a *App) UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) *model.AppError {
err := a.Srv().Store.Channel().UpdateSidebarCategoryOrder(userId, teamId, categoryOrder) err := a.Srv().Store.Channel().UpdateSidebarCategoryOrder(userId, teamId, categoryOrder)
if err != nil { if err != nil {
return err var nfErr *store.ErrNotFound
var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &nfErr):
return model.NewAppError("UpdateSidebarCategoryOrder", "app.channel.sidebar_categories.app_error", nil, nfErr.Error(), http.StatusNotFound)
case errors.As(err, &invErr):
return model.NewAppError("UpdateSidebarCategoryOrder", "app.channel.sidebar_categories.app_error", nil, invErr.Error(), http.StatusBadRequest)
default:
return model.NewAppError("UpdateSidebarCategoryOrder", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
}
} }
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_ORDER_UPDATED, teamId, "", userId, nil) message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_ORDER_UPDATED, teamId, "", userId, nil)
message.Add("order", categoryOrder) message.Add("order", categoryOrder)
@@ -96,8 +146,9 @@ func (a *App) UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []
func (a *App) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) { func (a *App) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
result, err := a.Srv().Store.Channel().UpdateSidebarCategories(userId, teamId, categories) result, err := a.Srv().Store.Channel().UpdateSidebarCategories(userId, teamId, categories)
if err != nil { if err != nil {
return nil, err return nil, model.NewAppError("UpdateSidebarCategories", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, teamId, "", userId, nil) message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_UPDATED, teamId, "", userId, nil)
a.Publish(message) a.Publish(message)
return result, nil return result, nil
@@ -106,7 +157,13 @@ func (a *App) UpdateSidebarCategories(userId, teamId string, categories []*model
func (a *App) DeleteSidebarCategory(userId, teamId, categoryId string) *model.AppError { func (a *App) DeleteSidebarCategory(userId, teamId, categoryId string) *model.AppError {
err := a.Srv().Store.Channel().DeleteSidebarCategory(categoryId) err := a.Srv().Store.Channel().DeleteSidebarCategory(categoryId)
if err != nil { if err != nil {
return err var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &invErr):
return model.NewAppError("DeleteSidebarCategory", "app.channel.sidebar_categories.app_error", nil, invErr.Error(), http.StatusBadRequest)
default:
return model.NewAppError("DeleteSidebarCategory", "app.channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
}
} }
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_DELETED, teamId, "", userId, nil) message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_SIDEBAR_CATEGORY_DELETED, teamId, "", userId, nil)

Просмотреть файл

@@ -129,6 +129,6 @@ func TestGetSidebarCategories(t *testing.T) {
categories, appErr := th.App.GetSidebarCategories(th.BasicUser.Id, th.BasicTeam.Id) categories, appErr := th.App.GetSidebarCategories(th.BasicUser.Id, th.BasicTeam.Id)
assert.Nil(t, categories) assert.Nil(t, categories)
assert.NotNil(t, appErr) assert.NotNil(t, appErr)
assert.Equal(t, "store.sql_channel.sidebar_categories.app_error", appErr.Id) assert.Equal(t, "app.channel.sidebar_categories.app_error", appErr.Id)
}) })
} }

Просмотреть файл

@@ -156,7 +156,7 @@ func (a *App) exportAllChannels(writer io.Writer) *model.AppError {
channels, err := a.Srv().Store.Channel().GetAllChannelsForExportAfter(1000, afterId) channels, err := a.Srv().Store.Channel().GetAllChannelsForExportAfter(1000, afterId)
if err != nil { if err != nil {
return err return model.NewAppError("exportAllChannels", "app.channel.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
if len(channels) == 0 { if len(channels) == 0 {
@@ -296,9 +296,9 @@ func (a *App) buildUserTeamAndChannelMemberships(userId string) (*[]UserTeamImpo
func (a *App) buildUserChannelMemberships(userId string, teamId string) (*[]UserChannelImportData, *model.AppError) { func (a *App) buildUserChannelMemberships(userId string, teamId string) (*[]UserChannelImportData, *model.AppError) {
var memberships []UserChannelImportData var memberships []UserChannelImportData
members, err := a.Srv().Store.Channel().GetChannelMembersForExport(userId, teamId) members, nErr := a.Srv().Store.Channel().GetChannelMembersForExport(userId, teamId)
if err != nil { if nErr != nil {
return nil, err return nil, model.NewAppError("buildUserChannelMemberships", "app.channel.get_members.app_error", nil, nErr.Error(), http.StatusInternalServerError)
} }
category := model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL category := model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL
@@ -517,7 +517,7 @@ func (a *App) exportAllDirectChannels(writer io.Writer) *model.AppError {
for { for {
channels, err := a.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, afterId) channels, err := a.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, afterId)
if err != nil { if err != nil {
return err return model.NewAppError("exportAllDirectChannels", "app.channel.get_all_direct.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
if len(channels) == 0 { if len(channels) == 0 {

Просмотреть файл

@@ -231,8 +231,8 @@ func TestExportDMChannel(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir") err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err) require.Nil(t, err)
channels, err := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 1, len(channels)) assert.Equal(t, 1, len(channels))
th1.TearDown() th1.TearDown()
@@ -240,8 +240,8 @@ func TestExportDMChannel(t *testing.T) {
th2 := Setup(t) th2 := Setup(t)
defer th2.TearDown() defer th2.TearDown()
channels, err = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 0, len(channels)) assert.Equal(t, 0, len(channels))
// import the exported channel // import the exported channel
@@ -250,8 +250,8 @@ func TestExportDMChannel(t *testing.T) {
assert.Equal(t, 0, i) assert.Equal(t, 0, i)
// Ensure the Members of the imported DM channel is the same was from the exported // Ensure the Members of the imported DM channel is the same was from the exported
channels, err = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 1, len(channels)) assert.Equal(t, 1, len(channels))
assert.ElementsMatch(t, []string{th1.BasicUser.Username, th1.BasicUser2.Username}, *channels[0].Members) assert.ElementsMatch(t, []string{th1.BasicUser.Username, th1.BasicUser2.Username}, *channels[0].Members)
} }
@@ -267,15 +267,15 @@ func TestExportDMChannelToSelf(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir") err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err) require.Nil(t, err)
channels, err := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 1, len(channels)) assert.Equal(t, 1, len(channels))
th2 := Setup(t) th2 := Setup(t)
defer th2.TearDown() defer th2.TearDown()
channels, err = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 0, len(channels)) assert.Equal(t, 0, len(channels))
// import the exported channel // import the exported channel
@@ -283,8 +283,8 @@ func TestExportDMChannelToSelf(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, 0, i) assert.Equal(t, 0, i)
channels, err = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 1, len(channels)) assert.Equal(t, 1, len(channels))
assert.Equal(t, 1, len((*channels[0].Members))) assert.Equal(t, 1, len((*channels[0].Members)))
assert.Equal(t, th1.BasicUser.Username, (*channels[0].Members)[0]) assert.Equal(t, th1.BasicUser.Username, (*channels[0].Members)[0])
@@ -305,8 +305,8 @@ func TestExportGMChannel(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir") err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err) require.Nil(t, err)
channels, err := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 1, len(channels)) assert.Equal(t, 1, len(channels))
th1.TearDown() th1.TearDown()
@@ -314,8 +314,8 @@ func TestExportGMChannel(t *testing.T) {
th2 := Setup(t) th2 := Setup(t)
defer th2.TearDown() defer th2.TearDown()
channels, err = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 0, len(channels)) assert.Equal(t, 0, len(channels))
} }
@@ -337,8 +337,8 @@ func TestExportGMandDMChannels(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir") err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err) require.Nil(t, err)
channels, err := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 2, len(channels)) assert.Equal(t, 2, len(channels))
th1.TearDown() th1.TearDown()
@@ -346,8 +346,8 @@ func TestExportGMandDMChannels(t *testing.T) {
th2 := Setup(t) th2 := Setup(t)
defer th2.TearDown() defer th2.TearDown()
channels, err = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
assert.Equal(t, 0, len(channels)) assert.Equal(t, 0, len(channels))
// import the exported channel // import the exported channel
@@ -356,8 +356,8 @@ func TestExportGMandDMChannels(t *testing.T) {
assert.Equal(t, 0, i) assert.Equal(t, 0, i)
// Ensure the Members of the imported GM channel is the same was from the exported // Ensure the Members of the imported GM channel is the same was from the exported
channels, err = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000") channels, nErr = th2.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err) require.Nil(t, nErr)
// Adding some deteminism so its possible to assert on slice index // Adding some deteminism so its possible to assert on slice index
sort.Slice(channels, func(i, j int) bool { return channels[i].Type > channels[j].Type }) sort.Slice(channels, func(i, j int) bool { return channels[i].Type > channels[j].Type })

Просмотреть файл

@@ -25,7 +25,7 @@ func (a *App) ResetPermissionsSystem() *model.AppError {
// Reset all Channels to not have a scheme. // Reset all Channels to not have a scheme.
if err := a.Srv().Store.Channel().ResetAllChannelSchemes(); err != nil { if err := a.Srv().Store.Channel().ResetAllChannelSchemes(); err != nil {
return err return model.NewAppError("ResetPermissionsSystem", "app.channel.reset_all_channel_schemes.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
// Reset all Custom Role assignments to Users. // Reset all Custom Role assignments to Users.
@@ -40,7 +40,7 @@ func (a *App) ResetPermissionsSystem() *model.AppError {
// Reset all Custom Role assignments to ChannelMembers. // Reset all Custom Role assignments to ChannelMembers.
if err := a.Srv().Store.Channel().ClearAllCustomRoleAssignments(); err != nil { if err := a.Srv().Store.Channel().ClearAllCustomRoleAssignments(); err != nil {
return err return model.NewAppError("ResetPermissionsSystem", "app.channel.clear_all_custom_role_assignments.select.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
// Purge all schemes from the database. // Purge all schemes from the database.

Просмотреть файл

@@ -188,7 +188,13 @@ func (a *App) GetChannelsForScheme(scheme *model.Scheme, offset int, limit int)
if err := a.IsPhase2MigrationCompleted(); err != nil { if err := a.IsPhase2MigrationCompleted(); err != nil {
return nil, err return nil, err
} }
return a.Srv().Store.Channel().GetChannelsByScheme(scheme.Id, offset, limit)
channelList, nErr := a.Srv().Store.Channel().GetChannelsByScheme(scheme.Id, offset, limit)
if nErr != nil {
return nil, model.NewAppError("GetChannelsForScheme", "app.channel.get_by_scheme.app_error", nil, nErr.Error(), http.StatusInternalServerError)
}
return channelList, nil
} }
func (s *Server) IsPhase2MigrationCompleted() *model.AppError { func (s *Server) IsPhase2MigrationCompleted() *model.AppError {

Просмотреть файл

@@ -209,12 +209,15 @@ func (a *App) SyncSyncableRoles(syncableID string, syncableType model.GroupSynca
nErr := a.Srv().Store.Team().UpdateMembersRole(syncableID, permittedAdmins) nErr := a.Srv().Store.Team().UpdateMembersRole(syncableID, permittedAdmins)
if nErr != nil { if nErr != nil {
// TODO: Should we change the key "store.update_error" to "app.update_error"? It is very general and changing it now will modify lots of files // TODO: Should we change the key "store.update_error" to "app.update_error"? It is very general and changing it now will modify lots of files
return model.NewAppError("SyncSyncableRoles", "store.update_error", nil, nErr.Error(), http.StatusInternalServerError) return model.NewAppError("App.SyncSyncableRoles", "store.update_error", nil, nErr.Error(), http.StatusInternalServerError)
} }
return nil return nil
case model.GroupSyncableTypeChannel: case model.GroupSyncableTypeChannel:
return a.Srv().Store.Channel().UpdateMembersRole(syncableID, permittedAdmins) nErr := a.Srv().Store.Channel().UpdateMembersRole(syncableID, permittedAdmins)
if nErr != nil {
return model.NewAppError("App.SyncSyncableRoles", "store.update_error", nil, nErr.Error(), http.StatusInternalServerError)
}
return nil
default: default:
return model.NewAppError("App.SyncSyncableRoles", "groups.unsupported_syncable_type", map[string]interface{}{"Value": syncableType}, "", http.StatusInternalServerError) return model.NewAppError("App.SyncSyncableRoles", "groups.unsupported_syncable_type", map[string]interface{}{"Value": syncableType}, "", http.StatusInternalServerError)
} }

Просмотреть файл

@@ -2006,7 +2006,12 @@ func (a *App) UserCanSeeOtherUser(userId string, otherUserId string) (bool, *mod
} }
func (a *App) userBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) { func (a *App) userBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
return a.Srv().Store.Channel().UserBelongsToChannels(userId, channelIds) belongs, err := a.Srv().Store.Channel().UserBelongsToChannels(userId, channelIds)
if err != nil {
return false, model.NewAppError("userBelongsToChannels", "app.channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return belongs, nil
} }
func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError) { func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError) {

Просмотреть файл

@@ -3506,6 +3506,10 @@
"id": "app.channel.analytics_type_count.app_error", "id": "app.channel.analytics_type_count.app_error",
"translation": "Unable to get channel type counts." "translation": "Unable to get channel type counts."
}, },
{
"id": "app.channel.clear_all_custom_role_assignments.select.app_error",
"translation": "Failed to retrieve the channel members."
},
{ {
"id": "app.channel.count_posts_since.app_error", "id": "app.channel.count_posts_since.app_error",
"translation": "Unable to count messages since given date." "translation": "Unable to count messages since given date."
@@ -3538,6 +3542,10 @@
"id": "app.channel.get.find.app_error", "id": "app.channel.get.find.app_error",
"translation": "We encountered an error finding the channel." "translation": "We encountered an error finding the channel."
}, },
{
"id": "app.channel.get_all.app_error",
"translation": "Unable to get all the channels."
},
{ {
"id": "app.channel.get_all_channels.app_error", "id": "app.channel.get_all_channels.app_error",
"translation": "Unable to get all the channels." "translation": "Unable to get all the channels."
@@ -3546,6 +3554,10 @@
"id": "app.channel.get_all_channels_count.app_error", "id": "app.channel.get_all_channels_count.app_error",
"translation": "Unable to count all the channels." "translation": "Unable to count all the channels."
}, },
{
"id": "app.channel.get_all_direct.app_error",
"translation": "Unable to get all the direct channels."
},
{ {
"id": "app.channel.get_by_name.existing.app_error", "id": "app.channel.get_by_name.existing.app_error",
"translation": "Unable to find the existing channel." "translation": "Unable to find the existing channel."
@@ -3554,6 +3566,10 @@
"id": "app.channel.get_by_name.missing.app_error", "id": "app.channel.get_by_name.missing.app_error",
"translation": "Channel does not exist." "translation": "Channel does not exist."
}, },
{
"id": "app.channel.get_by_scheme.app_error",
"translation": "Unable to get the channels for the provided scheme."
},
{ {
"id": "app.channel.get_channel_counts.get.app_error", "id": "app.channel.get_channel_counts.get.app_error",
"translation": "Unable to get the channel counts." "translation": "Unable to get the channel counts."
@@ -3566,6 +3582,10 @@
"id": "app.channel.get_channels.not_found.app_error", "id": "app.channel.get_channels.not_found.app_error",
"translation": "No channels were found." "translation": "No channels were found."
}, },
{
"id": "app.channel.get_channels_batch_for_indexing.get.app_error",
"translation": "Unable to get the channels batch for indexing."
},
{ {
"id": "app.channel.get_channels_by_ids.app_error", "id": "app.channel.get_channels_by_ids.app_error",
"translation": "Unable to get channels by ids." "translation": "Unable to get channels by ids."
@@ -3606,6 +3626,10 @@
"id": "app.channel.get_members.app_error", "id": "app.channel.get_members.app_error",
"translation": "Unable to get the channel members." "translation": "Unable to get the channel members."
}, },
{
"id": "app.channel.get_members_by_ids.app_error",
"translation": "Unable to get the channel members."
},
{ {
"id": "app.channel.get_more_channels.get.app_error", "id": "app.channel.get_more_channels.get.app_error",
"translation": "Unable to get the channels." "translation": "Unable to get the channels."
@@ -3622,10 +3646,18 @@
"id": "app.channel.get_public_channels.get.app_error", "id": "app.channel.get_public_channels.get.app_error",
"translation": "Unable to get public channels." "translation": "Unable to get public channels."
}, },
{
"id": "app.channel.get_unread.app_error",
"translation": "Unable to get the channel unread messages."
},
{ {
"id": "app.channel.increment_mention_count.app_error", "id": "app.channel.increment_mention_count.app_error",
"translation": "Unable to increment the mention count." "translation": "Unable to increment the mention count."
}, },
{
"id": "app.channel.migrate_channel_members.select.app_error",
"translation": "Failed to select the batch of channel members."
},
{ {
"id": "app.channel.move_channel.members_do_not_match.error", "id": "app.channel.move_channel.members_do_not_match.error",
"translation": "Unable to move a channel unless all its members are already members of the destination team." "translation": "Unable to move a channel unless all its members are already members of the destination team."
@@ -3662,10 +3694,18 @@
"id": "app.channel.post_update_channel_purpose_message.updated_to", "id": "app.channel.post_update_channel_purpose_message.updated_to",
"translation": "%s updated the channel purpose to: %s" "translation": "%s updated the channel purpose to: %s"
}, },
{
"id": "app.channel.remove_all_deactivated_members.app_error",
"translation": "We could not remove the deactivated users from the channel."
},
{ {
"id": "app.channel.remove_member.app_error", "id": "app.channel.remove_member.app_error",
"translation": "Unable to remove the channel member." "translation": "Unable to remove the channel member."
}, },
{
"id": "app.channel.reset_all_channel_schemes.app_error",
"translation": "We could not reset the channel schemes."
},
{ {
"id": "app.channel.restore.app_error", "id": "app.channel.restore.app_error",
"translation": "Unable to restore the channel." "translation": "Unable to restore the channel."
@@ -3674,6 +3714,14 @@
"id": "app.channel.save_member.exists.app_error", "id": "app.channel.save_member.exists.app_error",
"translation": "" "translation": ""
}, },
{
"id": "app.channel.search.app_error",
"translation": "We encountered an error searching channels."
},
{
"id": "app.channel.search_group_channels.app_error",
"translation": "Unable to get the group channels for the given user and term."
},
{ {
"id": "app.channel.sidebar_categories.app_error", "id": "app.channel.sidebar_categories.app_error",
"translation": "Failed to insert record to database." "translation": "Failed to insert record to database."
@@ -3694,6 +3742,10 @@
"id": "app.channel.update_last_viewed_at_post.app_error", "id": "app.channel.update_last_viewed_at_post.app_error",
"translation": "Unable to mark channel as unread." "translation": "Unable to mark channel as unread."
}, },
{
"id": "app.channel.user_belongs_to_channels.app_error",
"translation": "Unable to determine if the user belongs to a list of channels."
},
{ {
"id": "app.channel_member_history.log_join_event.internal_error", "id": "app.channel_member_history.log_join_event.internal_error",
"translation": "Failed to record channel member history." "translation": "Failed to record channel member history."
@@ -5806,6 +5858,10 @@
"id": "ent.elasticsearch.index_channel.error", "id": "ent.elasticsearch.index_channel.error",
"translation": "Failed to index the channel" "translation": "Failed to index the channel"
}, },
{
"id": "ent.elasticsearch.index_channels_batch.error",
"translation": "Unable to get the channels batch for indexing."
},
{ {
"id": "ent.elasticsearch.index_post.error", "id": "ent.elasticsearch.index_post.error",
"translation": "Failed to index the post" "translation": "Failed to index the post"
@@ -7726,10 +7782,6 @@
"id": "store.select_error", "id": "store.select_error",
"translation": "select error" "translation": "select error"
}, },
{
"id": "store.sql.build_query.app_error",
"translation": "failed to build query."
},
{ {
"id": "store.sql.convert_string_array", "id": "store.sql.convert_string_array",
"translation": "FromDb: Unable to convert StringArray to *string" "translation": "FromDb: Unable to convert StringArray to *string"
@@ -7746,26 +7798,6 @@
"id": "store.sql_bot.get.missing.app_error", "id": "store.sql_bot.get.missing.app_error",
"translation": "Bot does not exist." "translation": "Bot does not exist."
}, },
{
"id": "store.sql_channel.analytics_deleted_type_count.app_error",
"translation": "Unable to get deleted channel type counts."
},
{
"id": "store.sql_channel.clear_all_custom_role_assignments.commit_transaction.app_error",
"translation": "Failed to commit the database transaction."
},
{
"id": "store.sql_channel.clear_all_custom_role_assignments.open_transaction.app_error",
"translation": "Failed to begin the database transaction."
},
{
"id": "store.sql_channel.clear_all_custom_role_assignments.select.app_error",
"translation": "Failed to retrieve the channel members."
},
{
"id": "store.sql_channel.clear_all_custom_role_assignments.update.app_error",
"translation": "Failed to update the channel member."
},
{ {
"id": "store.sql_channel.get.existing.app_error", "id": "store.sql_channel.get.existing.app_error",
"translation": "Unable to find the existing channel." "translation": "Unable to find the existing channel."
@@ -7774,62 +7806,6 @@
"id": "store.sql_channel.get.find.app_error", "id": "store.sql_channel.get.find.app_error",
"translation": "We encountered an error finding the channel." "translation": "We encountered an error finding the channel."
}, },
{
"id": "store.sql_channel.get_all.app_error",
"translation": "Unable to get all the channels."
},
{
"id": "store.sql_channel.get_all_direct.app_error",
"translation": "Unable to get all the direct channels."
},
{
"id": "store.sql_channel.get_by_scheme.app_error",
"translation": "Unable to get the channels for the provided scheme."
},
{
"id": "store.sql_channel.get_channels_batch_for_indexing.get.app_error",
"translation": "Unable to get the channels batch for indexing."
},
{
"id": "store.sql_channel.get_members_by_ids.app_error",
"translation": "Unable to get the channel members."
},
{
"id": "store.sql_channel.get_unread.app_error",
"translation": "Unable to get the channel unread messages."
},
{
"id": "store.sql_channel.migrate_channel_members.commit_transaction.app_error",
"translation": "Failed to commit the database transaction."
},
{
"id": "store.sql_channel.migrate_channel_members.open_transaction.app_error",
"translation": "Failed to open the database transaction."
},
{
"id": "store.sql_channel.migrate_channel_members.select.app_error",
"translation": "Failed to select the batch of channel members."
},
{
"id": "store.sql_channel.migrate_channel_members.update.app_error",
"translation": "Failed to update the channel member."
},
{
"id": "store.sql_channel.remove_all_deactivated_members.app_error",
"translation": "We could not remove the deactivated users from the channel."
},
{
"id": "store.sql_channel.reset_all_channel_schemes.app_error",
"translation": "We could not reset the channel schemes."
},
{
"id": "store.sql_channel.reset_all_channel_schemes.commit_transaction.app_error",
"translation": "Unable to commit transaction."
},
{
"id": "store.sql_channel.reset_all_channel_schemes.open_transaction.app_error",
"translation": "Unable to open transaction."
},
{ {
"id": "store.sql_channel.save.archived_channel.app_error", "id": "store.sql_channel.save.archived_channel.app_error",
"translation": "You can not modify an archived channel." "translation": "You can not modify an archived channel."
@@ -7854,34 +7830,6 @@
"id": "store.sql_channel.save_direct_channel.not_direct.app_error", "id": "store.sql_channel.save_direct_channel.not_direct.app_error",
"translation": "Not a direct channel attempted to be created with SaveDirectChannel." "translation": "Not a direct channel attempted to be created with SaveDirectChannel."
}, },
{
"id": "store.sql_channel.search.app_error",
"translation": "We encountered an error searching channels."
},
{
"id": "store.sql_channel.search_group_channels.app_error",
"translation": "Unable to get the group channels for the given user and term."
},
{
"id": "store.sql_channel.sidebar_categories.app_error",
"translation": "Failed to insert record to database."
},
{
"id": "store.sql_channel.sidebar_categories.commit_transaction.app_error",
"translation": "Unable to commit transaction."
},
{
"id": "store.sql_channel.sidebar_categories.delete_invalid.app_error",
"translation": "Unable to delete non-custom category."
},
{
"id": "store.sql_channel.sidebar_categories.open_transaction.app_error",
"translation": "Failed to open the database transaction."
},
{
"id": "store.sql_channel.user_belongs_to_channels.app_error",
"translation": "Unable to determine if the user belongs to a list of channels."
},
{ {
"id": "store.sql_command.get.missing.app_error", "id": "store.sql_command.get.missing.app_error",
"translation": "Command does not exist." "translation": "Command does not exist."

Просмотреть файл

@@ -87,7 +87,7 @@ func (worker *Worker) runAdvancedPermissionsPhase2Migration(lastDone string) (bo
} else if progress.CurrentTable == "ChannelMembers" { } else if progress.CurrentTable == "ChannelMembers" {
// Run a ChannelMembers migration batch. // Run a ChannelMembers migration batch.
if data, err := worker.srv.Store.Channel().MigrateChannelMembers(progress.LastChannelId, progress.LastUserId); err != nil { if data, err := worker.srv.Store.Channel().MigrateChannelMembers(progress.LastChannelId, progress.LastUserId); err != nil {
return false, progress.ToJson(), err return false, progress.ToJson(), model.NewAppError("MigrationsWorker.runAdvancedPermissionsPhase2Migration", "app.channel.migrate_channel_members.select.app_error", nil, err.Error(), http.StatusInternalServerError)
} else { } else {
if data == nil { if data == nil {
// We haven't progressed. That means we've reached the end of this final stage of the migration. // We haven't progressed. That means we've reached the end of this final stage of the migration.

Просмотреть файл

@@ -362,14 +362,14 @@ func (worker *BleveIndexerWorker) IndexChannelsBatch(progress IndexingProgress)
tries := 0 tries := 0
for channels == nil { for channels == nil {
var err *model.AppError var nErr error
channels, err = worker.jobServer.Store.Channel().GetChannelsBatchForIndexing(progress.LastEntityTime, endTime, BATCH_SIZE) channels, nErr = worker.jobServer.Store.Channel().GetChannelsBatchForIndexing(progress.LastEntityTime, endTime, BATCH_SIZE)
if err != nil { if nErr != nil {
if tries >= 10 { if tries >= 10 {
return progress, err return progress, model.NewAppError("BleveIndexerWorker.IndexChannelsBatch", "app.channel.get_channels_batch_for_indexing.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
} }
mlog.Warn("Failed to get channels batch for indexing. Retrying.", mlog.Err(err)) mlog.Warn("Failed to get channels batch for indexing. Retrying.", mlog.Err(nErr))
// Wait a bit before trying again. // Wait a bit before trying again.
time.Sleep(15 * time.Second) time.Sleep(15 * time.Second)

Просмотреть файл

@@ -1083,9 +1083,9 @@ func (ts *TelemetryService) trackGroups() {
mlog.Error(nErr.Error()) mlog.Error(nErr.Error())
} }
groupSyncedChannelCount, err := ts.dbStore.Channel().GroupSyncedChannelCount() groupSyncedChannelCount, nErr := ts.dbStore.Channel().GroupSyncedChannelCount()
if err != nil { if nErr != nil {
mlog.Error(err.Error()) mlog.Error(nErr.Error())
} }
groupMemberCount, err := ts.dbStore.Group().GroupMemberCount() groupMemberCount, err := ts.dbStore.Group().GroupMemberCount()

Просмотреть файл

@@ -504,7 +504,7 @@ func (s *OpenTracingLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError) { func (s *OpenTracingLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AnalyticsDeletedTypeCount") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AnalyticsDeletedTypeCount")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -540,7 +540,7 @@ func (s *OpenTracingLayerChannelStore) AnalyticsTypeCount(teamId string, channel
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeam") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeam")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -558,7 +558,7 @@ func (s *OpenTracingLayerChannelStore) AutocompleteInTeam(teamId string, term st
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeamForSearch") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeamForSearch")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -576,7 +576,7 @@ func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamId string
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) ClearAllCustomRoleAssignments() *model.AppError { func (s *OpenTracingLayerChannelStore) ClearAllCustomRoleAssignments() error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.ClearAllCustomRoleAssignments") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.ClearAllCustomRoleAssignments")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -679,7 +679,7 @@ func (s *OpenTracingLayerChannelStore) CreateInitialSidebarCategories(userId str
return err return err
} }
func (s *OpenTracingLayerChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s *OpenTracingLayerChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.CreateSidebarCategory") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.CreateSidebarCategory")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -715,7 +715,7 @@ func (s *OpenTracingLayerChannelStore) Delete(channelId string, time int64) erro
return err return err
} }
func (s *OpenTracingLayerChannelStore) DeleteSidebarCategory(categoryId string) *model.AppError { func (s *OpenTracingLayerChannelStore) DeleteSidebarCategory(categoryId string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.DeleteSidebarCategory") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.DeleteSidebarCategory")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -859,7 +859,7 @@ func (s *OpenTracingLayerChannelStore) GetAllChannelsCount(opts store.ChannelSea
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetAllChannelsForExportAfter") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetAllChannelsForExportAfter")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -877,7 +877,7 @@ func (s *OpenTracingLayerChannelStore) GetAllChannelsForExportAfter(limit int, a
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetAllDirectChannelsForExportAfter") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetAllDirectChannelsForExportAfter")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -967,7 +967,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelCounts(teamId string, userId st
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelMembersForExport") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelMembersForExport")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1003,7 +1003,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelMembersTimezones(channelId stri
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelUnread") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelUnread")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1039,7 +1039,7 @@ func (s *OpenTracingLayerChannelStore) GetChannels(teamId string, userId string,
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelsBatchForIndexing") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelsBatchForIndexing")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1075,7 +1075,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelsByIds(channelIds []string, inc
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelsByScheme") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelsByScheme")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1286,7 +1286,7 @@ func (s *OpenTracingLayerChannelStore) GetMembers(channelId string, offset int,
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembersByIds") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembersByIds")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1448,7 +1448,7 @@ func (s *OpenTracingLayerChannelStore) GetPublicChannelsForTeam(teamId string, o
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategories") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategories")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1466,7 +1466,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategories(userId string, teamI
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategory") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategory")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1484,7 +1484,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategory(categoryId string) (*m
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, *model.AppError) { func (s *OpenTracingLayerChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategoryOrder") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategoryOrder")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1520,7 +1520,7 @@ func (s *OpenTracingLayerChannelStore) GetTeamChannels(teamId string) (*model.Ch
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) { func (s *OpenTracingLayerChannelStore) GroupSyncedChannelCount() (int64, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GroupSyncedChannelCount") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GroupSyncedChannelCount")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1660,7 +1660,7 @@ func (s *OpenTracingLayerChannelStore) IsUserInChannelUseCache(userId string, ch
return result return result
} }
func (s *OpenTracingLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError) { func (s *OpenTracingLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.MigrateChannelMembers") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.MigrateChannelMembers")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1768,7 +1768,7 @@ func (s *OpenTracingLayerChannelStore) PermanentDeleteMembersByUser(userId strin
return err return err
} }
func (s *OpenTracingLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError { func (s *OpenTracingLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.RemoveAllDeactivatedMembers") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.RemoveAllDeactivatedMembers")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1822,7 +1822,7 @@ func (s *OpenTracingLayerChannelStore) RemoveMembers(channelId string, userIds [
return err return err
} }
func (s *OpenTracingLayerChannelStore) ResetAllChannelSchemes() *model.AppError { func (s *OpenTracingLayerChannelStore) ResetAllChannelSchemes() error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.ResetAllChannelSchemes") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.ResetAllChannelSchemes")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1930,7 +1930,7 @@ func (s *OpenTracingLayerChannelStore) SaveMultipleMembers(members []*model.Chan
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) { func (s *OpenTracingLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchAllChannels") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchAllChannels")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1948,7 +1948,7 @@ func (s *OpenTracingLayerChannelStore) SearchAllChannels(term string, opts store
return result, resultVar1, err return result, resultVar1, err
} }
func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchArchivedInTeam") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchArchivedInTeam")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1966,7 +1966,7 @@ func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamId string, term
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchForUserInTeam") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchForUserInTeam")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -1984,7 +1984,7 @@ func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userId string, teamId
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchGroupChannels") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchGroupChannels")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -2002,7 +2002,7 @@ func (s *OpenTracingLayerChannelStore) SearchGroupChannels(userId string, term s
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchInTeam") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchInTeam")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -2020,7 +2020,7 @@ func (s *OpenTracingLayerChannelStore) SearchInTeam(teamId string, term string,
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError) { func (s *OpenTracingLayerChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchMore") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchMore")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -2128,7 +2128,7 @@ func (s *OpenTracingLayerChannelStore) UpdateMember(member *model.ChannelMember)
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) *model.AppError { func (s *OpenTracingLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateMembersRole") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateMembersRole")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -2164,7 +2164,7 @@ func (s *OpenTracingLayerChannelStore) UpdateMultipleMembers(members []*model.Ch
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) { func (s *OpenTracingLayerChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategories") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategories")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -2182,7 +2182,7 @@ func (s *OpenTracingLayerChannelStore) UpdateSidebarCategories(userId string, te
return result, err return result, err
} }
func (s *OpenTracingLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) *model.AppError { func (s *OpenTracingLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategoryOrder") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategoryOrder")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -2236,7 +2236,7 @@ func (s *OpenTracingLayerChannelStore) UpdateSidebarChannelsByPreferences(prefer
return err return err
} }
func (s *OpenTracingLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) { func (s *OpenTracingLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UserBelongsToChannels") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UserBelongsToChannels")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)

Просмотреть файл

@@ -538,9 +538,23 @@ func (s *RetryLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
} }
func (s *RetryLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError) { func (s *RetryLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error) {
return s.ChannelStore.AnalyticsDeletedTypeCount(teamId, channelType) tries := 0
for {
result, err := s.ChannelStore.AnalyticsDeletedTypeCount(teamId, channelType)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -564,21 +578,63 @@ func (s *RetryLayerChannelStore) AnalyticsTypeCount(teamId string, channelType s
} }
func (s *RetryLayerChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
return s.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted) tries := 0
for {
result, err := s.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
return s.ChannelStore.AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted) tries := 0
for {
result, err := s.ChannelStore.AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) ClearAllCustomRoleAssignments() *model.AppError { func (s *RetryLayerChannelStore) ClearAllCustomRoleAssignments() error {
return s.ChannelStore.ClearAllCustomRoleAssignments() tries := 0
for {
err := s.ChannelStore.ClearAllCustomRoleAssignments()
if err == nil {
return nil
}
if !isRepeatableError(err) {
return err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return err
}
}
} }
@@ -668,9 +724,23 @@ func (s *RetryLayerChannelStore) CreateInitialSidebarCategories(userId string, t
} }
func (s *RetryLayerChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s *RetryLayerChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
return s.ChannelStore.CreateSidebarCategory(userId, teamId, newCategory) tries := 0
for {
result, err := s.ChannelStore.CreateSidebarCategory(userId, teamId, newCategory)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -694,9 +764,23 @@ func (s *RetryLayerChannelStore) Delete(channelId string, time int64) error {
} }
func (s *RetryLayerChannelStore) DeleteSidebarCategory(categoryId string) *model.AppError { func (s *RetryLayerChannelStore) DeleteSidebarCategory(categoryId string) error {
return s.ChannelStore.DeleteSidebarCategory(categoryId) tries := 0
for {
err := s.ChannelStore.DeleteSidebarCategory(categoryId)
if err == nil {
return nil
}
if !isRepeatableError(err) {
return err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return err
}
}
} }
@@ -840,15 +924,43 @@ func (s *RetryLayerChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpt
} }
func (s *RetryLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) { func (s *RetryLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error) {
return s.ChannelStore.GetAllChannelsForExportAfter(limit, afterId) tries := 0
for {
result, err := s.ChannelStore.GetAllChannelsForExportAfter(limit, afterId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, *model.AppError) { func (s *RetryLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error) {
return s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterId) tries := 0
for {
result, err := s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -932,9 +1044,23 @@ func (s *RetryLayerChannelStore) GetChannelCounts(teamId string, userId string)
} }
func (s *RetryLayerChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) { func (s *RetryLayerChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error) {
return s.ChannelStore.GetChannelMembersForExport(userId, teamId) tries := 0
for {
result, err := s.ChannelStore.GetChannelMembersForExport(userId, teamId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -958,9 +1084,23 @@ func (s *RetryLayerChannelStore) GetChannelMembersTimezones(channelId string) ([
} }
func (s *RetryLayerChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, *model.AppError) { func (s *RetryLayerChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, error) {
return s.ChannelStore.GetChannelUnread(channelId, userId) tries := 0
for {
result, err := s.ChannelStore.GetChannelUnread(channelId, userId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -984,9 +1124,23 @@ func (s *RetryLayerChannelStore) GetChannels(teamId string, userId string, inclu
} }
func (s *RetryLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, *model.AppError) { func (s *RetryLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, error) {
return s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit) tries := 0
for {
result, err := s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -1010,9 +1164,23 @@ func (s *RetryLayerChannelStore) GetChannelsByIds(channelIds []string, includeDe
} }
func (s *RetryLayerChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error) {
return s.ChannelStore.GetChannelsByScheme(schemeId, offset, limit) tries := 0
for {
result, err := s.ChannelStore.GetChannelsByScheme(schemeId, offset, limit)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -1222,9 +1390,23 @@ func (s *RetryLayerChannelStore) GetMembers(channelId string, offset int, limit
} }
func (s *RetryLayerChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { func (s *RetryLayerChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error) {
return s.ChannelStore.GetMembersByIds(channelId, userIds) tries := 0
for {
result, err := s.ChannelStore.GetMembersByIds(channelId, userIds)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -1388,21 +1570,63 @@ func (s *RetryLayerChannelStore) GetPublicChannelsForTeam(teamId string, offset
} }
func (s *RetryLayerChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, *model.AppError) { func (s *RetryLayerChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, error) {
return s.ChannelStore.GetSidebarCategories(userId, teamId) tries := 0
for {
result, err := s.ChannelStore.GetSidebarCategories(userId, teamId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s *RetryLayerChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error) {
return s.ChannelStore.GetSidebarCategory(categoryId) tries := 0
for {
result, err := s.ChannelStore.GetSidebarCategory(categoryId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, *model.AppError) { func (s *RetryLayerChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, error) {
return s.ChannelStore.GetSidebarCategoryOrder(userId, teamId) tries := 0
for {
result, err := s.ChannelStore.GetSidebarCategoryOrder(userId, teamId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -1426,9 +1650,23 @@ func (s *RetryLayerChannelStore) GetTeamChannels(teamId string) (*model.ChannelL
} }
func (s *RetryLayerChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) { func (s *RetryLayerChannelStore) GroupSyncedChannelCount() (int64, error) {
return s.ChannelStore.GroupSyncedChannelCount() tries := 0
for {
result, err := s.ChannelStore.GroupSyncedChannelCount()
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -1500,9 +1738,23 @@ func (s *RetryLayerChannelStore) IsUserInChannelUseCache(userId string, channelI
} }
func (s *RetryLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError) { func (s *RetryLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error) {
return s.ChannelStore.MigrateChannelMembers(fromChannelId, fromUserId) tries := 0
for {
result, err := s.ChannelStore.MigrateChannelMembers(fromChannelId, fromUserId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -1606,9 +1858,23 @@ func (s *RetryLayerChannelStore) PermanentDeleteMembersByUser(userId string) err
} }
func (s *RetryLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError { func (s *RetryLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
return s.ChannelStore.RemoveAllDeactivatedMembers(channelId) tries := 0
for {
err := s.ChannelStore.RemoveAllDeactivatedMembers(channelId)
if err == nil {
return nil
}
if !isRepeatableError(err) {
return err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return err
}
}
} }
@@ -1652,9 +1918,23 @@ func (s *RetryLayerChannelStore) RemoveMembers(channelId string, userIds []strin
} }
func (s *RetryLayerChannelStore) ResetAllChannelSchemes() *model.AppError { func (s *RetryLayerChannelStore) ResetAllChannelSchemes() error {
return s.ChannelStore.ResetAllChannelSchemes() tries := 0
for {
err := s.ChannelStore.ResetAllChannelSchemes()
if err == nil {
return nil
}
if !isRepeatableError(err) {
return err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return err
}
}
} }
@@ -1758,39 +2038,123 @@ func (s *RetryLayerChannelStore) SaveMultipleMembers(members []*model.ChannelMem
} }
func (s *RetryLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) { func (s *RetryLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
return s.ChannelStore.SearchAllChannels(term, opts) tries := 0
for {
result, resultVar1, err := s.ChannelStore.SearchAllChannels(term, opts)
if err == nil {
return result, resultVar1, nil
}
if !isRepeatableError(err) {
return result, resultVar1, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, resultVar1, err
}
}
} }
func (s *RetryLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) {
return s.ChannelStore.SearchArchivedInTeam(teamId, term, userId) tries := 0
for {
result, err := s.ChannelStore.SearchArchivedInTeam(teamId, term, userId)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
return s.ChannelStore.SearchForUserInTeam(userId, teamId, term, includeDeleted) tries := 0
for {
result, err := s.ChannelStore.SearchForUserInTeam(userId, teamId, term, includeDeleted)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, error) {
return s.ChannelStore.SearchGroupChannels(userId, term) tries := 0
for {
result, err := s.ChannelStore.SearchGroupChannels(userId, term)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
return s.ChannelStore.SearchInTeam(teamId, term, includeDeleted) tries := 0
for {
result, err := s.ChannelStore.SearchInTeam(teamId, term, includeDeleted)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError) { func (s *RetryLayerChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error) {
return s.ChannelStore.SearchMore(userId, teamId, term) tries := 0
for {
result, err := s.ChannelStore.SearchMore(userId, teamId, term)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
@@ -1894,9 +2258,23 @@ func (s *RetryLayerChannelStore) UpdateMember(member *model.ChannelMember) (*mod
} }
func (s *RetryLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) *model.AppError { func (s *RetryLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
return s.ChannelStore.UpdateMembersRole(channelID, userIDs) tries := 0
for {
err := s.ChannelStore.UpdateMembersRole(channelID, userIDs)
if err == nil {
return nil
}
if !isRepeatableError(err) {
return err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return err
}
}
} }
@@ -1920,15 +2298,43 @@ func (s *RetryLayerChannelStore) UpdateMultipleMembers(members []*model.ChannelM
} }
func (s *RetryLayerChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) { func (s *RetryLayerChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, error) {
return s.ChannelStore.UpdateSidebarCategories(userId, teamId, categories) tries := 0
for {
result, err := s.ChannelStore.UpdateSidebarCategories(userId, teamId, categories)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }
func (s *RetryLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) *model.AppError { func (s *RetryLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) error {
return s.ChannelStore.UpdateSidebarCategoryOrder(userId, teamId, categoryOrder) tries := 0
for {
err := s.ChannelStore.UpdateSidebarCategoryOrder(userId, teamId, categoryOrder)
if err == nil {
return nil
}
if !isRepeatableError(err) {
return err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return err
}
}
} }
@@ -1972,9 +2378,23 @@ func (s *RetryLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences
} }
func (s *RetryLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) { func (s *RetryLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
return s.ChannelStore.UserBelongsToChannels(userId, channelIds) tries := 0
for {
result, err := s.ChannelStore.UserBelongsToChannels(userId, channelIds)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
} }

Просмотреть файл

@@ -128,16 +128,17 @@ func (c *SearchChannelStore) SaveDirectChannel(directchannel *model.Channel, mem
return channel, err return channel, err
} }
func (c *SearchChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (c *SearchChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
var channelList *model.ChannelList var channelList *model.ChannelList
var err *model.AppError var appErr *model.AppError
var nErr error
allFailed := true allFailed := true
for _, engine := range c.rootStore.searchEngine.GetActiveEngines() { for _, engine := range c.rootStore.searchEngine.GetActiveEngines() {
if engine.IsAutocompletionEnabled() { if engine.IsAutocompletionEnabled() {
channelList, err = c.searchAutocompleteChannels(engine, teamId, term, includeDeleted) channelList, appErr = c.searchAutocompleteChannels(engine, teamId, term, includeDeleted)
if err != nil { if appErr != nil {
mlog.Error("Encountered error on AutocompleteChannels through SearchEngine. Falling back to default autocompletion.", mlog.String("search_engine", engine.GetName()), mlog.Err(err)) mlog.Error("Encountered error on AutocompleteChannels through SearchEngine. Falling back to default autocompletion.", mlog.String("search_engine", engine.GetName()), mlog.Err(appErr))
continue continue
} }
allFailed = false allFailed = false
@@ -148,12 +149,17 @@ func (c *SearchChannelStore) AutocompleteInTeam(teamId string, term string, incl
if allFailed { if allFailed {
mlog.Debug("Using database search because no other search engine is available") mlog.Debug("Using database search because no other search engine is available")
channelList, err = c.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted) channelList, nErr = c.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted)
if err != nil { if nErr != nil {
return nil, err return nil, model.NewAppError("AutocompleteInTeam", "app.channel.search.app_error", nil, nErr.Error(), http.StatusInternalServerError)
} }
} }
return channelList, err
if appErr != nil {
return channelList, appErr
}
return channelList, nil
} }
func (c *SearchChannelStore) searchAutocompleteChannels(engine searchengine.SearchEngineInterface, teamId, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (c *SearchChannelStore) searchAutocompleteChannels(engine searchengine.SearchEngineInterface, teamId, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
@@ -185,7 +191,7 @@ func (c *SearchChannelStore) PermanentDeleteMembersByUser(userId string) error {
return err return err
} }
func (c *SearchChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError { func (c *SearchChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
profiles, errProfiles := c.rootStore.User().GetAllProfilesInChannel(channelId, true) profiles, errProfiles := c.rootStore.User().GetAllProfilesInChannel(channelId, true)
if errProfiles != nil { if errProfiles != nil {
mlog.Error("Encountered error indexing users for channel", mlog.String("channel_id", channelId), mlog.Err(errProfiles)) mlog.Error("Encountered error indexing users for channel", mlog.String("channel_id", channelId), mlog.Err(errProfiles))

Просмотреть файл

@@ -6,7 +6,6 @@ package sqlstore
import ( import (
"database/sql" "database/sql"
"fmt" "fmt"
"net/http"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@@ -707,7 +706,7 @@ func (s SqlChannelStore) updateChannelT(transaction *gorp.Transaction, channel *
return channel, nil return channel, nil
} }
func (s SqlChannelStore) GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError) { func (s SqlChannelStore) GetChannelUnread(channelId, userId string) (*model.ChannelUnread, error) {
var unreadChannel model.ChannelUnread var unreadChannel model.ChannelUnread
err := s.GetReplica().SelectOne(&unreadChannel, err := s.GetReplica().SelectOne(&unreadChannel,
`SELECT `SELECT
@@ -723,9 +722,9 @@ func (s SqlChannelStore) GetChannelUnread(channelId, userId string) (*model.Chan
if err != nil { if err != nil {
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
return nil, model.NewAppError("SqlChannelStore.GetChannelUnread", "store.sql_channel.get_unread.app_error", nil, "channelId="+channelId+" "+err.Error(), http.StatusNotFound) return nil, store.NewErrNotFound("Channel", fmt.Sprintf("channelId=%s,userId=%s", channelId, userId))
} }
return nil, model.NewAppError("SqlChannelStore.GetChannelUnread", "store.sql_channel.get_unread.app_error", nil, "channelId="+channelId+" "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to get Channel with channelId=%s and userId=%s", channelId, userId)
} }
return &unreadChannel, nil return &unreadChannel, nil
} }
@@ -2015,7 +2014,7 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) error {
return s.RemoveMembers(channelId, []string{userId}) return s.RemoveMembers(channelId, []string{userId})
} }
func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError { func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
query := ` query := `
DELETE DELETE
FROM FROM
@@ -2035,7 +2034,7 @@ func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.Ap
_, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId}) _, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId})
if err != nil { if err != nil {
return model.NewAppError("SqlChannelStore.RemoveAllDeactivatedMembers", "store.sql_channel.remove_all_deactivated_members.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete ChannelMembers with channelId=%s", channelId)
} }
return nil return nil
} }
@@ -2306,7 +2305,7 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) (
return value, nil return value, nil
} }
func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError) { func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error) {
query := "SELECT COUNT(Id) AS Value FROM Channels WHERE Type = :ChannelType AND DeleteAt > 0" query := "SELECT COUNT(Id) AS Value FROM Channels WHERE Type = :ChannelType AND DeleteAt > 0"
if len(teamId) > 0 { if len(teamId) > 0 {
@@ -2315,7 +2314,7 @@ func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType st
v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId, "ChannelType": channelType}) v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId, "ChannelType": channelType})
if err != nil { if err != nil {
return 0, model.NewAppError("SqlChannelStore.AnalyticsDeletedTypeCount", "store.sql_channel.analytics_deleted_type_count.app_error", nil, err.Error(), http.StatusInternalServerError) return 0, errors.Wrapf(err, "failed to count Channels with teamId=%s and channelType=%s", teamId, channelType)
} }
return v, nil return v, nil
@@ -2343,7 +2342,7 @@ func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string,
return dbMembers.ToModel(), nil return dbMembers.ToModel(), nil
} }
func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
deleteFilter := "AND Channels.DeleteAt = 0" deleteFilter := "AND Channels.DeleteAt = 0"
if includeDeleted { if includeDeleted {
deleteFilter = "" deleteFilter = ""
@@ -2366,7 +2365,7 @@ func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeD
if likeClause, likeTerm := s.buildLIKEClause(term, "c.Name, c.DisplayName, c.Purpose"); likeClause == "" { if likeClause, likeTerm := s.buildLIKEClause(term, "c.Name, c.DisplayName, c.Purpose"); likeClause == "" {
if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"TeamId": teamId}); err != nil { if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"TeamId": teamId}); err != nil {
return nil, model.NewAppError("SqlChannelStore.AutocompleteInTeam", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
} else { } else {
// Using a UNION results in index_merge and fulltext queries and is much faster than the ref // Using a UNION results in index_merge and fulltext queries and is much faster than the ref
@@ -2377,7 +2376,7 @@ func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeD
query := fmt.Sprintf("(%v) UNION (%v) LIMIT 50", likeQuery, fulltextQuery) query := fmt.Sprintf("(%v) UNION (%v) LIMIT 50", likeQuery, fulltextQuery)
if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "LikeTerm": likeTerm, "FulltextTerm": fulltextTerm}); err != nil { if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "LikeTerm": likeTerm, "FulltextTerm": fulltextTerm}); err != nil {
return nil, model.NewAppError("SqlChannelStore.AutocompleteInTeam", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
} }
@@ -2387,7 +2386,7 @@ func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeD
return &channels, nil return &channels, nil
} }
func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
deleteFilter := "AND DeleteAt = 0" deleteFilter := "AND DeleteAt = 0"
if includeDeleted { if includeDeleted {
deleteFilter = "" deleteFilter = ""
@@ -2411,7 +2410,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin
if likeClause, likeTerm := s.buildLIKEClause(term, "Name, DisplayName, Purpose"); likeClause == "" { if likeClause, likeTerm := s.buildLIKEClause(term, "Name, DisplayName, Purpose"); likeClause == "" {
if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"TeamId": teamId, "UserId": userId}); err != nil { if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"TeamId": teamId, "UserId": userId}); err != nil {
return nil, model.NewAppError("SqlChannelStore.AutocompleteInTeamForSearch", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
} else { } else {
// Using a UNION results in index_merge and fulltext queries and is much faster than the ref // Using a UNION results in index_merge and fulltext queries and is much faster than the ref
@@ -2422,7 +2421,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin
query := fmt.Sprintf("(%v) UNION (%v) LIMIT 50", likeQuery, fulltextQuery) query := fmt.Sprintf("(%v) UNION (%v) LIMIT 50", likeQuery, fulltextQuery)
if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "UserId": userId, "LikeTerm": likeTerm, "FulltextTerm": fulltextTerm}); err != nil { if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "UserId": userId, "LikeTerm": likeTerm, "FulltextTerm": fulltextTerm}); err != nil {
return nil, model.NewAppError("SqlChannelStore.AutocompleteInTeamForSearch", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
} }
@@ -2439,7 +2438,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin
return &channels, nil return &channels, nil
} }
func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string, term string) ([]*model.Channel, *model.AppError) { func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string, term string) ([]*model.Channel, error) {
queryFormat := ` queryFormat := `
SELECT SELECT
C.*, C.*,
@@ -2468,20 +2467,20 @@ func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string
if likeClause, likeTerm := s.buildLIKEClause(term, "IU.Username, IU.Nickname"); likeClause == "" { if likeClause, likeTerm := s.buildLIKEClause(term, "IU.Username, IU.Nickname"); likeClause == "" {
if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"UserId": userId}); err != nil { if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"UserId": userId}); err != nil {
return nil, model.NewAppError("SqlChannelStore.AutocompleteInTeamForSearch", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
} else { } else {
query := fmt.Sprintf(queryFormat, "AND "+likeClause) query := fmt.Sprintf(queryFormat, "AND "+likeClause)
if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"UserId": userId, "LikeTerm": likeTerm}); err != nil { if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"UserId": userId, "LikeTerm": likeTerm}); err != nil {
return nil, model.NewAppError("SqlChannelStore.AutocompleteInTeamForSearch", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
} }
return channels, nil return channels, nil
} }
func (s SqlChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s SqlChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
deleteFilter := "AND c.DeleteAt = 0" deleteFilter := "AND c.DeleteAt = 0"
if includeDeleted { if includeDeleted {
deleteFilter = "" deleteFilter = ""
@@ -2505,7 +2504,7 @@ func (s SqlChannelStore) SearchInTeam(teamId string, term string, includeDeleted
}) })
} }
func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) { func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) {
publicChannels, publicErr := s.performSearch(` publicChannels, publicErr := s.performSearch(`
SELECT SELECT
Channels.* Channels.*
@@ -2556,7 +2555,7 @@ func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId
return &output, outputErr return &output, outputErr
} }
func (s SqlChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s SqlChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
deleteFilter := "AND c.DeleteAt = 0" deleteFilter := "AND c.DeleteAt = 0"
if includeDeleted { if includeDeleted {
deleteFilter = "" deleteFilter = ""
@@ -2668,14 +2667,14 @@ func (s SqlChannelStore) channelSearchQuery(term string, opts store.ChannelSearc
return query return query
} }
func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) { func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
queryString, args, err := s.channelSearchQuery(term, opts, false).ToSql() queryString, args, err := s.channelSearchQuery(term, opts, false).ToSql()
if err != nil { if err != nil {
return nil, 0, model.NewAppError("SqlChannelStore.SearchAllChannels", "store.sql.build_query.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, 0, errors.Wrap(err, "channel_tosql")
} }
var channels model.ChannelListWithTeamData var channels model.ChannelListWithTeamData
if _, err = s.GetReplica().Select(&channels, queryString, args...); err != nil { if _, err = s.GetReplica().Select(&channels, queryString, args...); err != nil {
return nil, 0, model.NewAppError("SqlChannelStore.Search", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, 0, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
var totalCount int64 var totalCount int64
@@ -2684,10 +2683,10 @@ func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearch
if opts.IsPaginated() { if opts.IsPaginated() {
queryString, args, err = s.channelSearchQuery(term, opts, true).ToSql() queryString, args, err = s.channelSearchQuery(term, opts, true).ToSql()
if err != nil { if err != nil {
return nil, 0, model.NewAppError("SqlChannelStore.SearchAllChannels", "store.sql.build_query.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, 0, errors.Wrap(err, "channel_tosql")
} }
if totalCount, err = s.GetReplica().SelectInt(queryString, args...); err != nil { if totalCount, err = s.GetReplica().SelectInt(queryString, args...); err != nil {
return nil, 0, model.NewAppError("SqlChannelStore.Search", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, 0, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
} else { } else {
totalCount = int64(len(channels)) totalCount = int64(len(channels))
@@ -2696,7 +2695,7 @@ func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearch
return &channels, totalCount, nil return &channels, totalCount, nil
} }
func (s SqlChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError) { func (s SqlChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error) {
return s.performSearch(` return s.performSearch(`
SELECT SELECT
Channels.* Channels.*
@@ -2789,7 +2788,7 @@ func (s SqlChannelStore) buildFulltextClause(term string, searchColumns string)
return return
} }
func (s SqlChannelStore) performSearch(searchQuery string, term string, parameters map[string]interface{}) (*model.ChannelList, *model.AppError) { 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") likeClause, likeTerm := s.buildLIKEClause(term, "c.Name, c.DisplayName, c.Purpose")
if likeTerm == "" { if likeTerm == "" {
// If the likeTerm is empty after preparing, then don't bother searching. // If the likeTerm is empty after preparing, then don't bother searching.
@@ -2804,7 +2803,7 @@ func (s SqlChannelStore) performSearch(searchQuery string, term string, paramete
var channels model.ChannelList var channels model.ChannelList
if _, err := s.GetReplica().Select(&channels, searchQuery, parameters); err != nil { if _, err := s.GetReplica().Select(&channels, searchQuery, parameters); err != nil {
return nil, model.NewAppError("SqlChannelStore.Search", "store.sql_channel.search.app_error", nil, "term="+term+", "+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
} }
return &channels, nil return &channels, nil
@@ -2898,18 +2897,18 @@ func (s SqlChannelStore) getSearchGroupChannelsQuery(userId, term string, isPost
return query, args return query, args
} }
func (s SqlChannelStore) SearchGroupChannels(userId, term string) (*model.ChannelList, *model.AppError) { func (s SqlChannelStore) SearchGroupChannels(userId, term string) (*model.ChannelList, error) {
isPostgreSQL := s.DriverName() == model.DATABASE_DRIVER_POSTGRES isPostgreSQL := s.DriverName() == model.DATABASE_DRIVER_POSTGRES
queryString, args := s.getSearchGroupChannelsQuery(userId, term, isPostgreSQL) queryString, args := s.getSearchGroupChannelsQuery(userId, term, isPostgreSQL)
var groupChannels model.ChannelList var groupChannels model.ChannelList
if _, err := s.GetReplica().Select(&groupChannels, queryString, args); err != nil { if _, err := s.GetReplica().Select(&groupChannels, queryString, args); err != nil {
return nil, model.NewAppError("SqlChannelStore.SearchGroupChannels", "store.sql_channel.search_group_channels.app_error", nil, "userId="+userId+", term="+term+", err="+err.Error(), http.StatusInternalServerError) 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, *model.AppError) { func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error) {
var dbMembers channelMemberWithSchemeRolesList var dbMembers channelMemberWithSchemeRolesList
props := make(map[string]interface{}) props := make(map[string]interface{})
idQuery := "" idQuery := ""
@@ -2926,17 +2925,17 @@ func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) (*m
props["ChannelId"] = channelId props["ChannelId"] = channelId
if _, err := s.GetReplica().Select(&dbMembers, CHANNEL_MEMBERS_WITH_SCHEME_SELECT_QUERY+"WHERE ChannelMembers.ChannelId = :ChannelId AND ChannelMembers.UserId IN ("+idQuery+")", props); err != nil { if _, err := s.GetReplica().Select(&dbMembers, CHANNEL_MEMBERS_WITH_SCHEME_SELECT_QUERY+"WHERE ChannelMembers.ChannelId = :ChannelId AND ChannelMembers.UserId IN ("+idQuery+")", props); err != nil {
return nil, model.NewAppError("SqlChannelStore.GetMembersByIds", "store.sql_channel.get_members_by_ids.app_error", nil, "channelId="+channelId+" "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find ChannelMembers with channelId=%s and userId in %v", channelId, userIds)
} }
return dbMembers.ToModel(), nil return dbMembers.ToModel(), nil
} }
func (s SqlChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) { func (s SqlChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error) {
var channels model.ChannelList var channels model.ChannelList
_, err := s.GetReplica().Select(&channels, "SELECT * FROM Channels WHERE SchemeId = :SchemeId ORDER BY DisplayName LIMIT :Limit OFFSET :Offset", map[string]interface{}{"SchemeId": schemeId, "Offset": offset, "Limit": limit}) _, err := s.GetReplica().Select(&channels, "SELECT * FROM Channels WHERE SchemeId = :SchemeId ORDER BY DisplayName LIMIT :Limit OFFSET :Offset", map[string]interface{}{"SchemeId": schemeId, "Offset": offset, "Limit": limit})
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetChannelsByScheme", "store.sql_channel.get_by_scheme.app_error", nil, "schemeId="+schemeId+" "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find Channels with schemeId=%s", schemeId)
} }
return channels, nil return channels, nil
} }
@@ -2945,18 +2944,18 @@ func (s SqlChannelStore) GetChannelsByScheme(schemeId string, offset int, limit
// in batches as a single transaction per batch to ensure consistency but to also minimise execution time to avoid // in batches as a single transaction per batch to ensure consistency but to also minimise execution time to avoid
// causing unnecessary table locks. **THIS FUNCTION SHOULD NOT BE USED FOR ANY OTHER PURPOSE.** Executing this function // causing unnecessary table locks. **THIS FUNCTION SHOULD NOT BE USED FOR ANY OTHER PURPOSE.** Executing this function
// *after* the new Schemes functionality has been used on an installation will have unintended consequences. // *after* the new Schemes functionality has been used on an installation will have unintended consequences.
func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError) { func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error) {
var transaction *gorp.Transaction var transaction *gorp.Transaction
var err error var err error
if transaction, err = s.GetMaster().Begin(); err != nil { if transaction, err = s.GetMaster().Begin(); err != nil {
return nil, model.NewAppError("SqlChannelStore.MigrateChannelMembers", "store.sql_channel.migrate_channel_members.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
var channelMembers []channelMember var channelMembers []channelMember
if _, err := transaction.Select(&channelMembers, "SELECT * from ChannelMembers WHERE (ChannelId, UserId) > (:FromChannelId, :FromUserId) ORDER BY ChannelId, UserId LIMIT 100", map[string]interface{}{"FromChannelId": fromChannelId, "FromUserId": fromUserId}); err != nil { if _, err := transaction.Select(&channelMembers, "SELECT * from ChannelMembers WHERE (ChannelId, UserId) > (:FromChannelId, :FromUserId) ORDER BY ChannelId, UserId LIMIT 100", map[string]interface{}{"FromChannelId": fromChannelId, "FromUserId": fromUserId}); err != nil {
return nil, model.NewAppError("SqlChannelStore.MigrateChannelMembers", "store.sql_channel.migrate_channel_members.select.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to find ChannelMembers")
} }
if len(channelMembers) == 0 { if len(channelMembers) == 0 {
@@ -2991,13 +2990,13 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
member.Roles = strings.Join(newRoles, " ") member.Roles = strings.Join(newRoles, " ")
if _, err := transaction.Update(&member); err != nil { if _, err := transaction.Update(&member); err != nil {
return nil, model.NewAppError("SqlChannelStore.MigrateChannelMembers", "store.sql_channel.migrate_channel_members.update.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to update ChannelMember")
} }
} }
if err := transaction.Commit(); err != nil { if err := transaction.Commit(); err != nil {
return nil, model.NewAppError("SqlChannelStore.MigrateChannelMembers", "store.sql_channel.migrate_channel_members.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "commit_transaction")
} }
data := make(map[string]string) data := make(map[string]string)
@@ -3006,34 +3005,34 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
return data, nil return data, nil
} }
func (s SqlChannelStore) ResetAllChannelSchemes() *model.AppError { func (s SqlChannelStore) ResetAllChannelSchemes() error {
transaction, err := s.GetMaster().Begin() transaction, err := s.GetMaster().Begin()
if err != nil { if err != nil {
return model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
resetErr := s.resetAllChannelSchemesT(transaction) err = s.resetAllChannelSchemesT(transaction)
if resetErr != nil { if err != nil {
return resetErr return err
} }
if err := transaction.Commit(); err != nil { if err := transaction.Commit(); err != nil {
return model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "commit_transaction")
} }
return nil return nil
} }
func (s SqlChannelStore) resetAllChannelSchemesT(transaction *gorp.Transaction) *model.AppError { func (s SqlChannelStore) resetAllChannelSchemesT(transaction *gorp.Transaction) error {
if _, err := transaction.Exec("UPDATE Channels SET SchemeId=''"); err != nil { if _, err := transaction.Exec("UPDATE Channels SET SchemeId=''"); err != nil {
return model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to update Channels")
} }
return nil return nil
} }
func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError { func (s SqlChannelStore) ClearAllCustomRoleAssignments() error {
builtInRoles := model.MakeDefaultRoles() builtInRoles := model.MakeDefaultRoles()
lastUserId := strings.Repeat("0", 26) lastUserId := strings.Repeat("0", 26)
lastChannelId := strings.Repeat("0", 26) lastChannelId := strings.Repeat("0", 26)
@@ -3043,13 +3042,13 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
var err error var err error
if transaction, err = s.GetMaster().Begin(); err != nil { if transaction, err = s.GetMaster().Begin(); err != nil {
return model.NewAppError("SqlChannelStore.ClearAllCustomRoleAssignments", "store.sql_channel.clear_all_custom_role_assignments.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "begin_transaction")
} }
var channelMembers []*channelMember var channelMembers []*channelMember
if _, err := transaction.Select(&channelMembers, "SELECT * from ChannelMembers WHERE (ChannelId, UserId) > (:ChannelId, :UserId) ORDER BY ChannelId, UserId LIMIT 1000", map[string]interface{}{"ChannelId": lastChannelId, "UserId": lastUserId}); err != nil { if _, err := transaction.Select(&channelMembers, "SELECT * from ChannelMembers WHERE (ChannelId, UserId) > (:ChannelId, :UserId) ORDER BY ChannelId, UserId LIMIT 1000", map[string]interface{}{"ChannelId": lastChannelId, "UserId": lastUserId}); err != nil {
finalizeTransaction(transaction) finalizeTransaction(transaction)
return model.NewAppError("SqlChannelStore.ClearAllCustomRoleAssignments", "store.sql_channel.clear_all_custom_role_assignments.select.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to find ChannelMembers")
} }
if len(channelMembers) == 0 { if len(channelMembers) == 0 {
@@ -3076,21 +3075,21 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
if newRolesString != member.Roles { if newRolesString != member.Roles {
if _, err := transaction.Exec("UPDATE ChannelMembers SET Roles = :Roles WHERE UserId = :UserId AND ChannelId = :ChannelId", map[string]interface{}{"Roles": newRolesString, "ChannelId": member.ChannelId, "UserId": member.UserId}); err != nil { if _, err := transaction.Exec("UPDATE ChannelMembers SET Roles = :Roles WHERE UserId = :UserId AND ChannelId = :ChannelId", map[string]interface{}{"Roles": newRolesString, "ChannelId": member.ChannelId, "UserId": member.UserId}); err != nil {
finalizeTransaction(transaction) finalizeTransaction(transaction)
return model.NewAppError("SqlChannelStore.ClearAllCustomRoleAssignments", "store.sql_channel.clear_all_custom_role_assignments.update.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to update ChannelMembers")
} }
} }
} }
if err := transaction.Commit(); err != nil { if err := transaction.Commit(); err != nil {
finalizeTransaction(transaction) finalizeTransaction(transaction)
return model.NewAppError("SqlChannelStore.ClearAllCustomRoleAssignments", "store.sql_channel.clear_all_custom_role_assignments.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "commit_transaction")
} }
} }
return nil return nil
} }
func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) { func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error) {
var channels []*model.ChannelForExport var channels []*model.ChannelForExport
if _, err := s.GetReplica().Select(&channels, ` if _, err := s.GetReplica().Select(&channels, `
SELECT SELECT
@@ -3109,13 +3108,13 @@ func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string)
Id Id
LIMIT :Limit`, LIMIT :Limit`,
map[string]interface{}{"AfterId": afterId, "Limit": limit}); err != nil { map[string]interface{}{"AfterId": afterId, "Limit": limit}); err != nil {
return nil, model.NewAppError("SqlChannelStore.GetAllChannelsForExportAfter", "store.sql_channel.get_all.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to find Channels for export")
} }
return channels, nil return channels, nil
} }
func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) { func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error) {
var members []*model.ChannelMemberForExport var members []*model.ChannelMemberForExport
_, err := s.GetReplica().Select(&members, ` _, err := s.GetReplica().Select(&members, `
SELECT SELECT
@@ -3142,13 +3141,13 @@ func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string
map[string]interface{}{"TeamId": teamId, "UserId": userId}) map[string]interface{}{"TeamId": teamId, "UserId": userId})
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetChannelMembersForExport", "app.channel.get_members.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to find Channels for export")
} }
return members, nil return members, nil
} }
func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, *model.AppError) { func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error) {
var directChannelsForExport []*model.DirectChannelForExport var directChannelsForExport []*model.DirectChannelForExport
query := s.getQueryBuilder(). query := s.getQueryBuilder().
Select("Channels.*"). Select("Channels.*").
@@ -3163,11 +3162,11 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
queryString, args, err := query.ToSql() queryString, args, err := query.ToSql()
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetAllDirectChannelsForExportAfter", "store.sql_channel.get_all_direct.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "channel_tosql")
} }
if _, err = s.GetReplica().Select(&directChannelsForExport, queryString, args...); err != nil { if _, err = s.GetReplica().Select(&directChannelsForExport, queryString, args...); err != nil {
return nil, model.NewAppError("SqlChannelStore.GetAllDirectChannelsForExportAfter", "store.sql_channel.get_all_direct.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to find direct Channels for export")
} }
var channelIds []string var channelIds []string
@@ -3185,12 +3184,12 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
queryString, args, err = query.ToSql() queryString, args, err = query.ToSql()
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetAllDirectChannelsForExportAfter", "store.sql_channel.get_all_direct.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "channel_tosql")
} }
var channelMembers []*model.ChannelMemberForExport var channelMembers []*model.ChannelMemberForExport
if _, err := s.GetReplica().Select(&channelMembers, queryString, args...); err != nil { if _, err := s.GetReplica().Select(&channelMembers, queryString, args...); err != nil {
return nil, model.NewAppError("SqlChannelStore.GetAllDirectChannelsForExportAfter", "store.sql_channel.get_all_direct.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to find ChannelMembers")
} }
// Populate each channel with its members // Populate each channel with its members
@@ -3207,7 +3206,7 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
return directChannelsForExport, nil return directChannelsForExport, nil
} }
func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError) { func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, error) {
query := query :=
`SELECT `SELECT
* *
@@ -3227,13 +3226,13 @@ func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, l
var channels []*model.Channel var channels []*model.Channel
_, err := s.GetSearchReplica().Select(&channels, query, map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumChannels": limit}) _, err := s.GetSearchReplica().Select(&channels, query, map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumChannels": limit})
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetChannelsBatchForIndexing", "store.sql_channel.get_channels_batch_for_indexing.get.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to find Channels")
} }
return channels, nil return channels, nil
} }
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) { func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
query := s.getQueryBuilder(). query := s.getQueryBuilder().
Select("Count(*)"). Select("Count(*)").
From("ChannelMembers"). From("ChannelMembers").
@@ -3244,16 +3243,16 @@ func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []strin
queryString, args, err := query.ToSql() queryString, args, err := query.ToSql()
if err != nil { if err != nil {
return false, model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError) return false, errors.Wrap(err, "channel_tosql")
} }
c, err := s.GetReplica().SelectInt(queryString, args...) c, err := s.GetReplica().SelectInt(queryString, args...)
if err != nil { if err != nil {
return false, model.NewAppError("SqlChannelStore.UserBelongsToChannels", "store.sql_channel.user_belongs_to_channels.app_error", nil, err.Error(), http.StatusInternalServerError) return false, errors.Wrap(err, "failed to count ChannelMembers")
} }
return c > 0, nil return c > 0, nil
} }
func (s SqlChannelStore) UpdateMembersRole(channelID string, userIDs []string) *model.AppError { func (s SqlChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
sql := fmt.Sprintf(` sql := fmt.Sprintf(`
UPDATE UPDATE
ChannelMembers ChannelMembers
@@ -3269,23 +3268,23 @@ func (s SqlChannelStore) UpdateMembersRole(channelID string, userIDs []string) *
`, strings.Join(userIDs, "', '")) `, strings.Join(userIDs, "', '"))
if _, err := s.GetMaster().Exec(sql, map[string]interface{}{"ChannelId": channelID}); err != nil { if _, err := s.GetMaster().Exec(sql, map[string]interface{}{"ChannelId": channelID}); err != nil {
return model.NewAppError("SqlChannelStore.UpdateMembersRole", "store.update_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to update ChannelMembers")
} }
return nil return nil
} }
func (s SqlChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) { func (s SqlChannelStore) GroupSyncedChannelCount() (int64, error) {
query := s.getQueryBuilder().Select("COUNT(*)").From("Channels").Where(sq.Eq{"GroupConstrained": true, "DeleteAt": 0}) query := s.getQueryBuilder().Select("COUNT(*)").From("Channels").Where(sq.Eq{"GroupConstrained": true, "DeleteAt": 0})
sql, args, err := query.ToSql() sql, args, err := query.ToSql()
if err != nil { if err != nil {
return 0, model.NewAppError("SqlChannelStore.GroupSyncedChannelCount", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError) return 0, errors.Wrap(err, "channel_tosql")
} }
count, err := s.GetReplica().SelectInt(sql, args...) count, err := s.GetReplica().SelectInt(sql, args...)
if err != nil { if err != nil {
return 0, model.NewAppError("SqlChannelStore.GroupSyncedChannelCount", "store.select_error", nil, err.Error(), http.StatusInternalServerError) return 0, errors.Wrap(err, "failed to count Channels")
} }
return count, nil return count, nil

Просмотреть файл

@@ -4,7 +4,9 @@
package sqlstore package sqlstore
import ( import (
"net/http" "fmt"
"github.com/mattermost/mattermost-server/v5/store"
"github.com/mattermost/gorp" "github.com/mattermost/gorp"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
@@ -222,21 +224,23 @@ type sidebarCategoryForJoin struct {
ChannelId *string ChannelId *string
} }
func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
transaction, err := s.GetMaster().Begin() transaction, err := s.GetMaster().Begin()
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.CreateSidebarCategory", "store.sql_channel.sidebar_categories.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
categoriesWithOrder, appErr := s.getSidebarCategoriesT(transaction, userId, teamId) categoriesWithOrder, err := s.getSidebarCategoriesT(transaction, userId, teamId)
if appErr != nil { if err != nil {
return nil, appErr return nil, err
} }
if len(categoriesWithOrder.Categories) < 1 { if len(categoriesWithOrder.Categories) < 1 {
return nil, model.NewAppError("SqlChannelStore.CreateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, "", http.StatusInternalServerError) return nil, errors.Wrap(err, "categories not found")
} }
newOrder := categoriesWithOrder.Order newOrder := categoriesWithOrder.Order
newCategoryId := model.NewId() newCategoryId := model.NewId()
newCategorySortOrder := 0 newCategorySortOrder := 0
@@ -262,7 +266,7 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
Type: model.SidebarCategoryCustom, Type: model.SidebarCategoryCustom,
} }
if err = transaction.Insert(category); err != nil { if err = transaction.Insert(category); err != nil {
return nil, model.NewAppError("SqlPostStore.CreateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to save SidebarCategory")
} }
if len(newCategory.Channels) > 0 { if len(newCategory.Channels) > 0 {
@@ -299,7 +303,7 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
_, err = transaction.Exec(deleteQuery, deleteParams) _, err = transaction.Exec(deleteQuery, deleteParams)
if err != nil { if err != nil {
return nil, model.NewAppError("SqlPostStore.CreateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to delete SidebarChannels")
} }
var channels []interface{} var channels []interface{}
@@ -312,17 +316,17 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
}) })
} }
if err = transaction.Insert(channels...); err != nil { if err = transaction.Insert(channels...); err != nil {
return nil, model.NewAppError("SqlPostStore.CreateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to save SidebarChannels")
} }
} }
// now we re-order the categories according to the new order // now we re-order the categories according to the new order
if appErr := s.updateSidebarCategoryOrderT(transaction, userId, teamId, newOrder); appErr != nil { if err = s.updateSidebarCategoryOrderT(transaction, userId, teamId, newOrder); err != nil {
return nil, appErr return nil, err
} }
if err = transaction.Commit(); err != nil { if err = transaction.Commit(); err != nil {
return nil, model.NewAppError("SqlChannelStore.CreateSidebarCategory", "store.sql_channel.sidebar_categories.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "commit_transaction")
} }
// patch category to return proper sort order // patch category to return proper sort order
@@ -335,26 +339,26 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
return result, nil return result, nil
} }
func (s SqlChannelStore) completePopulatingCategoryChannels(category *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s SqlChannelStore) completePopulatingCategoryChannels(category *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
transaction, err := s.GetMaster().Begin() transaction, err := s.GetMaster().Begin()
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.completePopulatingCategoryChannels", "store.sql_channel.sidebar_categories.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
result, appErr := s.completePopulatingCategoryChannelsT(transaction, category) result, err := s.completePopulatingCategoryChannelsT(transaction, category)
if appErr != nil { if err != nil {
return nil, appErr return nil, err
} }
if err = transaction.Commit(); err != nil { if err = transaction.Commit(); err != nil {
return nil, model.NewAppError("SqlChannelStore.completePopulatingCategoryChannels", "store.sql_channel.sidebar_categories.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "commit_transaction")
} }
return result, nil return result, nil
} }
func (s SqlChannelStore) completePopulatingCategoryChannelsT(transation *gorp.Transaction, category *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s SqlChannelStore) completePopulatingCategoryChannelsT(transation *gorp.Transaction, category *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
if category.Type == model.SidebarCategoryCustom || category.Type == model.SidebarCategoryFavorites { if category.Type == model.SidebarCategoryCustom || category.Type == model.SidebarCategoryFavorites {
return category, nil return category, nil
} }
@@ -384,7 +388,7 @@ func (s SqlChannelStore) completePopulatingCategoryChannelsT(transation *gorp.Tr
Suffix(")") Suffix(")")
var channels []string var channels []string
sql, args, _ := s.getQueryBuilder(). sql, args, err := s.getQueryBuilder().
Select("Id"). Select("Id").
From("ChannelMembers"). From("ChannelMembers").
LeftJoin("Channels ON Channels.Id=ChannelMembers.ChannelId"). LeftJoin("Channels ON Channels.Id=ChannelMembers.ChannelId").
@@ -395,29 +399,38 @@ func (s SqlChannelStore) completePopulatingCategoryChannelsT(transation *gorp.Tr
doesNotHaveSidebarChannel, doesNotHaveSidebarChannel,
}). }).
OrderBy("DisplayName ASC").ToSql() OrderBy("DisplayName ASC").ToSql()
if err != nil {
return nil, errors.Wrap(err, "channel_tosql")
}
if _, err := transation.Select(&channels, sql, args...); err != nil { if _, err = transation.Select(&channels, sql, args...); err != nil {
return nil, model.NewAppError("SqlPostStore.completePopulatingCategoryChannelsT", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound) return nil, store.NewErrNotFound("ChannelMembers", "<too many fields>")
} }
category.Channels = append(channels, category.Channels...) category.Channels = append(channels, category.Channels...)
return category, nil return category, nil
} }
func (s SqlChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s SqlChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error) {
var categories []*sidebarCategoryForJoin var categories []*sidebarCategoryForJoin
sql, args, _ := s.getQueryBuilder(). sql, args, err := s.getQueryBuilder().
Select("SidebarCategories.*", "SidebarChannels.ChannelId"). Select("SidebarCategories.*", "SidebarChannels.ChannelId").
From("SidebarCategories"). From("SidebarCategories").
LeftJoin("SidebarChannels ON SidebarChannels.CategoryId=SidebarCategories.Id"). LeftJoin("SidebarChannels ON SidebarChannels.CategoryId=SidebarCategories.Id").
Where(sq.Eq{"SidebarCategories.Id": categoryId}). Where(sq.Eq{"SidebarCategories.Id": categoryId}).
OrderBy("SidebarChannels.SortOrder ASC").ToSql() OrderBy("SidebarChannels.SortOrder ASC").ToSql()
if _, err := s.GetReplica().Select(&categories, sql, args...); err != nil { if err != nil {
return nil, model.NewAppError("SqlPostStore.GetSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound) return nil, errors.Wrap(err, "sidebar_category_tosql")
} }
if _, err = s.GetReplica().Select(&categories, sql, args...); err != nil {
return nil, store.NewErrNotFound("SidebarCategories", categoryId)
}
if len(categories) == 0 { if len(categories) == 0 {
return nil, model.NewAppError("SqlPostStore.GetSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, "", http.StatusNotFound) return nil, store.NewErrNotFound("SidebarCategories", categoryId)
} }
result := &model.SidebarCategoryWithChannels{ result := &model.SidebarCategoryWithChannels{
SidebarCategory: categories[0].SidebarCategory, SidebarCategory: categories[0].SidebarCategory,
Channels: make([]string, 0), Channels: make([]string, 0),
@@ -430,14 +443,14 @@ func (s SqlChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCa
return s.completePopulatingCategoryChannels(result) return s.completePopulatingCategoryChannels(result)
} }
func (s SqlChannelStore) getSidebarCategoriesT(transaction *gorp.Transaction, userId, teamId string) (*model.OrderedSidebarCategories, *model.AppError) { func (s SqlChannelStore) getSidebarCategoriesT(transaction *gorp.Transaction, userId, teamId string) (*model.OrderedSidebarCategories, error) {
oc := model.OrderedSidebarCategories{ oc := model.OrderedSidebarCategories{
Categories: make(model.SidebarCategoriesWithChannels, 0), Categories: make(model.SidebarCategoriesWithChannels, 0),
Order: make([]string, 0), Order: make([]string, 0),
} }
var categories []*sidebarCategoryForJoin var categories []*sidebarCategoryForJoin
sql, args, _ := s.getQueryBuilder(). query, args, err := s.getQueryBuilder().
Select("SidebarCategories.*", "SidebarChannels.ChannelId"). Select("SidebarCategories.*", "SidebarChannels.ChannelId").
From("SidebarCategories"). From("SidebarCategories").
LeftJoin("SidebarChannels ON SidebarChannels.CategoryId=Id"). LeftJoin("SidebarChannels ON SidebarChannels.CategoryId=Id").
@@ -446,9 +459,12 @@ func (s SqlChannelStore) getSidebarCategoriesT(transaction *gorp.Transaction, us
sq.Eq{"SidebarCategories.TeamId": teamId}, sq.Eq{"SidebarCategories.TeamId": teamId},
}). }).
OrderBy("SidebarCategories.SortOrder ASC, SidebarChannels.SortOrder ASC").ToSql() OrderBy("SidebarCategories.SortOrder ASC, SidebarChannels.SortOrder ASC").ToSql()
if err != nil {
return nil, errors.Wrap(err, "sidebar_categories_tosql")
}
if _, err := transaction.Select(&categories, sql, args...); err != nil { if _, err = transaction.Select(&categories, query, args...); err != nil {
return nil, model.NewAppError("SqlPostStore.GetSidebarCategories", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound) return nil, store.NewErrNotFound("SidebarCategories", fmt.Sprintf("userId=%s,teamId=%s", userId, teamId))
} }
for _, category := range categories { for _, category := range categories {
var prevCategory *model.SidebarCategoryWithChannels var prevCategory *model.SidebarCategoryWithChannels
@@ -479,30 +495,30 @@ func (s SqlChannelStore) getSidebarCategoriesT(transaction *gorp.Transaction, us
return &oc, nil return &oc, nil
} }
func (s SqlChannelStore) GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, *model.AppError) { func (s SqlChannelStore) GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, error) {
transaction, err := s.GetMaster().Begin() transaction, err := s.GetMaster().Begin()
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetSidebarCategories", "store.sql_channel.sidebar_categories.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
oc, appErr := s.getSidebarCategoriesT(transaction, userId, teamId) oc, err := s.getSidebarCategoriesT(transaction, userId, teamId)
if appErr != nil { if err != nil {
return nil, appErr return nil, err
} }
if err = transaction.Commit(); err != nil { if err = transaction.Commit(); err != nil {
return nil, model.NewAppError("SqlChannelStore.GetSidebarCategories", "store.sql_channel.sidebar_categories.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "commit_transaction")
} }
return oc, nil return oc, nil
} }
func (s SqlChannelStore) GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError) { func (s SqlChannelStore) GetSidebarCategoryOrder(userId, teamId string) ([]string, error) {
var ids []string var ids []string
sql, args, _ := s.getQueryBuilder(). sql, args, err := s.getQueryBuilder().
Select("Id"). Select("Id").
From("SidebarCategories"). From("SidebarCategories").
Where(sq.And{ Where(sq.And{
@@ -511,13 +527,18 @@ func (s SqlChannelStore) GetSidebarCategoryOrder(userId, teamId string) ([]strin
}). }).
OrderBy("SidebarCategories.SortOrder ASC").ToSql() OrderBy("SidebarCategories.SortOrder ASC").ToSql()
if _, err := s.GetReplica().Select(&ids, sql, args...); err != nil { if err != nil {
return nil, model.NewAppError("SqlPostStore.GetSidebarCategoryOrder", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound) return nil, errors.Wrap(err, "sidebar_category_tosql")
} }
if _, err := s.GetReplica().Select(&ids, sql, args...); err != nil {
return nil, store.NewErrNotFound("SidebarCategories", fmt.Sprintf("userId=%s,teamId=%s", userId, teamId))
}
return ids, nil return ids, nil
} }
func (s SqlChannelStore) updateSidebarCategoryOrderT(transaction *gorp.Transaction, userId, teamId string, categoryOrder []string) *model.AppError { func (s SqlChannelStore) updateSidebarCategoryOrderT(transaction *gorp.Transaction, userId, teamId string, categoryOrder []string) error {
var newOrder []interface{} var newOrder []interface{}
runningOrder := 0 runningOrder := 0
for _, categoryId := range categoryOrder { for _, categoryId := range categoryOrder {
@@ -534,28 +555,30 @@ func (s SqlChannelStore) updateSidebarCategoryOrderT(transaction *gorp.Transacti
if _, err := transaction.UpdateColumns(func(col *gorp.ColumnMap) bool { if _, err := transaction.UpdateColumns(func(col *gorp.ColumnMap) bool {
return col.ColumnName == "SortOrder" return col.ColumnName == "SortOrder"
}, newOrder...); err != nil { }, newOrder...); err != nil {
return model.NewAppError("SqlPostStore.UpdateSidebarCategoryOrder", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to update SidebarCategory")
} }
return nil return nil
} }
func (s SqlChannelStore) UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) *model.AppError { func (s SqlChannelStore) UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) error {
transaction, err := s.GetMaster().Begin() transaction, err := s.GetMaster().Begin()
if err != nil { if err != nil {
return model.NewAppError("SqlChannelStore.UpdateSidebarCategoryOrder", "store.sql_channel.sidebar_categories.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
// Ensure no invalid categories are included and that no categories are left out // Ensure no invalid categories are included and that no categories are left out
existingOrder, appErr := s.GetSidebarCategoryOrder(userId, teamId) existingOrder, err := s.GetSidebarCategoryOrder(userId, teamId)
if appErr != nil { if err != nil {
return appErr return err
} }
if len(existingOrder) != len(categoryOrder) { if len(existingOrder) != len(categoryOrder) {
return model.NewAppError("SqlPostStore.UpdateSidebarCategoryOrder", "store.sql_channel.sidebar_categories.app_error", nil, "Cannot update category order, passed list of categories different size than in DB", http.StatusInternalServerError) return errors.New("cannot update category order, passed list of categories different size than in DB")
} }
for _, originalCategoryId := range existingOrder { for _, originalCategoryId := range existingOrder {
found := false found := false
for _, newCategoryId := range categoryOrder { for _, newCategoryId := range categoryOrder {
@@ -565,33 +588,33 @@ func (s SqlChannelStore) UpdateSidebarCategoryOrder(userId, teamId string, categ
} }
} }
if !found { if !found {
return model.NewAppError("SqlPostStore.UpdateSidebarCategoryOrder", "store.sql_channel.sidebar_categories.app_error", nil, "Cannot update category order, passed list of categories contains unrecognized category IDs", http.StatusBadRequest) return store.NewErrInvalidInput("SidebarCategories", "id", fmt.Sprintf("%v", categoryOrder))
} }
} }
if appErr := s.updateSidebarCategoryOrderT(transaction, userId, teamId, categoryOrder); appErr != nil { if err = s.updateSidebarCategoryOrderT(transaction, userId, teamId, categoryOrder); err != nil {
return appErr return err
} }
if err = transaction.Commit(); err != nil { if err = transaction.Commit(); err != nil {
return model.NewAppError("SqlChannelStore.UpdateSidebarCategoryOrder", "store.sql_channel.sidebar_categories.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "commit_transaction")
} }
return nil return nil
} }
func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) { func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, error) {
transaction, err := s.GetMaster().Begin() transaction, err := s.GetMaster().Begin()
if err != nil { if err != nil {
return nil, model.NewAppError("SqlChannelStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
updatedCategories := []*model.SidebarCategoryWithChannels{} updatedCategories := []*model.SidebarCategoryWithChannels{}
for _, category := range categories { for _, category := range categories {
originalCategory, appErr := s.GetSidebarCategory(category.Id) originalCategory, err2 := s.GetSidebarCategory(category.Id)
if appErr != nil { if err2 != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, appErr.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err2, "failed to find SidebarCategories")
} }
// Copy category to avoid modifying an argument // Copy category to avoid modifying an argument
@@ -621,7 +644,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
Where(sq.Eq{"Id": updatedCategory.Id}).ToSql() Where(sq.Eq{"Id": updatedCategory.Id}).ToSql()
if _, err = transaction.Exec(updateQuery, updateParams...); err != nil { if _, err = transaction.Exec(updateQuery, updateParams...); err != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to update SidebarCategories")
} }
// if we are updating DM category, it's order can't channel order cannot be changed. // if we are updating DM category, it's order can't channel order cannot be changed.
@@ -629,7 +652,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
// Remove any SidebarChannels entries that were either: // Remove any SidebarChannels entries that were either:
// - previously in this category (and any ones that are still in the category will be recreated below) // - previously in this category (and any ones that are still in the category will be recreated below)
// - in another category and are being added to this category // - in another category and are being added to this category
sql, args, _ := s.getQueryBuilder(). query, args, err2 := s.getQueryBuilder().
Delete("SidebarChannels"). Delete("SidebarChannels").
Where( Where(
sq.And{ sq.And{
@@ -641,8 +664,12 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
}, },
).ToSql() ).ToSql()
if _, err = transaction.Exec(sql, args...); err != nil { if err2 != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err2, "update_sidebar_catetories_tosql")
}
if _, err = transaction.Exec(query, args...); err != nil {
return nil, errors.Wrap(err, "failed to delete SidebarChannels")
} }
var channels []interface{} var channels []interface{}
@@ -658,7 +685,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
} }
if err = transaction.Insert(channels...); err != nil { if err = transaction.Insert(channels...); err != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to save SidebarChannels")
} }
} }
@@ -674,7 +701,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
).ToSql() ).ToSql()
if _, err = transaction.Exec(sql, args...); err != nil { if _, err = transaction.Exec(sql, args...); err != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to delete Preferences")
} }
// And then add the new ones // And then add the new ones
@@ -687,21 +714,24 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
Category: model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL, Category: model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL,
Value: "true", Value: "true",
}); err != nil { }); err != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to save Preference")
} }
} }
} else { } else {
// Remove any old favorites that might have been in this category // Remove any old favorites that might have been in this category
sql, args, _ := s.getQueryBuilder().Delete("Preferences").Where( query, args, nErr := s.getQueryBuilder().Delete("Preferences").Where(
sq.Eq{ sq.Eq{
"UserId": userId, "UserId": userId,
"Name": category.Channels, "Name": category.Channels,
"Category": model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL, "Category": model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL,
}, },
).ToSql() ).ToSql()
if nErr != nil {
return nil, errors.Wrap(nErr, "update_sidebar_categories_tosql")
}
if _, err = transaction.Exec(sql, args...); err != nil { if _, nErr = transaction.Exec(query, args...); nErr != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(nErr, "failed to delete Preferences")
} }
} }
@@ -710,16 +740,16 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
// Ensure Channels are populated for Channels/Direct Messages category if they change // Ensure Channels are populated for Channels/Direct Messages category if they change
for i, updatedCategory := range updatedCategories { for i, updatedCategory := range updatedCategories {
populated, err := s.completePopulatingCategoryChannelsT(transaction, updatedCategory) populated, nErr := s.completePopulatingCategoryChannelsT(transaction, updatedCategory)
if err != nil { if nErr != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, nErr
} }
updatedCategories[i] = populated updatedCategories[i] = populated
} }
if err = transaction.Commit(); err != nil { if err = transaction.Commit(); err != nil {
return nil, model.NewAppError("SqlChannelStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "commit_transaction")
} }
return updatedCategories, nil return updatedCategories, nil
@@ -934,43 +964,49 @@ func (s SqlChannelStore) ClearSidebarOnTeamLeave(userId, teamId string) error {
// DeleteSidebarCategory removes a custom category and moves any channels into it into the Channels and Direct Messages // DeleteSidebarCategory removes a custom category and moves any channels into it into the Channels and Direct Messages
// categories respectively. Assumes that the provided user ID and team ID match the given category ID. // categories respectively. Assumes that the provided user ID and team ID match the given category ID.
func (s SqlChannelStore) DeleteSidebarCategory(categoryId string) *model.AppError { func (s SqlChannelStore) DeleteSidebarCategory(categoryId string) error {
transaction, err := s.GetMaster().Begin() transaction, err := s.GetMaster().Begin()
if err != nil { if err != nil {
return model.NewAppError("SqlChannelStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
// Ensure that we're deleting a custom category // Ensure that we're deleting a custom category
var category *model.SidebarCategory var category *model.SidebarCategory
if err = transaction.SelectOne(&category, "SELECT * FROM SidebarCategories WHERE Id = :Id", map[string]interface{}{"Id": categoryId}); err != nil { if err = transaction.SelectOne(&category, "SELECT * FROM SidebarCategories WHERE Id = :Id", map[string]interface{}{"Id": categoryId}); err != nil {
return model.NewAppError("SqlPostStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to find SidebarCategories with id=%s", categoryId)
} }
if category.Type != model.SidebarCategoryCustom { if category.Type != model.SidebarCategoryCustom {
return model.NewAppError("SqlPostStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.delete_invalid.app_error", nil, "", http.StatusBadRequest) return store.NewErrInvalidInput("SidebarCategory", "id", categoryId)
} }
// Delete the channels in the category // Delete the channels in the category
sql, args, _ := s.getQueryBuilder(). query, args, err := s.getQueryBuilder().
Delete("SidebarChannels"). Delete("SidebarChannels").
Where(sq.Eq{"CategoryId": categoryId}).ToSql() Where(sq.Eq{"CategoryId": categoryId}).ToSql()
if err != nil {
return errors.Wrap(err, "delete_sidebar_cateory_tosql")
}
if _, err := transaction.Exec(sql, args...); err != nil { if _, err = transaction.Exec(query, args...); err != nil {
return model.NewAppError("SqlPostStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to delete SidebarChannel")
} }
// Delete the category itself // Delete the category itself
sql, args, _ = s.getQueryBuilder(). query, args, err = s.getQueryBuilder().
Delete("SidebarCategories"). Delete("SidebarCategories").
Where(sq.Eq{"Id": categoryId}).ToSql() Where(sq.Eq{"Id": categoryId}).ToSql()
if err != nil {
return errors.Wrap(err, "delete_sidebar_cateory_tosql")
}
if _, err := transaction.Exec(sql, args...); err != nil { if _, err = transaction.Exec(query, args...); err != nil {
return model.NewAppError("SqlChannelStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to delete SidebarCategory")
} }
if err := transaction.Commit(); err != nil { if err := transaction.Commit(); err != nil {
return model.NewAppError("SqlChannelStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "commit_transaction")
} }
return nil return nil

Просмотреть файл

@@ -198,46 +198,46 @@ type ChannelStore interface {
AnalyticsTypeCount(teamId string, channelType string) (int64, error) AnalyticsTypeCount(teamId string, channelType string) (int64, error)
GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, error) GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, error)
GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (*model.ChannelMembers, error) GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (*model.ChannelMembers, error)
AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error)
SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error)
SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error)
SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error)
SearchGroupChannels(userId, term string) (*model.ChannelList, *model.AppError) SearchGroupChannels(userId, term string) (*model.ChannelList, error)
GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error)
AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error)
GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError) GetChannelUnread(channelId, userId string) (*model.ChannelUnread, error)
ClearCaches() ClearCaches()
GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error)
MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error)
ResetAllChannelSchemes() *model.AppError ResetAllChannelSchemes() error
ClearAllCustomRoleAssignments() *model.AppError ClearAllCustomRoleAssignments() error
MigratePublicChannels() error MigratePublicChannels() error
CreateInitialSidebarCategories(userId, teamId string) error CreateInitialSidebarCategories(userId, teamId string) error
GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, *model.AppError) GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, error)
GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error)
GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError) GetSidebarCategoryOrder(userId, teamId string) ([]string, error)
CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error)
UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) *model.AppError UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) error
UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, error)
UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error
DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error
DeleteSidebarCategory(categoryId string) *model.AppError DeleteSidebarCategory(categoryId string) error
GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error)
GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, *model.AppError) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error)
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error)
RemoveAllDeactivatedMembers(channelId string) *model.AppError RemoveAllDeactivatedMembers(channelId string) error
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError) GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, error)
UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) UserBelongsToChannels(userId string, channelIds []string) (bool, error)
// UpdateMembersRole sets all of the given team members to admins and all of the other members of the team to // UpdateMembersRole sets all of the given team members to admins and all of the other members of the team to
// non-admin members. // non-admin members.
UpdateMembersRole(channelID string, userIDs []string) *model.AppError UpdateMembersRole(channelID string, userIDs []string) error
// GroupSyncedChannelCount returns the count of non-deleted group-constrained channels. // GroupSyncedChannelCount returns the count of non-deleted group-constrained channels.
GroupSyncedChannelCount() (int64, *model.AppError) GroupSyncedChannelCount() (int64, error)
} }
type ChannelMemberHistoryStore interface { type ChannelMemberHistoryStore interface {

Просмотреть файл

@@ -341,9 +341,9 @@ func testGetChannelUnread(t *testing.T, ss store.Store) {
require.Nil(t, err) require.Nil(t, err)
// Check for Channel 1 // Check for Channel 1
ch, err := ss.Channel().GetChannelUnread(c1.Id, uid) ch, nErr := ss.Channel().GetChannelUnread(c1.Id, uid)
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
require.Equal(t, c1.Id, ch.ChannelId, "Wrong channel id") require.Equal(t, c1.Id, ch.ChannelId, "Wrong channel id")
require.Equal(t, teamId1, ch.TeamId, "Wrong team id for channel 1") require.Equal(t, teamId1, ch.TeamId, "Wrong team id for channel 1")
require.NotNil(t, ch.NotifyProps, "wrong props for channel 1") require.NotNil(t, ch.NotifyProps, "wrong props for channel 1")
@@ -351,9 +351,9 @@ func testGetChannelUnread(t *testing.T, ss store.Store) {
require.EqualValues(t, 10, ch.MsgCount, "wrong MsgCount for channel 1") require.EqualValues(t, 10, ch.MsgCount, "wrong MsgCount for channel 1")
// Check for Channel 2 // Check for Channel 2
ch2, err := ss.Channel().GetChannelUnread(c2.Id, uid) ch2, nErr := ss.Channel().GetChannelUnread(c2.Id, uid)
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
require.Equal(t, c2.Id, ch2.ChannelId, "Wrong channel id") require.Equal(t, c2.Id, ch2.ChannelId, "Wrong channel id")
require.Equal(t, teamId2, ch2.TeamId, "Wrong team id") require.Equal(t, teamId2, ch2.TeamId, "Wrong team id")
require.EqualValues(t, 5, ch2.MentionCount, "wrong MentionCount for channel 2") require.EqualValues(t, 5, ch2.MentionCount, "wrong MentionCount for channel 2")
@@ -5117,7 +5117,7 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store, s SqlSupplier) {
{"pipe ignored", teamId, "town square |", false, &model.ChannelList{&o9}}, {"pipe ignored", teamId, "town square |", false, &model.ChannelList{&o9}},
} }
for name, search := range map[string]func(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError){ for name, search := range map[string]func(teamId string, term string, includeDeleted bool) (*model.ChannelList, error){
"AutocompleteInTeam": ss.Channel().AutocompleteInTeam, "AutocompleteInTeam": ss.Channel().AutocompleteInTeam,
"SearchInTeam": ss.Channel().SearchInTeam, "SearchInTeam": ss.Channel().SearchInTeam,
} { } {
@@ -5503,10 +5503,10 @@ func testChannelStoreGetMembersByIds(t *testing.T, ss store.Store) {
require.Nil(t, err) require.Nil(t, err)
var members *model.ChannelMembers var members *model.ChannelMembers
members, err = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId}) members, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId})
require.Nil(t, nErr, nErr)
rm1 := (*members)[0] rm1 := (*members)[0]
require.Nil(t, err, err)
require.Equal(t, m1.ChannelId, rm1.ChannelId, "bad team id") require.Equal(t, m1.ChannelId, rm1.ChannelId, "bad team id")
require.Equal(t, m1.UserId, rm1.UserId, "bad user id") require.Equal(t, m1.UserId, rm1.UserId, "bad user id")
@@ -5514,12 +5514,12 @@ func testChannelStoreGetMembersByIds(t *testing.T, ss store.Store) {
_, err = ss.Channel().SaveMember(m2) _, err = ss.Channel().SaveMember(m2)
require.Nil(t, err) require.Nil(t, err)
members, err = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId, m2.UserId, model.NewId()}) members, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId, m2.UserId, model.NewId()})
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
require.Len(t, *members, 2, "return wrong number of results") require.Len(t, *members, 2, "return wrong number of results")
_, err = ss.Channel().GetMembersByIds(m1.ChannelId, []string{}) _, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{})
require.NotNil(t, err, "empty user ids - should have failed") require.NotNil(t, nErr, "empty user ids - should have failed")
} }
func testChannelStoreSearchGroupChannels(t *testing.T, ss store.Store) { func testChannelStoreSearchGroupChannels(t *testing.T, ss store.Store) {
@@ -5721,16 +5721,16 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) {
}() }()
var openStartCount int64 var openStartCount int64
openStartCount, err = ss.Channel().AnalyticsDeletedTypeCount("", "O") openStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "O")
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
var privateStartCount int64 var privateStartCount int64
privateStartCount, err = ss.Channel().AnalyticsDeletedTypeCount("", "P") privateStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "P")
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
var directStartCount int64 var directStartCount int64
directStartCount, err = ss.Channel().AnalyticsDeletedTypeCount("", "D") directStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "D")
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
nErr = ss.Channel().Delete(o1.Id, model.GetMillis()) nErr = ss.Channel().Delete(o1.Id, model.GetMillis())
require.Nil(t, nErr, "channel should have been deleted") require.Nil(t, nErr, "channel should have been deleted")
@@ -5743,16 +5743,16 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) {
var count int64 var count int64
count, err = ss.Channel().AnalyticsDeletedTypeCount("", "O") count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "O")
require.Nil(t, err, err) require.Nil(t, err, nErr)
assert.Equal(t, openStartCount+2, count, "Wrong open channel deleted count.") assert.Equal(t, openStartCount+2, count, "Wrong open channel deleted count.")
count, err = ss.Channel().AnalyticsDeletedTypeCount("", "P") count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "P")
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
assert.Equal(t, privateStartCount+1, count, "Wrong private channel deleted count.") assert.Equal(t, privateStartCount+1, count, "Wrong private channel deleted count.")
count, err = ss.Channel().AnalyticsDeletedTypeCount("", "D") count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "D")
require.Nil(t, err, err) require.Nil(t, nErr, nErr)
assert.Equal(t, directStartCount+1, count, "Wrong direct channel deleted count.") assert.Equal(t, directStartCount+1, count, "Wrong direct channel deleted count.")
} }
@@ -6538,8 +6538,8 @@ func testChannelStoreExportAllDirectChannels(t *testing.T, ss store.Store, s Sql
ss.Channel().SaveDirectChannel(&o1, &m1, &m2) ss.Channel().SaveDirectChannel(&o1, &m1, &m2)
d1, err := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26)) d1, nErr := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, err) assert.Nil(t, nErr)
assert.Len(t, d1, 2) assert.Len(t, d1, 2)
assert.ElementsMatch(t, []string{o1.DisplayName, o2.DisplayName}, []string{d1[0].DisplayName, d1[1].DisplayName}) assert.ElementsMatch(t, []string{o1.DisplayName, o2.DisplayName}, []string{d1[0].DisplayName, d1[1].DisplayName})
@@ -6601,8 +6601,8 @@ func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T
ss.Channel().SaveDirectChannel(&o1, &m1, &m2) ss.Channel().SaveDirectChannel(&o1, &m1, &m2)
d1, err := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26)) d1, nErr := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, err) assert.Nil(t, nErr)
assert.Len(t, d1, 1) assert.Len(t, d1, 1)
assert.Equal(t, o1.DisplayName, d1[0].DisplayName) assert.Equal(t, o1.DisplayName, d1[0].DisplayName)
@@ -6651,8 +6651,8 @@ func testChannelStoreExportAllDirectChannelsDeletedChannel(t *testing.T, ss stor
nErr = ss.Channel().SetDeleteAt(o1.Id, 1, 1) nErr = ss.Channel().SetDeleteAt(o1.Id, 1, 1)
require.Nil(t, nErr, "channel should have been deleted") require.Nil(t, nErr, "channel should have been deleted")
d1, err := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26)) d1, nErr := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, err) assert.Nil(t, nErr)
assert.Equal(t, 0, len(d1)) assert.Equal(t, 0, len(d1))

Просмотреть файл

@@ -144,8 +144,8 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) {
require.Nil(t, nErr) require.Nil(t, nErr)
// Get and check the categories for channels // Get and check the categories for channels
categories, err := ss.Channel().GetSidebarCategories(userId, teamId) categories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err) require.Nil(t, nErr)
require.Len(t, categories.Categories, 3) require.Len(t, categories.Categories, 3)
assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type) assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type)
assert.Equal(t, []string{channel1.Id}, categories.Categories[0].Channels) assert.Equal(t, []string{channel1.Id}, categories.Categories[0].Channels)
@@ -207,8 +207,8 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) {
require.Nil(t, nErr) require.Nil(t, nErr)
// Get and check the categories for channels // Get and check the categories for channels
categories, err := ss.Channel().GetSidebarCategories(userId, teamId) categories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err) require.Nil(t, nErr)
require.Len(t, categories.Categories, 3) require.Len(t, categories.Categories, 3)
assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type) assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type)
assert.Equal(t, []string{channel2.Id, channel1.Id}, categories.Categories[0].Channels) assert.Equal(t, []string{channel2.Id, channel1.Id}, categories.Categories[0].Channels)
@@ -312,8 +312,8 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) {
require.Nil(t, nErr) require.Nil(t, nErr)
// Get and check the categories for channels // Get and check the categories for channels
categories, err := ss.Channel().GetSidebarCategories(userId, teamId) categories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err) require.Nil(t, nErr)
require.Len(t, categories.Categories, 3) require.Len(t, categories.Categories, 3)
assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type) assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type)
assert.Equal(t, []string{}, categories.Categories[0].Channels) assert.Equal(t, []string{}, categories.Categories[0].Channels)
@@ -1370,8 +1370,8 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
require.Nil(t, nErr) require.Nil(t, nErr)
// And some categories // And some categories
initialCategories, err := ss.Channel().GetSidebarCategories(userId, teamId) initialCategories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err) require.Nil(t, nErr)
channelsCategory := initialCategories.Categories[1] channelsCategory := initialCategories.Categories[1]
dmsCategory := initialCategories.Categories[2] dmsCategory := initialCategories.Categories[2]
@@ -1391,8 +1391,8 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
}, },
} }
updatedCategories, err := ss.Channel().UpdateSidebarCategories(userId, teamId, categoriesToUpdate) updatedCategories, nErr := ss.Channel().UpdateSidebarCategories(userId, teamId, categoriesToUpdate)
assert.Nil(t, err) assert.Nil(t, nErr)
// The channels should still exist in the category because they would otherwise be orphaned // The channels should still exist in the category because they would otherwise be orphaned
assert.Equal(t, []string{channel.Id}, updatedCategories[0].Channels) assert.Equal(t, []string{channel.Id}, updatedCategories[0].Channels)
@@ -1510,17 +1510,17 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
nErr = ss.Channel().CreateInitialSidebarCategories(userId, teamId) nErr = ss.Channel().CreateInitialSidebarCategories(userId, teamId)
require.Nil(t, nErr) require.Nil(t, nErr)
initialCategories, err := ss.Channel().GetSidebarCategories(userId, teamId) initialCategories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err) require.Nil(t, nErr)
channelsCategory := initialCategories.Categories[1] channelsCategory := initialCategories.Categories[1]
require.Equal(t, []string{channel.Id}, channelsCategory.Channels) require.Equal(t, []string{channel.Id}, channelsCategory.Channels)
customCategory, err := ss.Channel().CreateSidebarCategory(userId, teamId, &model.SidebarCategoryWithChannels{}) customCategory, nErr := ss.Channel().CreateSidebarCategory(userId, teamId, &model.SidebarCategoryWithChannels{})
require.Nil(t, err) require.Nil(t, nErr)
// Move the channel one way // Move the channel one way
updatedCategories, err := ss.Channel().UpdateSidebarCategories(userId, teamId, []*model.SidebarCategoryWithChannels{ updatedCategories, nErr := ss.Channel().UpdateSidebarCategories(userId, teamId, []*model.SidebarCategoryWithChannels{
{ {
SidebarCategory: channelsCategory.SidebarCategory, SidebarCategory: channelsCategory.SidebarCategory,
Channels: []string{}, Channels: []string{},
@@ -1530,13 +1530,13 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
Channels: []string{channel.Id}, Channels: []string{channel.Id},
}, },
}) })
assert.Nil(t, err) assert.Nil(t, nErr)
assert.Equal(t, []string{}, updatedCategories[0].Channels) assert.Equal(t, []string{}, updatedCategories[0].Channels)
assert.Equal(t, []string{channel.Id}, updatedCategories[1].Channels) assert.Equal(t, []string{channel.Id}, updatedCategories[1].Channels)
// And then the other // And then the other
updatedCategories, err = ss.Channel().UpdateSidebarCategories(userId, teamId, []*model.SidebarCategoryWithChannels{ updatedCategories, nErr = ss.Channel().UpdateSidebarCategories(userId, teamId, []*model.SidebarCategoryWithChannels{
{ {
SidebarCategory: channelsCategory.SidebarCategory, SidebarCategory: channelsCategory.SidebarCategory,
Channels: []string{channel.Id}, Channels: []string{channel.Id},
@@ -1546,7 +1546,7 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
Channels: []string{}, Channels: []string{},
}, },
}) })
assert.Nil(t, err) assert.Nil(t, nErr)
assert.Equal(t, []string{channel.Id}, updatedCategories[0].Channels) assert.Equal(t, []string{channel.Id}, updatedCategories[0].Channels)
assert.Equal(t, []string{}, updatedCategories[1].Channels) assert.Equal(t, []string{}, updatedCategories[1].Channels)
}) })

Просмотреть файл

@@ -16,7 +16,7 @@ type ChannelStore struct {
} }
// AnalyticsDeletedTypeCount provides a mock function with given fields: teamId, channelType // AnalyticsDeletedTypeCount provides a mock function with given fields: teamId, channelType
func (_m *ChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError) { func (_m *ChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error) {
ret := _m.Called(teamId, channelType) ret := _m.Called(teamId, channelType)
var r0 int64 var r0 int64
@@ -26,13 +26,11 @@ func (_m *ChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType str
r0 = ret.Get(0).(int64) r0 = ret.Get(0).(int64)
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(teamId, channelType) r1 = rf(teamId, channelType)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -60,7 +58,7 @@ func (_m *ChannelStore) AnalyticsTypeCount(teamId string, channelType string) (i
} }
// AutocompleteInTeam provides a mock function with given fields: teamId, term, includeDeleted // AutocompleteInTeam provides a mock function with given fields: teamId, term, includeDeleted
func (_m *ChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (_m *ChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
ret := _m.Called(teamId, term, includeDeleted) ret := _m.Called(teamId, term, includeDeleted)
var r0 *model.ChannelList var r0 *model.ChannelList
@@ -72,20 +70,18 @@ func (_m *ChannelStore) AutocompleteInTeam(teamId string, term string, includeDe
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, bool) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, bool) error); ok {
r1 = rf(teamId, term, includeDeleted) r1 = rf(teamId, term, includeDeleted)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// AutocompleteInTeamForSearch provides a mock function with given fields: teamId, userId, term, includeDeleted // 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, *model.AppError) { func (_m *ChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
ret := _m.Called(teamId, userId, term, includeDeleted) ret := _m.Called(teamId, userId, term, includeDeleted)
var r0 *model.ChannelList var r0 *model.ChannelList
@@ -97,29 +93,25 @@ func (_m *ChannelStore) AutocompleteInTeamForSearch(teamId string, userId string
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, string, bool) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, string, bool) error); ok {
r1 = rf(teamId, userId, term, includeDeleted) r1 = rf(teamId, userId, term, includeDeleted)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// ClearAllCustomRoleAssignments provides a mock function with given fields: // ClearAllCustomRoleAssignments provides a mock function with given fields:
func (_m *ChannelStore) ClearAllCustomRoleAssignments() *model.AppError { func (_m *ChannelStore) ClearAllCustomRoleAssignments() error {
ret := _m.Called() ret := _m.Called()
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func() *model.AppError); ok { if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf() r0 = rf()
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
@@ -203,7 +195,7 @@ func (_m *ChannelStore) CreateInitialSidebarCategories(userId string, teamId str
} }
// CreateSidebarCategory provides a mock function with given fields: userId, teamId, newCategory // CreateSidebarCategory provides a mock function with given fields: userId, teamId, newCategory
func (_m *ChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (_m *ChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
ret := _m.Called(userId, teamId, newCategory) ret := _m.Called(userId, teamId, newCategory)
var r0 *model.SidebarCategoryWithChannels var r0 *model.SidebarCategoryWithChannels
@@ -215,13 +207,11 @@ func (_m *ChannelStore) CreateSidebarCategory(userId string, teamId string, newC
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, *model.SidebarCategoryWithChannels) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, *model.SidebarCategoryWithChannels) error); ok {
r1 = rf(userId, teamId, newCategory) r1 = rf(userId, teamId, newCategory)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -242,16 +232,14 @@ func (_m *ChannelStore) Delete(channelId string, time int64) error {
} }
// DeleteSidebarCategory provides a mock function with given fields: categoryId // DeleteSidebarCategory provides a mock function with given fields: categoryId
func (_m *ChannelStore) DeleteSidebarCategory(categoryId string) *model.AppError { func (_m *ChannelStore) DeleteSidebarCategory(categoryId string) error {
ret := _m.Called(categoryId) ret := _m.Called(categoryId)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(categoryId) r0 = rf(categoryId)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
@@ -408,7 +396,7 @@ func (_m *ChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpts) (int64
} }
// GetAllChannelsForExportAfter provides a mock function with given fields: limit, afterId // GetAllChannelsForExportAfter provides a mock function with given fields: limit, afterId
func (_m *ChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) { func (_m *ChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error) {
ret := _m.Called(limit, afterId) ret := _m.Called(limit, afterId)
var r0 []*model.ChannelForExport var r0 []*model.ChannelForExport
@@ -420,20 +408,18 @@ func (_m *ChannelStore) GetAllChannelsForExportAfter(limit int, afterId string)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(int, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(int, string) error); ok {
r1 = rf(limit, afterId) r1 = rf(limit, afterId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetAllDirectChannelsForExportAfter provides a mock function with given fields: limit, afterId // GetAllDirectChannelsForExportAfter provides a mock function with given fields: limit, afterId
func (_m *ChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, *model.AppError) { func (_m *ChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error) {
ret := _m.Called(limit, afterId) ret := _m.Called(limit, afterId)
var r0 []*model.DirectChannelForExport var r0 []*model.DirectChannelForExport
@@ -445,13 +431,11 @@ func (_m *ChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId st
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(int, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(int, string) error); ok {
r1 = rf(limit, afterId) r1 = rf(limit, afterId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -550,7 +534,7 @@ func (_m *ChannelStore) GetChannelCounts(teamId string, userId string) (*model.C
} }
// GetChannelMembersForExport provides a mock function with given fields: userId, teamId // GetChannelMembersForExport provides a mock function with given fields: userId, teamId
func (_m *ChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) { func (_m *ChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error) {
ret := _m.Called(userId, teamId) ret := _m.Called(userId, teamId)
var r0 []*model.ChannelMemberForExport var r0 []*model.ChannelMemberForExport
@@ -562,13 +546,11 @@ func (_m *ChannelStore) GetChannelMembersForExport(userId string, teamId string)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, teamId) r1 = rf(userId, teamId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -598,7 +580,7 @@ func (_m *ChannelStore) GetChannelMembersTimezones(channelId string) ([]model.St
} }
// GetChannelUnread provides a mock function with given fields: channelId, userId // GetChannelUnread provides a mock function with given fields: channelId, userId
func (_m *ChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, *model.AppError) { func (_m *ChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, error) {
ret := _m.Called(channelId, userId) ret := _m.Called(channelId, userId)
var r0 *model.ChannelUnread var r0 *model.ChannelUnread
@@ -610,13 +592,11 @@ func (_m *ChannelStore) GetChannelUnread(channelId string, userId string) (*mode
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(channelId, userId) r1 = rf(channelId, userId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -646,7 +626,7 @@ func (_m *ChannelStore) GetChannels(teamId string, userId string, includeDeleted
} }
// GetChannelsBatchForIndexing provides a mock function with given fields: startTime, endTime, limit // GetChannelsBatchForIndexing provides a mock function with given fields: startTime, endTime, limit
func (_m *ChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, *model.AppError) { func (_m *ChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, error) {
ret := _m.Called(startTime, endTime, limit) ret := _m.Called(startTime, endTime, limit)
var r0 []*model.Channel var r0 []*model.Channel
@@ -658,13 +638,11 @@ func (_m *ChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(int64, int64, int) *model.AppError); ok { if rf, ok := ret.Get(1).(func(int64, int64, int) error); ok {
r1 = rf(startTime, endTime, limit) r1 = rf(startTime, endTime, limit)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -694,7 +672,7 @@ func (_m *ChannelStore) GetChannelsByIds(channelIds []string, includeDeleted boo
} }
// GetChannelsByScheme provides a mock function with given fields: schemeId, offset, limit // GetChannelsByScheme provides a mock function with given fields: schemeId, offset, limit
func (_m *ChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) { func (_m *ChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error) {
ret := _m.Called(schemeId, offset, limit) ret := _m.Called(schemeId, offset, limit)
var r0 model.ChannelList var r0 model.ChannelList
@@ -706,13 +684,11 @@ func (_m *ChannelStore) GetChannelsByScheme(schemeId string, offset int, limit i
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, int, int) error); ok {
r1 = rf(schemeId, offset, limit) r1 = rf(schemeId, offset, limit)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -959,7 +935,7 @@ func (_m *ChannelStore) GetMembers(channelId string, offset int, limit int) (*mo
} }
// GetMembersByIds provides a mock function with given fields: channelId, userIds // GetMembersByIds provides a mock function with given fields: channelId, userIds
func (_m *ChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { func (_m *ChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error) {
ret := _m.Called(channelId, userIds) ret := _m.Called(channelId, userIds)
var r0 *model.ChannelMembers var r0 *model.ChannelMembers
@@ -971,13 +947,11 @@ func (_m *ChannelStore) GetMembersByIds(channelId string, userIds []string) (*mo
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, []string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, []string) error); ok {
r1 = rf(channelId, userIds) r1 = rf(channelId, userIds)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -1166,7 +1140,7 @@ func (_m *ChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limi
} }
// GetSidebarCategories provides a mock function with given fields: userId, teamId // GetSidebarCategories provides a mock function with given fields: userId, teamId
func (_m *ChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, *model.AppError) { func (_m *ChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, error) {
ret := _m.Called(userId, teamId) ret := _m.Called(userId, teamId)
var r0 *model.OrderedSidebarCategories var r0 *model.OrderedSidebarCategories
@@ -1178,20 +1152,18 @@ func (_m *ChannelStore) GetSidebarCategories(userId string, teamId string) (*mod
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, teamId) r1 = rf(userId, teamId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetSidebarCategory provides a mock function with given fields: categoryId // GetSidebarCategory provides a mock function with given fields: categoryId
func (_m *ChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) { func (_m *ChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error) {
ret := _m.Called(categoryId) ret := _m.Called(categoryId)
var r0 *model.SidebarCategoryWithChannels var r0 *model.SidebarCategoryWithChannels
@@ -1203,20 +1175,18 @@ func (_m *ChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCat
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(categoryId) r1 = rf(categoryId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetSidebarCategoryOrder provides a mock function with given fields: userId, teamId // GetSidebarCategoryOrder provides a mock function with given fields: userId, teamId
func (_m *ChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, *model.AppError) { func (_m *ChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, error) {
ret := _m.Called(userId, teamId) ret := _m.Called(userId, teamId)
var r0 []string var r0 []string
@@ -1228,13 +1198,11 @@ func (_m *ChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, teamId) r1 = rf(userId, teamId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -1264,7 +1232,7 @@ func (_m *ChannelStore) GetTeamChannels(teamId string) (*model.ChannelList, erro
} }
// GroupSyncedChannelCount provides a mock function with given fields: // GroupSyncedChannelCount provides a mock function with given fields:
func (_m *ChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) { func (_m *ChannelStore) GroupSyncedChannelCount() (int64, error) {
ret := _m.Called() ret := _m.Called()
var r0 int64 var r0 int64
@@ -1274,13 +1242,11 @@ func (_m *ChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) {
r0 = ret.Get(0).(int64) r0 = ret.Get(0).(int64)
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func() *model.AppError); ok { if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf() r1 = rf()
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -1350,7 +1316,7 @@ func (_m *ChannelStore) IsUserInChannelUseCache(userId string, channelId string)
} }
// MigrateChannelMembers provides a mock function with given fields: fromChannelId, fromUserId // MigrateChannelMembers provides a mock function with given fields: fromChannelId, fromUserId
func (_m *ChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError) { func (_m *ChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error) {
ret := _m.Called(fromChannelId, fromUserId) ret := _m.Called(fromChannelId, fromUserId)
var r0 map[string]string var r0 map[string]string
@@ -1362,13 +1328,11 @@ func (_m *ChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId s
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(fromChannelId, fromUserId) r1 = rf(fromChannelId, fromUserId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -1445,16 +1409,14 @@ func (_m *ChannelStore) PermanentDeleteMembersByUser(userId string) error {
} }
// RemoveAllDeactivatedMembers provides a mock function with given fields: channelId // RemoveAllDeactivatedMembers provides a mock function with given fields: channelId
func (_m *ChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError { func (_m *ChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
ret := _m.Called(channelId) ret := _m.Called(channelId)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(channelId) r0 = rf(channelId)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
@@ -1489,16 +1451,14 @@ func (_m *ChannelStore) RemoveMembers(channelId string, userIds []string) error
} }
// ResetAllChannelSchemes provides a mock function with given fields: // ResetAllChannelSchemes provides a mock function with given fields:
func (_m *ChannelStore) ResetAllChannelSchemes() *model.AppError { func (_m *ChannelStore) ResetAllChannelSchemes() error {
ret := _m.Called() ret := _m.Called()
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func() *model.AppError); ok { if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf() r0 = rf()
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
@@ -1611,7 +1571,7 @@ func (_m *ChannelStore) SaveMultipleMembers(members []*model.ChannelMember) ([]*
} }
// SearchAllChannels provides a mock function with given fields: term, opts // SearchAllChannels provides a mock function with given fields: term, opts
func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) { func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
ret := _m.Called(term, opts) ret := _m.Called(term, opts)
var r0 *model.ChannelListWithTeamData var r0 *model.ChannelListWithTeamData
@@ -1630,20 +1590,18 @@ func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchO
r1 = ret.Get(1).(int64) r1 = ret.Get(1).(int64)
} }
var r2 *model.AppError var r2 error
if rf, ok := ret.Get(2).(func(string, store.ChannelSearchOpts) *model.AppError); ok { if rf, ok := ret.Get(2).(func(string, store.ChannelSearchOpts) error); ok {
r2 = rf(term, opts) r2 = rf(term, opts)
} else { } else {
if ret.Get(2) != nil { r2 = ret.Error(2)
r2 = ret.Get(2).(*model.AppError)
}
} }
return r0, r1, r2 return r0, r1, r2
} }
// SearchArchivedInTeam provides a mock function with given fields: teamId, term, userId // SearchArchivedInTeam provides a mock function with given fields: teamId, term, userId
func (_m *ChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) { func (_m *ChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) {
ret := _m.Called(teamId, term, userId) ret := _m.Called(teamId, term, userId)
var r0 *model.ChannelList var r0 *model.ChannelList
@@ -1655,20 +1613,18 @@ func (_m *ChannelStore) SearchArchivedInTeam(teamId string, term string, userId
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
r1 = rf(teamId, term, userId) r1 = rf(teamId, term, userId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// SearchForUserInTeam provides a mock function with given fields: userId, teamId, term, includeDeleted // 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, *model.AppError) { func (_m *ChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
ret := _m.Called(userId, teamId, term, includeDeleted) ret := _m.Called(userId, teamId, term, includeDeleted)
var r0 *model.ChannelList var r0 *model.ChannelList
@@ -1680,20 +1636,18 @@ func (_m *ChannelStore) SearchForUserInTeam(userId string, teamId string, term s
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, string, bool) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, string, bool) error); ok {
r1 = rf(userId, teamId, term, includeDeleted) r1 = rf(userId, teamId, term, includeDeleted)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// SearchGroupChannels provides a mock function with given fields: userId, term // SearchGroupChannels provides a mock function with given fields: userId, term
func (_m *ChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, *model.AppError) { func (_m *ChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, error) {
ret := _m.Called(userId, term) ret := _m.Called(userId, term)
var r0 *model.ChannelList var r0 *model.ChannelList
@@ -1705,20 +1659,18 @@ func (_m *ChannelStore) SearchGroupChannels(userId string, term string) (*model.
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, term) r1 = rf(userId, term)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// SearchInTeam provides a mock function with given fields: teamId, term, includeDeleted // SearchInTeam provides a mock function with given fields: teamId, term, includeDeleted
func (_m *ChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (_m *ChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
ret := _m.Called(teamId, term, includeDeleted) ret := _m.Called(teamId, term, includeDeleted)
var r0 *model.ChannelList var r0 *model.ChannelList
@@ -1730,20 +1682,18 @@ func (_m *ChannelStore) SearchInTeam(teamId string, term string, includeDeleted
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, bool) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, bool) error); ok {
r1 = rf(teamId, term, includeDeleted) r1 = rf(teamId, term, includeDeleted)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// SearchMore provides a mock function with given fields: userId, teamId, term // SearchMore provides a mock function with given fields: userId, teamId, term
func (_m *ChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError) { func (_m *ChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error) {
ret := _m.Called(userId, teamId, term) ret := _m.Called(userId, teamId, term)
var r0 *model.ChannelList var r0 *model.ChannelList
@@ -1755,13 +1705,11 @@ func (_m *ChannelStore) SearchMore(userId string, teamId string, term string) (*
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
r1 = rf(userId, teamId, term) r1 = rf(userId, teamId, term)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
@@ -1874,16 +1822,14 @@ func (_m *ChannelStore) UpdateMember(member *model.ChannelMember) (*model.Channe
} }
// UpdateMembersRole provides a mock function with given fields: channelID, userIDs // UpdateMembersRole provides a mock function with given fields: channelID, userIDs
func (_m *ChannelStore) UpdateMembersRole(channelID string, userIDs []string) *model.AppError { func (_m *ChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
ret := _m.Called(channelID, userIDs) ret := _m.Called(channelID, userIDs)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string, []string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string, []string) error); ok {
r0 = rf(channelID, userIDs) r0 = rf(channelID, userIDs)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
@@ -1913,7 +1859,7 @@ func (_m *ChannelStore) UpdateMultipleMembers(members []*model.ChannelMember) ([
} }
// UpdateSidebarCategories provides a mock function with given fields: userId, teamId, categories // UpdateSidebarCategories provides a mock function with given fields: userId, teamId, categories
func (_m *ChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) { func (_m *ChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, error) {
ret := _m.Called(userId, teamId, categories) ret := _m.Called(userId, teamId, categories)
var r0 []*model.SidebarCategoryWithChannels var r0 []*model.SidebarCategoryWithChannels
@@ -1925,29 +1871,25 @@ func (_m *ChannelStore) UpdateSidebarCategories(userId string, teamId string, ca
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string, []*model.SidebarCategoryWithChannels) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string, []*model.SidebarCategoryWithChannels) error); ok {
r1 = rf(userId, teamId, categories) r1 = rf(userId, teamId, categories)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// UpdateSidebarCategoryOrder provides a mock function with given fields: userId, teamId, categoryOrder // UpdateSidebarCategoryOrder provides a mock function with given fields: userId, teamId, categoryOrder
func (_m *ChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) *model.AppError { func (_m *ChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) error {
ret := _m.Called(userId, teamId, categoryOrder) ret := _m.Called(userId, teamId, categoryOrder)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string, string, []string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string, string, []string) error); ok {
r0 = rf(userId, teamId, categoryOrder) r0 = rf(userId, teamId, categoryOrder)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
@@ -1982,7 +1924,7 @@ func (_m *ChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Pr
} }
// UserBelongsToChannels provides a mock function with given fields: userId, channelIds // UserBelongsToChannels provides a mock function with given fields: userId, channelIds
func (_m *ChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) { func (_m *ChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
ret := _m.Called(userId, channelIds) ret := _m.Called(userId, channelIds)
var r0 bool var r0 bool
@@ -1992,13 +1934,11 @@ func (_m *ChannelStore) UserBelongsToChannels(userId string, channelIds []string
r0 = ret.Get(0).(bool) r0 = ret.Get(0).(bool)
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, []string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, []string) error); ok {
r1 = rf(userId, channelIds) r1 = rf(userId, channelIds)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1

Просмотреть файл

@@ -488,7 +488,7 @@ func (s *TimerLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
return result, err return result, err
} }
func (s *TimerLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError) { func (s *TimerLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.AnalyticsDeletedTypeCount(teamId, channelType) result, err := s.ChannelStore.AnalyticsDeletedTypeCount(teamId, channelType)
@@ -520,7 +520,7 @@ func (s *TimerLayerChannelStore) AnalyticsTypeCount(teamId string, channelType s
return result, err return result, err
} }
func (s *TimerLayerChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted) result, err := s.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted)
@@ -536,7 +536,7 @@ func (s *TimerLayerChannelStore) AutocompleteInTeam(teamId string, term string,
return result, err return result, err
} }
func (s *TimerLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted) result, err := s.ChannelStore.AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted)
@@ -552,7 +552,7 @@ func (s *TimerLayerChannelStore) AutocompleteInTeamForSearch(teamId string, user
return result, err return result, err
} }
func (s *TimerLayerChannelStore) ClearAllCustomRoleAssignments() *model.AppError { func (s *TimerLayerChannelStore) ClearAllCustomRoleAssignments() error {
start := timemodule.Now() start := timemodule.Now()
err := s.ChannelStore.ClearAllCustomRoleAssignments() err := s.ChannelStore.ClearAllCustomRoleAssignments()
@@ -647,7 +647,7 @@ func (s *TimerLayerChannelStore) CreateInitialSidebarCategories(userId string, t
return err return err
} }
func (s *TimerLayerChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s *TimerLayerChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.CreateSidebarCategory(userId, teamId, newCategory) result, err := s.ChannelStore.CreateSidebarCategory(userId, teamId, newCategory)
@@ -679,7 +679,7 @@ func (s *TimerLayerChannelStore) Delete(channelId string, time int64) error {
return err return err
} }
func (s *TimerLayerChannelStore) DeleteSidebarCategory(categoryId string) *model.AppError { func (s *TimerLayerChannelStore) DeleteSidebarCategory(categoryId string) error {
start := timemodule.Now() start := timemodule.Now()
err := s.ChannelStore.DeleteSidebarCategory(categoryId) err := s.ChannelStore.DeleteSidebarCategory(categoryId)
@@ -807,7 +807,7 @@ func (s *TimerLayerChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpt
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) { func (s *TimerLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetAllChannelsForExportAfter(limit, afterId) result, err := s.ChannelStore.GetAllChannelsForExportAfter(limit, afterId)
@@ -823,7 +823,7 @@ func (s *TimerLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, *model.AppError) { func (s *TimerLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterId) result, err := s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterId)
@@ -903,7 +903,7 @@ func (s *TimerLayerChannelStore) GetChannelCounts(teamId string, userId string)
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) { func (s *TimerLayerChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetChannelMembersForExport(userId, teamId) result, err := s.ChannelStore.GetChannelMembersForExport(userId, teamId)
@@ -935,7 +935,7 @@ func (s *TimerLayerChannelStore) GetChannelMembersTimezones(channelId string) ([
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, *model.AppError) { func (s *TimerLayerChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetChannelUnread(channelId, userId) result, err := s.ChannelStore.GetChannelUnread(channelId, userId)
@@ -967,7 +967,7 @@ func (s *TimerLayerChannelStore) GetChannels(teamId string, userId string, inclu
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, *model.AppError) { func (s *TimerLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit) result, err := s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit)
@@ -999,7 +999,7 @@ func (s *TimerLayerChannelStore) GetChannelsByIds(channelIds []string, includeDe
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetChannelsByScheme(schemeId, offset, limit) result, err := s.ChannelStore.GetChannelsByScheme(schemeId, offset, limit)
@@ -1191,7 +1191,7 @@ func (s *TimerLayerChannelStore) GetMembers(channelId string, offset int, limit
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError) { func (s *TimerLayerChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetMembersByIds(channelId, userIds) result, err := s.ChannelStore.GetMembersByIds(channelId, userIds)
@@ -1335,7 +1335,7 @@ func (s *TimerLayerChannelStore) GetPublicChannelsForTeam(teamId string, offset
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, *model.AppError) { func (s *TimerLayerChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetSidebarCategories(userId, teamId) result, err := s.ChannelStore.GetSidebarCategories(userId, teamId)
@@ -1351,7 +1351,7 @@ func (s *TimerLayerChannelStore) GetSidebarCategories(userId string, teamId stri
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) { func (s *TimerLayerChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetSidebarCategory(categoryId) result, err := s.ChannelStore.GetSidebarCategory(categoryId)
@@ -1367,7 +1367,7 @@ func (s *TimerLayerChannelStore) GetSidebarCategory(categoryId string) (*model.S
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, *model.AppError) { func (s *TimerLayerChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GetSidebarCategoryOrder(userId, teamId) result, err := s.ChannelStore.GetSidebarCategoryOrder(userId, teamId)
@@ -1399,7 +1399,7 @@ func (s *TimerLayerChannelStore) GetTeamChannels(teamId string) (*model.ChannelL
return result, err return result, err
} }
func (s *TimerLayerChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) { func (s *TimerLayerChannelStore) GroupSyncedChannelCount() (int64, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.GroupSyncedChannelCount() result, err := s.ChannelStore.GroupSyncedChannelCount()
@@ -1552,7 +1552,7 @@ func (s *TimerLayerChannelStore) IsUserInChannelUseCache(userId string, channelI
return result return result
} }
func (s *TimerLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError) { func (s *TimerLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.MigrateChannelMembers(fromChannelId, fromUserId) result, err := s.ChannelStore.MigrateChannelMembers(fromChannelId, fromUserId)
@@ -1648,7 +1648,7 @@ func (s *TimerLayerChannelStore) PermanentDeleteMembersByUser(userId string) err
return err return err
} }
func (s *TimerLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError { func (s *TimerLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
start := timemodule.Now() start := timemodule.Now()
err := s.ChannelStore.RemoveAllDeactivatedMembers(channelId) err := s.ChannelStore.RemoveAllDeactivatedMembers(channelId)
@@ -1696,7 +1696,7 @@ func (s *TimerLayerChannelStore) RemoveMembers(channelId string, userIds []strin
return err return err
} }
func (s *TimerLayerChannelStore) ResetAllChannelSchemes() *model.AppError { func (s *TimerLayerChannelStore) ResetAllChannelSchemes() error {
start := timemodule.Now() start := timemodule.Now()
err := s.ChannelStore.ResetAllChannelSchemes() err := s.ChannelStore.ResetAllChannelSchemes()
@@ -1792,7 +1792,7 @@ func (s *TimerLayerChannelStore) SaveMultipleMembers(members []*model.ChannelMem
return result, err return result, err
} }
func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) { func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
start := timemodule.Now() start := timemodule.Now()
result, resultVar1, err := s.ChannelStore.SearchAllChannels(term, opts) result, resultVar1, err := s.ChannelStore.SearchAllChannels(term, opts)
@@ -1808,7 +1808,7 @@ func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts store.Chann
return result, resultVar1, err return result, resultVar1, err
} }
func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.SearchArchivedInTeam(teamId, term, userId) result, err := s.ChannelStore.SearchArchivedInTeam(teamId, term, userId)
@@ -1824,7 +1824,7 @@ func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamId string, term string
return result, err return result, err
} }
func (s *TimerLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.SearchForUserInTeam(userId, teamId, term, includeDeleted) result, err := s.ChannelStore.SearchForUserInTeam(userId, teamId, term, includeDeleted)
@@ -1840,7 +1840,7 @@ func (s *TimerLayerChannelStore) SearchForUserInTeam(userId string, teamId strin
return result, err return result, err
} }
func (s *TimerLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.SearchGroupChannels(userId, term) result, err := s.ChannelStore.SearchGroupChannels(userId, term)
@@ -1856,7 +1856,7 @@ func (s *TimerLayerChannelStore) SearchGroupChannels(userId string, term string)
return result, err return result, err
} }
func (s *TimerLayerChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.SearchInTeam(teamId, term, includeDeleted) result, err := s.ChannelStore.SearchInTeam(teamId, term, includeDeleted)
@@ -1872,7 +1872,7 @@ func (s *TimerLayerChannelStore) SearchInTeam(teamId string, term string, includ
return result, err return result, err
} }
func (s *TimerLayerChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError) { func (s *TimerLayerChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.SearchMore(userId, teamId, term) result, err := s.ChannelStore.SearchMore(userId, teamId, term)
@@ -1968,7 +1968,7 @@ func (s *TimerLayerChannelStore) UpdateMember(member *model.ChannelMember) (*mod
return result, err return result, err
} }
func (s *TimerLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) *model.AppError { func (s *TimerLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
start := timemodule.Now() start := timemodule.Now()
err := s.ChannelStore.UpdateMembersRole(channelID, userIDs) err := s.ChannelStore.UpdateMembersRole(channelID, userIDs)
@@ -2000,7 +2000,7 @@ func (s *TimerLayerChannelStore) UpdateMultipleMembers(members []*model.ChannelM
return result, err return result, err
} }
func (s *TimerLayerChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) { func (s *TimerLayerChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.UpdateSidebarCategories(userId, teamId, categories) result, err := s.ChannelStore.UpdateSidebarCategories(userId, teamId, categories)
@@ -2016,7 +2016,7 @@ func (s *TimerLayerChannelStore) UpdateSidebarCategories(userId string, teamId s
return result, err return result, err
} }
func (s *TimerLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) *model.AppError { func (s *TimerLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) error {
start := timemodule.Now() start := timemodule.Now()
err := s.ChannelStore.UpdateSidebarCategoryOrder(userId, teamId, categoryOrder) err := s.ChannelStore.UpdateSidebarCategoryOrder(userId, teamId, categoryOrder)
@@ -2064,7 +2064,7 @@ func (s *TimerLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences
return err return err
} }
func (s *TimerLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) { func (s *TimerLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
start := timemodule.Now() start := timemodule.Now()
result, err := s.ChannelStore.UserBelongsToChannels(userId, channelIds) result, err := s.ChannelStore.UserBelongsToChannels(userId, channelIds)