* Revert "MM-51482_Create Apps Category and link to bots DM (#22918)" This reverts commit1051925eec. * Revert "MM-51711_Feature flag: APPS sidebar category (#22766)" This reverts commit9156205178.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
16ad573979
Коммит
6a5bb53963
@@ -25,17 +25,13 @@ func (a *App) createInitialSidebarCategories(userID string, opts *store.SidebarC
|
||||
|
||||
func (a *App) GetSidebarCategoriesForTeamForUser(c request.CTX, userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
var appErr *model.AppError
|
||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
||||
options := &store.SidebarCategorySearchOpts{
|
||||
TeamID: teamID,
|
||||
ExcludeTeam: false,
|
||||
AppsCategoryEnabled: appsCategoryEnabled,
|
||||
}
|
||||
categories, err := a.Srv().Store().Channel().GetSidebarCategoriesForTeamForUser(userID, teamID, options)
|
||||
if err == nil && (len(categories.Categories) == 0 || (appsCategoryEnabled && checkMissingSystemSidebarCategories(categories))) {
|
||||
// A user must always have system categories, so migration must not have happened yet, and we should run it ourselves
|
||||
categories, appErr = a.createInitialSidebarCategories(userID, options)
|
||||
|
||||
categories, err := a.Srv().Store().Channel().GetSidebarCategoriesForTeamForUser(userID, teamID)
|
||||
if err == nil && len(categories.Categories) == 0 {
|
||||
// A user must always have categories, so migration must not have happened yet, and we should run it ourselves
|
||||
categories, appErr = a.createInitialSidebarCategories(userID, &store.SidebarCategorySearchOpts{
|
||||
TeamID: teamID,
|
||||
ExcludeTeam: false,
|
||||
})
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
@@ -56,17 +52,10 @@ func (a *App) GetSidebarCategoriesForTeamForUser(c request.CTX, userID, teamID s
|
||||
|
||||
func (a *App) GetSidebarCategories(c request.CTX, userID string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
var appErr *model.AppError
|
||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
||||
options := &store.SidebarCategorySearchOpts{
|
||||
TeamID: opts.TeamID,
|
||||
ExcludeTeam: opts.ExcludeTeam,
|
||||
AppsCategoryEnabled: appsCategoryEnabled,
|
||||
}
|
||||
categories, err := a.Srv().Store().Channel().GetSidebarCategories(userID, options)
|
||||
if err == nil && (len(categories.Categories) == 0 || (appsCategoryEnabled && checkMissingSystemSidebarCategories(categories))) {
|
||||
// A user must always have system categories, so migration must not have happened yet, and we should run it ourselves
|
||||
categories, appErr = a.createInitialSidebarCategories(userID, options)
|
||||
|
||||
categories, err := a.Srv().Store().Channel().GetSidebarCategories(userID, opts)
|
||||
if err == nil && len(categories.Categories) == 0 {
|
||||
// A user must always have categories, so migration must not have happened yet, and we should run it ourselves
|
||||
categories, appErr = a.createInitialSidebarCategories(userID, opts)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
@@ -101,8 +90,7 @@ func (a *App) GetSidebarCategoryOrder(c request.CTX, userID, teamID string) ([]s
|
||||
}
|
||||
|
||||
func (a *App) GetSidebarCategory(c request.CTX, categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
||||
category, err := a.Srv().Store().Channel().GetSidebarCategory(categoryId, &store.SidebarCategorySearchOpts{AppsCategoryEnabled: appsCategoryEnabled})
|
||||
category, err := a.Srv().Store().Channel().GetSidebarCategory(categoryId)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -117,8 +105,7 @@ func (a *App) GetSidebarCategory(c request.CTX, categoryId string) (*model.Sideb
|
||||
}
|
||||
|
||||
func (a *App) CreateSidebarCategory(c request.CTX, userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
||||
category, err := a.Srv().Store().Channel().CreateSidebarCategory(userID, teamID, newCategory, &store.SidebarCategorySearchOpts{AppsCategoryEnabled: appsCategoryEnabled})
|
||||
category, err := a.Srv().Store().Channel().CreateSidebarCategory(userID, teamID, newCategory)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -155,13 +142,7 @@ func (a *App) UpdateSidebarCategoryOrder(c request.CTX, userID, teamID string, c
|
||||
}
|
||||
|
||||
func (a *App) UpdateSidebarCategories(c request.CTX, userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
||||
updatedCategories, originalCategories, err := a.Srv().Store().Channel().UpdateSidebarCategories(
|
||||
userID,
|
||||
teamID,
|
||||
categories,
|
||||
&store.SidebarCategorySearchOpts{AppsCategoryEnabled: appsCategoryEnabled},
|
||||
)
|
||||
updatedCategories, originalCategories, err := a.Srv().Store().Channel().UpdateSidebarCategories(userID, teamID, categories)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("UpdateSidebarCategories", "app.channel.sidebar_categories.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
@@ -305,17 +286,3 @@ func (a *App) DeleteSidebarCategory(c request.CTX, userID, teamID, categoryId st
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkMissingSystemSidebarCategories(categories *model.OrderedSidebarCategories) bool {
|
||||
missingSystemCategories := make(map[model.SidebarCategoryType]struct{})
|
||||
|
||||
for _, systemSidebarCategory := range model.SystemSidebarCategories {
|
||||
missingSystemCategories[systemSidebarCategory] = struct{}{}
|
||||
}
|
||||
|
||||
for _, category := range categories.Categories {
|
||||
delete(missingSystemCategories, category.Type)
|
||||
}
|
||||
|
||||
return len(missingSystemCategories) != 0
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user