MM-63728: simplify category store with graphql gone (#30848)
* move category permissions to api In https://github.com/mattermost/mattermost/pull/21038, we changed the behaviour of the channel category store to filter out deleted teams and teams for which the user was not a member. This was necessary in part due to querying multiple teams via GraphQL. With GraphQL no longer supported, let's move the permissions to the API instead and remove the `JOIN` to filter out teams in the store. Note that we /don't/ prevent access to deleted teams. For better or worse, deleted teams remain largely accessible via other API endpoints anyway. * remove ExcludeTeam / GraphQL support As part of https://github.com/mattermost/mattermost/pull/20353, we added `ExcludeTeam` and the associated logic to support a GraphQL API. With GraphQL no longer supported, let's simplify this logic and remove the filtering and associated complexity. * Fix shadow variable declaration in channel_store_categories.go Fixed golangci-lint error by reusing existing err variable rather than shadowing it. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix build issue * Remove SidebarCategorySearchOpts and simplify API to use teamID string Per code review feedback, this change removes the SidebarCategorySearchOpts struct entirely since the Type field was never used in the store implementation. All methods now accept a simple teamID string parameter instead of the struct, which simplifies the API and makes the code clearer. Changes: - Remove SidebarCategorySearchOpts struct from store.go - Update CreateInitialSidebarCategories and GetSidebarCategories signatures - Update all implementations (sqlstore, retrylayer, timerlayer, mocks) - Update all callers to pass teamID string directly - Clean up unused imports 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b69412d23f
Коммит
dcc72c4c61
@@ -342,9 +342,9 @@ func (_m *ChannelStore) CreateDirectChannel(ctx request.CTX, userID *model.User,
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateInitialSidebarCategories provides a mock function with given fields: c, userID, opts
|
||||
func (_m *ChannelStore) CreateInitialSidebarCategories(c request.CTX, userID string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
||||
ret := _m.Called(c, userID, opts)
|
||||
// CreateInitialSidebarCategories provides a mock function with given fields: c, userID, teamID
|
||||
func (_m *ChannelStore) CreateInitialSidebarCategories(c request.CTX, userID string, teamID string) (*model.OrderedSidebarCategories, error) {
|
||||
ret := _m.Called(c, userID, teamID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CreateInitialSidebarCategories")
|
||||
@@ -352,19 +352,19 @@ func (_m *ChannelStore) CreateInitialSidebarCategories(c request.CTX, userID str
|
||||
|
||||
var r0 *model.OrderedSidebarCategories
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(request.CTX, string, *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)); ok {
|
||||
return rf(c, userID, opts)
|
||||
if rf, ok := ret.Get(0).(func(request.CTX, string, string) (*model.OrderedSidebarCategories, error)); ok {
|
||||
return rf(c, userID, teamID)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(request.CTX, string, *store.SidebarCategorySearchOpts) *model.OrderedSidebarCategories); ok {
|
||||
r0 = rf(c, userID, opts)
|
||||
if rf, ok := ret.Get(0).(func(request.CTX, string, string) *model.OrderedSidebarCategories); ok {
|
||||
r0 = rf(c, userID, teamID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.OrderedSidebarCategories)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(request.CTX, string, *store.SidebarCategorySearchOpts) error); ok {
|
||||
r1 = rf(c, userID, opts)
|
||||
if rf, ok := ret.Get(1).(func(request.CTX, string, string) error); ok {
|
||||
r1 = rf(c, userID, teamID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -1968,9 +1968,9 @@ func (_m *ChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limi
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetSidebarCategories provides a mock function with given fields: userID, opts
|
||||
func (_m *ChannelStore) GetSidebarCategories(userID string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
||||
ret := _m.Called(userID, opts)
|
||||
// GetSidebarCategories provides a mock function with given fields: userID, teamID
|
||||
func (_m *ChannelStore) GetSidebarCategories(userID string, teamID string) (*model.OrderedSidebarCategories, error) {
|
||||
ret := _m.Called(userID, teamID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetSidebarCategories")
|
||||
@@ -1978,19 +1978,19 @@ func (_m *ChannelStore) GetSidebarCategories(userID string, opts *store.SidebarC
|
||||
|
||||
var r0 *model.OrderedSidebarCategories
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)); ok {
|
||||
return rf(userID, opts)
|
||||
if rf, ok := ret.Get(0).(func(string, string) (*model.OrderedSidebarCategories, error)); ok {
|
||||
return rf(userID, teamID)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, *store.SidebarCategorySearchOpts) *model.OrderedSidebarCategories); ok {
|
||||
r0 = rf(userID, opts)
|
||||
if rf, ok := ret.Get(0).(func(string, string) *model.OrderedSidebarCategories); ok {
|
||||
r0 = rf(userID, teamID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.OrderedSidebarCategories)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, *store.SidebarCategorySearchOpts) error); ok {
|
||||
r1 = rf(userID, opts)
|
||||
if rf, ok := ret.Get(1).(func(string, string) error); ok {
|
||||
r1 = rf(userID, teamID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user