* 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 удалений

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

@@ -504,7 +504,7 @@ func (s *OpenTracingLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AnalyticsDeletedTypeCount")
s.Root.Store.SetContext(newCtx)
@@ -540,7 +540,7 @@ func (s *OpenTracingLayerChannelStore) AnalyticsTypeCount(teamId string, channel
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeam")
s.Root.Store.SetContext(newCtx)
@@ -558,7 +558,7 @@ func (s *OpenTracingLayerChannelStore) AutocompleteInTeam(teamId string, term st
return result, err
}
func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AutocompleteInTeamForSearch")
s.Root.Store.SetContext(newCtx)
@@ -576,7 +576,7 @@ func (s *OpenTracingLayerChannelStore) AutocompleteInTeamForSearch(teamId string
return result, err
}
func (s *OpenTracingLayerChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
func (s *OpenTracingLayerChannelStore) ClearAllCustomRoleAssignments() error {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.ClearAllCustomRoleAssignments")
s.Root.Store.SetContext(newCtx)
@@ -679,7 +679,7 @@ func (s *OpenTracingLayerChannelStore) CreateInitialSidebarCategories(userId str
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.CreateSidebarCategory")
s.Root.Store.SetContext(newCtx)
@@ -715,7 +715,7 @@ func (s *OpenTracingLayerChannelStore) Delete(channelId string, time int64) erro
return err
}
func (s *OpenTracingLayerChannelStore) DeleteSidebarCategory(categoryId string) *model.AppError {
func (s *OpenTracingLayerChannelStore) DeleteSidebarCategory(categoryId string) error {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.DeleteSidebarCategory")
s.Root.Store.SetContext(newCtx)
@@ -859,7 +859,7 @@ func (s *OpenTracingLayerChannelStore) GetAllChannelsCount(opts store.ChannelSea
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetAllChannelsForExportAfter")
s.Root.Store.SetContext(newCtx)
@@ -877,7 +877,7 @@ func (s *OpenTracingLayerChannelStore) GetAllChannelsForExportAfter(limit int, a
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetAllDirectChannelsForExportAfter")
s.Root.Store.SetContext(newCtx)
@@ -967,7 +967,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelCounts(teamId string, userId st
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelMembersForExport")
s.Root.Store.SetContext(newCtx)
@@ -1003,7 +1003,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelMembersTimezones(channelId stri
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelUnread")
s.Root.Store.SetContext(newCtx)
@@ -1039,7 +1039,7 @@ func (s *OpenTracingLayerChannelStore) GetChannels(teamId string, userId string,
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelsBatchForIndexing")
s.Root.Store.SetContext(newCtx)
@@ -1075,7 +1075,7 @@ func (s *OpenTracingLayerChannelStore) GetChannelsByIds(channelIds []string, inc
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetChannelsByScheme")
s.Root.Store.SetContext(newCtx)
@@ -1286,7 +1286,7 @@ func (s *OpenTracingLayerChannelStore) GetMembers(channelId string, offset int,
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMembersByIds")
s.Root.Store.SetContext(newCtx)
@@ -1448,7 +1448,7 @@ func (s *OpenTracingLayerChannelStore) GetPublicChannelsForTeam(teamId string, o
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategories")
s.Root.Store.SetContext(newCtx)
@@ -1466,7 +1466,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategories(userId string, teamI
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategory")
s.Root.Store.SetContext(newCtx)
@@ -1484,7 +1484,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategory(categoryId string) (*m
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategoryOrder")
s.Root.Store.SetContext(newCtx)
@@ -1520,7 +1520,7 @@ func (s *OpenTracingLayerChannelStore) GetTeamChannels(teamId string) (*model.Ch
return result, err
}
func (s *OpenTracingLayerChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) {
func (s *OpenTracingLayerChannelStore) GroupSyncedChannelCount() (int64, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GroupSyncedChannelCount")
s.Root.Store.SetContext(newCtx)
@@ -1660,7 +1660,7 @@ func (s *OpenTracingLayerChannelStore) IsUserInChannelUseCache(userId string, ch
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.MigrateChannelMembers")
s.Root.Store.SetContext(newCtx)
@@ -1768,7 +1768,7 @@ func (s *OpenTracingLayerChannelStore) PermanentDeleteMembersByUser(userId strin
return err
}
func (s *OpenTracingLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError {
func (s *OpenTracingLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.RemoveAllDeactivatedMembers")
s.Root.Store.SetContext(newCtx)
@@ -1822,7 +1822,7 @@ func (s *OpenTracingLayerChannelStore) RemoveMembers(channelId string, userIds [
return err
}
func (s *OpenTracingLayerChannelStore) ResetAllChannelSchemes() *model.AppError {
func (s *OpenTracingLayerChannelStore) ResetAllChannelSchemes() error {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.ResetAllChannelSchemes")
s.Root.Store.SetContext(newCtx)
@@ -1930,7 +1930,7 @@ func (s *OpenTracingLayerChannelStore) SaveMultipleMembers(members []*model.Chan
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchAllChannels")
s.Root.Store.SetContext(newCtx)
@@ -1948,7 +1948,7 @@ func (s *OpenTracingLayerChannelStore) SearchAllChannels(term string, opts store
return result, resultVar1, err
}
func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) {
func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchArchivedInTeam")
s.Root.Store.SetContext(newCtx)
@@ -1966,7 +1966,7 @@ func (s *OpenTracingLayerChannelStore) SearchArchivedInTeam(teamId string, term
return result, err
}
func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchForUserInTeam")
s.Root.Store.SetContext(newCtx)
@@ -1984,7 +1984,7 @@ func (s *OpenTracingLayerChannelStore) SearchForUserInTeam(userId string, teamId
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchGroupChannels")
s.Root.Store.SetContext(newCtx)
@@ -2002,7 +2002,7 @@ func (s *OpenTracingLayerChannelStore) SearchGroupChannels(userId string, term s
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchInTeam")
s.Root.Store.SetContext(newCtx)
@@ -2020,7 +2020,7 @@ func (s *OpenTracingLayerChannelStore) SearchInTeam(teamId string, term string,
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.SearchMore")
s.Root.Store.SetContext(newCtx)
@@ -2128,7 +2128,7 @@ func (s *OpenTracingLayerChannelStore) UpdateMember(member *model.ChannelMember)
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateMembersRole")
s.Root.Store.SetContext(newCtx)
@@ -2164,7 +2164,7 @@ func (s *OpenTracingLayerChannelStore) UpdateMultipleMembers(members []*model.Ch
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategories")
s.Root.Store.SetContext(newCtx)
@@ -2182,7 +2182,7 @@ func (s *OpenTracingLayerChannelStore) UpdateSidebarCategories(userId string, te
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategoryOrder")
s.Root.Store.SetContext(newCtx)
@@ -2236,7 +2236,7 @@ func (s *OpenTracingLayerChannelStore) UpdateSidebarChannelsByPreferences(prefer
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()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UserBelongsToChannels")
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
}
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 err *model.AppError
var appErr *model.AppError
var nErr error
allFailed := true
for _, engine := range c.rootStore.searchEngine.GetActiveEngines() {
if engine.IsAutocompletionEnabled() {
channelList, err = c.searchAutocompleteChannels(engine, teamId, term, includeDeleted)
if err != nil {
mlog.Error("Encountered error on AutocompleteChannels through SearchEngine. Falling back to default autocompletion.", mlog.String("search_engine", engine.GetName()), mlog.Err(err))
channelList, appErr = c.searchAutocompleteChannels(engine, teamId, term, includeDeleted)
if appErr != nil {
mlog.Error("Encountered error on AutocompleteChannels through SearchEngine. Falling back to default autocompletion.", mlog.String("search_engine", engine.GetName()), mlog.Err(appErr))
continue
}
allFailed = false
@@ -148,12 +149,17 @@ func (c *SearchChannelStore) AutocompleteInTeam(teamId string, term string, incl
if allFailed {
mlog.Debug("Using database search because no other search engine is available")
channelList, err = c.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted)
if err != nil {
return nil, err
channelList, nErr = c.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted)
if nErr != nil {
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) {
@@ -185,7 +191,7 @@ func (c *SearchChannelStore) PermanentDeleteMembersByUser(userId string) error {
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)
if errProfiles != nil {
mlog.Error("Encountered error indexing users for channel", mlog.String("channel_id", channelId), mlog.Err(errProfiles))

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

@@ -6,7 +6,6 @@ package sqlstore
import (
"database/sql"
"fmt"
"net/http"
"sort"
"strconv"
"strings"
@@ -707,7 +706,7 @@ func (s SqlChannelStore) updateChannelT(transaction *gorp.Transaction, channel *
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
err := s.GetReplica().SelectOne(&unreadChannel,
`SELECT
@@ -723,9 +722,9 @@ func (s SqlChannelStore) GetChannelUnread(channelId, userId string) (*model.Chan
if err != nil {
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
}
@@ -2015,7 +2014,7 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) error {
return s.RemoveMembers(channelId, []string{userId})
}
func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError {
func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
query := `
DELETE
FROM
@@ -2035,7 +2034,7 @@ func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.Ap
_, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId})
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
}
@@ -2306,7 +2305,7 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) (
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"
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})
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
@@ -2343,7 +2342,7 @@ func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string,
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"
if includeDeleted {
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 _, 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 {
// 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)
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
}
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"
if includeDeleted {
deleteFilter = ""
@@ -2411,7 +2410,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin
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 {
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 {
// 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)
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
}
func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string, term string) ([]*model.Channel, *model.AppError) {
func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string, term string) ([]*model.Channel, error) {
queryFormat := `
SELECT
C.*,
@@ -2468,20 +2467,20 @@ func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string
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 {
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 {
query := fmt.Sprintf(queryFormat, "AND "+likeClause)
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
}
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"
if includeDeleted {
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(`
SELECT
Channels.*
@@ -2556,7 +2555,7 @@ func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId
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"
if includeDeleted {
deleteFilter = ""
@@ -2668,14 +2667,14 @@ func (s SqlChannelStore) channelSearchQuery(term string, opts store.ChannelSearc
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()
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
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
@@ -2684,10 +2683,10 @@ func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearch
if opts.IsPaginated() {
queryString, args, err = s.channelSearchQuery(term, opts, true).ToSql()
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 {
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 {
totalCount = int64(len(channels))
@@ -2696,7 +2695,7 @@ func (s SqlChannelStore) SearchAllChannels(term string, opts store.ChannelSearch
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(`
SELECT
Channels.*
@@ -2789,7 +2788,7 @@ func (s SqlChannelStore) buildFulltextClause(term string, searchColumns string)
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")
if likeTerm == "" {
// 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
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
@@ -2898,18 +2897,18 @@ func (s SqlChannelStore) getSearchGroupChannelsQuery(userId, term string, isPost
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
queryString, args := s.getSearchGroupChannelsQuery(userId, term, isPostgreSQL)
var groupChannels model.ChannelList
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
}
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
props := make(map[string]interface{})
idQuery := ""
@@ -2926,17 +2925,17 @@ func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) (*m
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 {
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
}
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
_, 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 {
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
}
@@ -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
// 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.
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 err error
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)
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 {
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 {
@@ -2991,13 +2990,13 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
member.Roles = strings.Join(newRoles, " ")
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 {
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)
@@ -3006,34 +3005,34 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
return data, nil
}
func (s SqlChannelStore) ResetAllChannelSchemes() *model.AppError {
func (s SqlChannelStore) ResetAllChannelSchemes() error {
transaction, err := s.GetMaster().Begin()
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)
resetErr := s.resetAllChannelSchemesT(transaction)
if resetErr != nil {
return resetErr
err = s.resetAllChannelSchemesT(transaction)
if err != nil {
return err
}
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
}
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 {
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
}
func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
func (s SqlChannelStore) ClearAllCustomRoleAssignments() error {
builtInRoles := model.MakeDefaultRoles()
lastUserId := strings.Repeat("0", 26)
lastChannelId := strings.Repeat("0", 26)
@@ -3043,13 +3042,13 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
var err error
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
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)
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 {
@@ -3076,21 +3075,21 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
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 {
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 {
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
}
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
if _, err := s.GetReplica().Select(&channels, `
SELECT
@@ -3109,13 +3108,13 @@ func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string)
Id
LIMIT :Limit`,
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
}
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
_, err := s.GetReplica().Select(&members, `
SELECT
@@ -3142,13 +3141,13 @@ func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string
map[string]interface{}{"TeamId": teamId, "UserId": userId})
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
}
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
query := s.getQueryBuilder().
Select("Channels.*").
@@ -3163,11 +3162,11 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
queryString, args, err := query.ToSql()
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 {
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
@@ -3185,12 +3184,12 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
queryString, args, err = query.ToSql()
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
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
@@ -3207,7 +3206,7 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
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 :=
`SELECT
*
@@ -3227,13 +3226,13 @@ func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, l
var channels []*model.Channel
_, err := s.GetSearchReplica().Select(&channels, query, map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumChannels": limit})
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
}
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError) {
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
query := s.getQueryBuilder().
Select("Count(*)").
From("ChannelMembers").
@@ -3244,16 +3243,16 @@ func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []strin
queryString, args, err := query.ToSql()
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...)
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
}
func (s SqlChannelStore) UpdateMembersRole(channelID string, userIDs []string) *model.AppError {
func (s SqlChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
sql := fmt.Sprintf(`
UPDATE
ChannelMembers
@@ -3269,23 +3268,23 @@ func (s SqlChannelStore) UpdateMembersRole(channelID string, userIDs []string) *
`, strings.Join(userIDs, "', '"))
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
}
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})
sql, args, err := query.ToSql()
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...)
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

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

@@ -4,7 +4,9 @@
package sqlstore
import (
"net/http"
"fmt"
"github.com/mattermost/mattermost-server/v5/store"
"github.com/mattermost/gorp"
"github.com/mattermost/mattermost-server/v5/model"
@@ -222,21 +224,23 @@ type sidebarCategoryForJoin struct {
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()
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)
categoriesWithOrder, appErr := s.getSidebarCategoriesT(transaction, userId, teamId)
if appErr != nil {
return nil, appErr
categoriesWithOrder, err := s.getSidebarCategoriesT(transaction, userId, teamId)
if err != nil {
return nil, err
}
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
newCategoryId := model.NewId()
newCategorySortOrder := 0
@@ -262,7 +266,7 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
Type: model.SidebarCategoryCustom,
}
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 {
@@ -299,7 +303,7 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
_, err = transaction.Exec(deleteQuery, deleteParams)
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{}
@@ -312,17 +316,17 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
})
}
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
if appErr := s.updateSidebarCategoryOrderT(transaction, userId, teamId, newOrder); appErr != nil {
return nil, appErr
if err = s.updateSidebarCategoryOrderT(transaction, userId, teamId, newOrder); err != nil {
return nil, err
}
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
@@ -335,26 +339,26 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
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()
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)
result, appErr := s.completePopulatingCategoryChannelsT(transaction, category)
if appErr != nil {
return nil, appErr
result, err := s.completePopulatingCategoryChannelsT(transaction, category)
if err != nil {
return nil, err
}
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
}
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 {
return category, nil
}
@@ -384,7 +388,7 @@ func (s SqlChannelStore) completePopulatingCategoryChannelsT(transation *gorp.Tr
Suffix(")")
var channels []string
sql, args, _ := s.getQueryBuilder().
sql, args, err := s.getQueryBuilder().
Select("Id").
From("ChannelMembers").
LeftJoin("Channels ON Channels.Id=ChannelMembers.ChannelId").
@@ -395,29 +399,38 @@ func (s SqlChannelStore) completePopulatingCategoryChannelsT(transation *gorp.Tr
doesNotHaveSidebarChannel,
}).
OrderBy("DisplayName ASC").ToSql()
if err != nil {
return nil, errors.Wrap(err, "channel_tosql")
}
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)
if _, err = transation.Select(&channels, sql, args...); err != nil {
return nil, store.NewErrNotFound("ChannelMembers", "<too many fields>")
}
category.Channels = append(channels, category.Channels...)
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
sql, args, _ := s.getQueryBuilder().
sql, args, err := s.getQueryBuilder().
Select("SidebarCategories.*", "SidebarChannels.ChannelId").
From("SidebarCategories").
LeftJoin("SidebarChannels ON SidebarChannels.CategoryId=SidebarCategories.Id").
Where(sq.Eq{"SidebarCategories.Id": categoryId}).
OrderBy("SidebarChannels.SortOrder ASC").ToSql()
if _, err := s.GetReplica().Select(&categories, sql, args...); err != nil {
return nil, model.NewAppError("SqlPostStore.GetSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound)
if err != nil {
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 {
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{
SidebarCategory: categories[0].SidebarCategory,
Channels: make([]string, 0),
@@ -430,14 +443,14 @@ func (s SqlChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCa
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{
Categories: make(model.SidebarCategoriesWithChannels, 0),
Order: make([]string, 0),
}
var categories []*sidebarCategoryForJoin
sql, args, _ := s.getQueryBuilder().
query, args, err := s.getQueryBuilder().
Select("SidebarCategories.*", "SidebarChannels.ChannelId").
From("SidebarCategories").
LeftJoin("SidebarChannels ON SidebarChannels.CategoryId=Id").
@@ -446,9 +459,12 @@ func (s SqlChannelStore) getSidebarCategoriesT(transaction *gorp.Transaction, us
sq.Eq{"SidebarCategories.TeamId": teamId},
}).
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 {
return nil, model.NewAppError("SqlPostStore.GetSidebarCategories", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound)
if _, err = transaction.Select(&categories, query, args...); err != nil {
return nil, store.NewErrNotFound("SidebarCategories", fmt.Sprintf("userId=%s,teamId=%s", userId, teamId))
}
for _, category := range categories {
var prevCategory *model.SidebarCategoryWithChannels
@@ -479,30 +495,30 @@ func (s SqlChannelStore) getSidebarCategoriesT(transaction *gorp.Transaction, us
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()
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)
oc, appErr := s.getSidebarCategoriesT(transaction, userId, teamId)
if appErr != nil {
return nil, appErr
oc, err := s.getSidebarCategoriesT(transaction, userId, teamId)
if err != nil {
return nil, err
}
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
}
func (s SqlChannelStore) GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError) {
func (s SqlChannelStore) GetSidebarCategoryOrder(userId, teamId string) ([]string, error) {
var ids []string
sql, args, _ := s.getQueryBuilder().
sql, args, err := s.getQueryBuilder().
Select("Id").
From("SidebarCategories").
Where(sq.And{
@@ -511,13 +527,18 @@ func (s SqlChannelStore) GetSidebarCategoryOrder(userId, teamId string) ([]strin
}).
OrderBy("SidebarCategories.SortOrder ASC").ToSql()
if _, err := s.GetReplica().Select(&ids, sql, args...); err != nil {
return nil, model.NewAppError("SqlPostStore.GetSidebarCategoryOrder", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound)
if err != nil {
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
}
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{}
runningOrder := 0
for _, categoryId := range categoryOrder {
@@ -534,28 +555,30 @@ func (s SqlChannelStore) updateSidebarCategoryOrderT(transaction *gorp.Transacti
if _, err := transaction.UpdateColumns(func(col *gorp.ColumnMap) bool {
return col.ColumnName == "SortOrder"
}, 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
}
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()
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)
// Ensure no invalid categories are included and that no categories are left out
existingOrder, appErr := s.GetSidebarCategoryOrder(userId, teamId)
if appErr != nil {
return appErr
existingOrder, err := s.GetSidebarCategoryOrder(userId, teamId)
if err != nil {
return err
}
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 {
found := false
for _, newCategoryId := range categoryOrder {
@@ -565,33 +588,33 @@ func (s SqlChannelStore) UpdateSidebarCategoryOrder(userId, teamId string, categ
}
}
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 {
return appErr
if err = s.updateSidebarCategoryOrderT(transaction, userId, teamId, categoryOrder); err != nil {
return err
}
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
}
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()
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)
updatedCategories := []*model.SidebarCategoryWithChannels{}
for _, category := range categories {
originalCategory, appErr := s.GetSidebarCategory(category.Id)
if appErr != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, appErr.Error(), http.StatusInternalServerError)
originalCategory, err2 := s.GetSidebarCategory(category.Id)
if err2 != nil {
return nil, errors.Wrap(err2, "failed to find SidebarCategories")
}
// 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()
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.
@@ -629,7 +652,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
// Remove any SidebarChannels entries that were either:
// - 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
sql, args, _ := s.getQueryBuilder().
query, args, err2 := s.getQueryBuilder().
Delete("SidebarChannels").
Where(
sq.And{
@@ -641,8 +664,12 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
},
).ToSql()
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)
if err2 != nil {
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{}
@@ -658,7 +685,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
}
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()
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
@@ -687,21 +714,24 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
Category: model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL,
Value: "true",
}); 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 {
// 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{
"UserId": userId,
"Name": category.Channels,
"Category": model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL,
},
).ToSql()
if nErr != nil {
return nil, errors.Wrap(nErr, "update_sidebar_categories_tosql")
}
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)
if _, nErr = transaction.Exec(query, args...); nErr != nil {
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
for i, updatedCategory := range updatedCategories {
populated, err := s.completePopulatingCategoryChannelsT(transaction, updatedCategory)
if err != nil {
return nil, model.NewAppError("SqlPostStore.UpdateSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
populated, nErr := s.completePopulatingCategoryChannelsT(transaction, updatedCategory)
if nErr != nil {
return nil, nErr
}
updatedCategories[i] = populated
}
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
@@ -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
// 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()
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)
// Ensure that we're deleting a custom category
var category *model.SidebarCategory
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 {
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
sql, args, _ := s.getQueryBuilder().
query, args, err := s.getQueryBuilder().
Delete("SidebarChannels").
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 {
return model.NewAppError("SqlPostStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
if _, err = transaction.Exec(query, args...); err != nil {
return errors.Wrap(err, "failed to delete SidebarChannel")
}
// Delete the category itself
sql, args, _ = s.getQueryBuilder().
query, args, err = s.getQueryBuilder().
Delete("SidebarCategories").
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 {
return model.NewAppError("SqlChannelStore.DeleteSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusInternalServerError)
if _, err = transaction.Exec(query, args...); err != nil {
return errors.Wrap(err, "failed to delete SidebarCategory")
}
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

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

@@ -198,46 +198,46 @@ type ChannelStore interface {
AnalyticsTypeCount(teamId string, channelType string) (int64, error)
GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, error)
GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (*model.ChannelMembers, error)
AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError)
SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError)
SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError)
SearchGroupChannels(userId, term string) (*model.ChannelList, *model.AppError)
GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError)
AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError)
GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError)
AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error)
SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error)
SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error)
SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error)
SearchMore(userId string, teamId string, term string) (*model.ChannelList, error)
SearchGroupChannels(userId, term string) (*model.ChannelList, error)
GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error)
AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error)
GetChannelUnread(channelId, userId string) (*model.ChannelUnread, error)
ClearCaches()
GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError)
MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError)
ResetAllChannelSchemes() *model.AppError
ClearAllCustomRoleAssignments() *model.AppError
GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error)
MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error)
ResetAllChannelSchemes() error
ClearAllCustomRoleAssignments() error
MigratePublicChannels() error
CreateInitialSidebarCategories(userId, teamId string) error
GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, *model.AppError)
GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError)
GetSidebarCategoryOrder(userId, teamId string) ([]string, *model.AppError)
CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError)
UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) *model.AppError
UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError)
GetSidebarCategories(userId, teamId string) (*model.OrderedSidebarCategories, error)
GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error)
GetSidebarCategoryOrder(userId, teamId string) ([]string, error)
CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error)
UpdateSidebarCategoryOrder(userId, teamId string, categoryOrder []string) error
UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, error)
UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error
DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error
DeleteSidebarCategory(categoryId string) *model.AppError
GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError)
GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, *model.AppError)
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError)
RemoveAllDeactivatedMembers(channelId string) *model.AppError
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError)
UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError)
DeleteSidebarCategory(categoryId string) error
GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error)
GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error)
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error)
RemoveAllDeactivatedMembers(channelId string) error
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, error)
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
// 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() (int64, *model.AppError)
GroupSyncedChannelCount() (int64, error)
}
type ChannelMemberHistoryStore interface {

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

@@ -341,9 +341,9 @@ func testGetChannelUnread(t *testing.T, ss store.Store) {
require.Nil(t, err)
// 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, teamId1, ch.TeamId, "Wrong team id 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")
// 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, teamId2, ch2.TeamId, "Wrong team id")
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}},
}
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,
"SearchInTeam": ss.Channel().SearchInTeam,
} {
@@ -5503,10 +5503,10 @@ func testChannelStoreGetMembersByIds(t *testing.T, ss store.Store) {
require.Nil(t, err)
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]
require.Nil(t, err, err)
require.Equal(t, m1.ChannelId, rm1.ChannelId, "bad team 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)
require.Nil(t, err)
members, err = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId, m2.UserId, model.NewId()})
require.Nil(t, err, err)
members, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId, m2.UserId, model.NewId()})
require.Nil(t, nErr, nErr)
require.Len(t, *members, 2, "return wrong number of results")
_, err = ss.Channel().GetMembersByIds(m1.ChannelId, []string{})
require.NotNil(t, err, "empty user ids - should have failed")
_, nErr = ss.Channel().GetMembersByIds(m1.ChannelId, []string{})
require.NotNil(t, nErr, "empty user ids - should have failed")
}
func testChannelStoreSearchGroupChannels(t *testing.T, ss store.Store) {
@@ -5721,16 +5721,16 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) {
}()
var openStartCount int64
openStartCount, err = ss.Channel().AnalyticsDeletedTypeCount("", "O")
require.Nil(t, err, err)
openStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "O")
require.Nil(t, nErr, nErr)
var privateStartCount int64
privateStartCount, err = ss.Channel().AnalyticsDeletedTypeCount("", "P")
require.Nil(t, err, err)
privateStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "P")
require.Nil(t, nErr, nErr)
var directStartCount int64
directStartCount, err = ss.Channel().AnalyticsDeletedTypeCount("", "D")
require.Nil(t, err, err)
directStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "D")
require.Nil(t, nErr, nErr)
nErr = ss.Channel().Delete(o1.Id, model.GetMillis())
require.Nil(t, nErr, "channel should have been deleted")
@@ -5743,16 +5743,16 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) {
var count int64
count, err = ss.Channel().AnalyticsDeletedTypeCount("", "O")
require.Nil(t, err, err)
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "O")
require.Nil(t, err, nErr)
assert.Equal(t, openStartCount+2, count, "Wrong open channel deleted count.")
count, err = ss.Channel().AnalyticsDeletedTypeCount("", "P")
require.Nil(t, err, err)
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "P")
require.Nil(t, nErr, nErr)
assert.Equal(t, privateStartCount+1, count, "Wrong private channel deleted count.")
count, err = ss.Channel().AnalyticsDeletedTypeCount("", "D")
require.Nil(t, err, err)
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "D")
require.Nil(t, nErr, nErr)
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)
d1, err := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, err)
d1, nErr := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, nErr)
assert.Len(t, d1, 2)
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)
d1, err := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, err)
d1, nErr := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, nErr)
assert.Len(t, d1, 1)
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)
require.Nil(t, nErr, "channel should have been deleted")
d1, err := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, err)
d1, nErr := ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26))
assert.Nil(t, nErr)
assert.Equal(t, 0, len(d1))

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

@@ -144,8 +144,8 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) {
require.Nil(t, nErr)
// Get and check the categories for channels
categories, err := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err)
categories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, nErr)
require.Len(t, categories.Categories, 3)
assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type)
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)
// Get and check the categories for channels
categories, err := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err)
categories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, nErr)
require.Len(t, categories.Categories, 3)
assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type)
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)
// Get and check the categories for channels
categories, err := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err)
categories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, nErr)
require.Len(t, categories.Categories, 3)
assert.Equal(t, model.SidebarCategoryFavorites, categories.Categories[0].Type)
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)
// And some categories
initialCategories, err := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err)
initialCategories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, nErr)
channelsCategory := initialCategories.Categories[1]
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)
assert.Nil(t, err)
updatedCategories, nErr := ss.Channel().UpdateSidebarCategories(userId, teamId, categoriesToUpdate)
assert.Nil(t, nErr)
// The channels should still exist in the category because they would otherwise be orphaned
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)
require.Nil(t, nErr)
initialCategories, err := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, err)
initialCategories, nErr := ss.Channel().GetSidebarCategories(userId, teamId)
require.Nil(t, nErr)
channelsCategory := initialCategories.Categories[1]
require.Equal(t, []string{channel.Id}, channelsCategory.Channels)
customCategory, err := ss.Channel().CreateSidebarCategory(userId, teamId, &model.SidebarCategoryWithChannels{})
require.Nil(t, err)
customCategory, nErr := ss.Channel().CreateSidebarCategory(userId, teamId, &model.SidebarCategoryWithChannels{})
require.Nil(t, nErr)
// 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,
Channels: []string{},
@@ -1530,13 +1530,13 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
Channels: []string{channel.Id},
},
})
assert.Nil(t, err)
assert.Nil(t, nErr)
assert.Equal(t, []string{}, updatedCategories[0].Channels)
assert.Equal(t, []string{channel.Id}, updatedCategories[1].Channels)
// 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,
Channels: []string{channel.Id},
@@ -1546,7 +1546,7 @@ func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlSupplier) {
Channels: []string{},
},
})
assert.Nil(t, err)
assert.Nil(t, nErr)
assert.Equal(t, []string{channel.Id}, updatedCategories[0].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
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)
var r0 int64
@@ -26,13 +26,11 @@ func (_m *ChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType str
r0 = ret.Get(0).(int64)
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(teamId, channelType)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 *model.ChannelList
@@ -72,20 +70,18 @@ func (_m *ChannelStore) AutocompleteInTeam(teamId string, term string, includeDe
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, bool) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, bool) error); ok {
r1 = rf(teamId, term, includeDeleted)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 *model.ChannelList
@@ -97,29 +93,25 @@ func (_m *ChannelStore) AutocompleteInTeamForSearch(teamId string, userId string
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, string, bool) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, string, bool) error); ok {
r1 = rf(teamId, userId, term, includeDeleted)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// ClearAllCustomRoleAssignments provides a mock function with given fields:
func (_m *ChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
func (_m *ChannelStore) ClearAllCustomRoleAssignments() error {
ret := _m.Called()
var r0 *model.AppError
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
var r0 error
if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
r0 = ret.Error(0)
}
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
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)
var r0 *model.SidebarCategoryWithChannels
@@ -215,13 +207,11 @@ func (_m *ChannelStore) CreateSidebarCategory(userId string, teamId string, newC
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, *model.SidebarCategoryWithChannels) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, *model.SidebarCategoryWithChannels) error); ok {
r1 = rf(userId, teamId, newCategory)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
func (_m *ChannelStore) DeleteSidebarCategory(categoryId string) *model.AppError {
func (_m *ChannelStore) DeleteSidebarCategory(categoryId string) error {
ret := _m.Called(categoryId)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
var r0 error
if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(categoryId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
r0 = ret.Error(0)
}
return r0
@@ -408,7 +396,7 @@ func (_m *ChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpts) (int64
}
// 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)
var r0 []*model.ChannelForExport
@@ -420,20 +408,18 @@ func (_m *ChannelStore) GetAllChannelsForExportAfter(limit int, afterId string)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(int, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(int, string) error); ok {
r1 = rf(limit, afterId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 []*model.DirectChannelForExport
@@ -445,13 +431,11 @@ func (_m *ChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId st
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(int, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(int, string) error); ok {
r1 = rf(limit, afterId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 []*model.ChannelMemberForExport
@@ -562,13 +546,11 @@ func (_m *ChannelStore) GetChannelMembersForExport(userId string, teamId string)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, teamId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 *model.ChannelUnread
@@ -610,13 +592,11 @@ func (_m *ChannelStore) GetChannelUnread(channelId string, userId string) (*mode
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(channelId, userId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 []*model.Channel
@@ -658,13 +638,11 @@ func (_m *ChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(int64, int64, int) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(int64, int64, int) error); ok {
r1 = rf(startTime, endTime, limit)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 model.ChannelList
@@ -706,13 +684,11 @@ func (_m *ChannelStore) GetChannelsByScheme(schemeId string, offset int, limit i
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, int, int) error); ok {
r1 = rf(schemeId, offset, limit)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 *model.ChannelMembers
@@ -971,13 +947,11 @@ func (_m *ChannelStore) GetMembersByIds(channelId string, userIds []string) (*mo
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, []string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, []string) error); ok {
r1 = rf(channelId, userIds)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 *model.OrderedSidebarCategories
@@ -1178,20 +1152,18 @@ func (_m *ChannelStore) GetSidebarCategories(userId string, teamId string) (*mod
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, teamId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 *model.SidebarCategoryWithChannels
@@ -1203,20 +1175,18 @@ func (_m *ChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCat
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(categoryId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 []string
@@ -1228,13 +1198,11 @@ func (_m *ChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, teamId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
@@ -1264,7 +1232,7 @@ func (_m *ChannelStore) GetTeamChannels(teamId string) (*model.ChannelList, erro
}
// GroupSyncedChannelCount provides a mock function with given fields:
func (_m *ChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) {
func (_m *ChannelStore) GroupSyncedChannelCount() (int64, error) {
ret := _m.Called()
var r0 int64
@@ -1274,13 +1242,11 @@ func (_m *ChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) {
r0 = ret.Get(0).(int64)
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
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)
var r0 map[string]string
@@ -1362,13 +1328,11 @@ func (_m *ChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId s
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(fromChannelId, fromUserId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
@@ -1445,16 +1409,14 @@ func (_m *ChannelStore) PermanentDeleteMembersByUser(userId string) error {
}
// 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)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
var r0 error
if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(channelId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
r0 = ret.Error(0)
}
return r0
@@ -1489,16 +1451,14 @@ func (_m *ChannelStore) RemoveMembers(channelId string, userIds []string) error
}
// ResetAllChannelSchemes provides a mock function with given fields:
func (_m *ChannelStore) ResetAllChannelSchemes() *model.AppError {
func (_m *ChannelStore) ResetAllChannelSchemes() error {
ret := _m.Called()
var r0 *model.AppError
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
var r0 error
if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
r0 = ret.Error(0)
}
return r0
@@ -1611,7 +1571,7 @@ func (_m *ChannelStore) SaveMultipleMembers(members []*model.ChannelMember) ([]*
}
// SearchAllChannels provides a mock function with given fields: term, opts
func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) {
func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
ret := _m.Called(term, opts)
var r0 *model.ChannelListWithTeamData
@@ -1630,20 +1590,18 @@ func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchO
r1 = ret.Get(1).(int64)
}
var r2 *model.AppError
if rf, ok := ret.Get(2).(func(string, store.ChannelSearchOpts) *model.AppError); ok {
var r2 error
if rf, ok := ret.Get(2).(func(string, store.ChannelSearchOpts) error); ok {
r2 = rf(term, opts)
} else {
if ret.Get(2) != nil {
r2 = ret.Get(2).(*model.AppError)
}
r2 = ret.Error(2)
}
return r0, r1, r2
}
// 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)
var r0 *model.ChannelList
@@ -1655,20 +1613,18 @@ func (_m *ChannelStore) SearchArchivedInTeam(teamId string, term string, userId
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
r1 = rf(teamId, term, userId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 *model.ChannelList
@@ -1680,20 +1636,18 @@ func (_m *ChannelStore) SearchForUserInTeam(userId string, teamId string, term s
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, string, bool) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, string, bool) error); ok {
r1 = rf(userId, teamId, term, includeDeleted)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 *model.ChannelList
@@ -1705,20 +1659,18 @@ func (_m *ChannelStore) SearchGroupChannels(userId string, term string) (*model.
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, term)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 *model.ChannelList
@@ -1730,20 +1682,18 @@ func (_m *ChannelStore) SearchInTeam(teamId string, term string, includeDeleted
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, bool) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, bool) error); ok {
r1 = rf(teamId, term, includeDeleted)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 *model.ChannelList
@@ -1755,13 +1705,11 @@ func (_m *ChannelStore) SearchMore(userId string, teamId string, term string) (*
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
r1 = rf(userId, teamId, term)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
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
func (_m *ChannelStore) UpdateMembersRole(channelID string, userIDs []string) *model.AppError {
func (_m *ChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
ret := _m.Called(channelID, userIDs)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string, []string) *model.AppError); ok {
var r0 error
if rf, ok := ret.Get(0).(func(string, []string) error); ok {
r0 = rf(channelID, userIDs)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
r0 = ret.Error(0)
}
return r0
@@ -1913,7 +1859,7 @@ func (_m *ChannelStore) UpdateMultipleMembers(members []*model.ChannelMember) ([
}
// 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)
var r0 []*model.SidebarCategoryWithChannels
@@ -1925,29 +1871,25 @@ func (_m *ChannelStore) UpdateSidebarCategories(userId string, teamId string, ca
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, []*model.SidebarCategoryWithChannels) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, []*model.SidebarCategoryWithChannels) error); ok {
r1 = rf(userId, teamId, categories)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// 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)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string, string, []string) *model.AppError); ok {
var r0 error
if rf, ok := ret.Get(0).(func(string, string, []string) error); ok {
r0 = rf(userId, teamId, categoryOrder)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
r0 = ret.Error(0)
}
return r0
@@ -1982,7 +1924,7 @@ func (_m *ChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Pr
}
// 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)
var r0 bool
@@ -1992,13 +1934,11 @@ func (_m *ChannelStore) UserBelongsToChannels(userId string, channelIds []string
r0 = ret.Get(0).(bool)
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, []string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, []string) error); ok {
r1 = rf(userId, channelIds)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1

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

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