MM-32421: Extend channel sidebar category APIs for Plugins (#17821)
* extend plugin api with sidebar functionalities * include generated mocks for tests * bump up version requirements for plugin api * update tag to 'ChannelSidebar' Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a9b3e423e6
Коммит
b4f6cb8cb7
@@ -439,6 +439,18 @@ func (api *PluginAPI) SearchChannels(teamID string, term string) ([]*model.Chann
|
||||
return *channels, err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
return api.app.CreateSidebarCategory(userID, teamID, newCategory)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
return api.app.GetSidebarCategories(userID, teamID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateChannelSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
return api.app.UpdateSidebarCategories(userID, teamID, categories)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchUsers(search *model.UserSearch) ([]*model.User, *model.AppError) {
|
||||
pluginSearchUsersOptions := &model.UserSearchOptions{
|
||||
IsAdmin: true,
|
||||
|
||||
@@ -450,6 +450,24 @@ type API interface {
|
||||
// Minimum server version: 5.6
|
||||
SearchChannels(teamID string, term string) ([]*model.Channel, *model.AppError)
|
||||
|
||||
// CreateChannelSidebarCategory creates a new sidebar category for a set of channels.
|
||||
//
|
||||
// @tag ChannelSidebar
|
||||
// Minimum server version: 5.37
|
||||
CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
|
||||
// GetChannelSidebarCategories returns sidebar categories.
|
||||
//
|
||||
// @tag ChannelSidebar
|
||||
// Minimum server version: 5.37
|
||||
GetChannelSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError)
|
||||
|
||||
// UpdateChannelSidebarCategories updates the channel sidebar categories.
|
||||
//
|
||||
// @tag ChannelSidebar
|
||||
// Minimum server version: 5.37
|
||||
UpdateChannelSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
|
||||
// SearchUsers returns a list of users based on some search criteria.
|
||||
//
|
||||
// @tag User
|
||||
|
||||
@@ -497,6 +497,27 @@ func (api *apiTimerLayer) SearchChannels(teamID string, term string) ([]*model.C
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.CreateChannelSidebarCategory(userID, teamID, newCategory)
|
||||
api.recordTime(startTime, "CreateChannelSidebarCategory", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetChannelSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.GetChannelSidebarCategories(userID, teamID)
|
||||
api.recordTime(startTime, "GetChannelSidebarCategories", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) UpdateChannelSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.UpdateChannelSidebarCategories(userID, teamID, categories)
|
||||
api.recordTime(startTime, "UpdateChannelSidebarCategories", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) SearchUsers(search *model.UserSearch) ([]*model.User, *model.AppError) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.SearchUsers(search)
|
||||
|
||||
@@ -2491,6 +2491,98 @@ func (s *apiRPCServer) SearchChannels(args *Z_SearchChannelsArgs, returns *Z_Sea
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_CreateChannelSidebarCategoryArgs struct {
|
||||
A string
|
||||
B string
|
||||
C *model.SidebarCategoryWithChannels
|
||||
}
|
||||
|
||||
type Z_CreateChannelSidebarCategoryReturns struct {
|
||||
A *model.SidebarCategoryWithChannels
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
_args := &Z_CreateChannelSidebarCategoryArgs{userID, teamID, newCategory}
|
||||
_returns := &Z_CreateChannelSidebarCategoryReturns{}
|
||||
if err := g.client.Call("Plugin.CreateChannelSidebarCategory", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to CreateChannelSidebarCategory API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) CreateChannelSidebarCategory(args *Z_CreateChannelSidebarCategoryArgs, returns *Z_CreateChannelSidebarCategoryReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.CreateChannelSidebarCategory(args.A, args.B, args.C)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API CreateChannelSidebarCategory called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetChannelSidebarCategoriesArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_GetChannelSidebarCategoriesReturns struct {
|
||||
A *model.OrderedSidebarCategories
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetChannelSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
_args := &Z_GetChannelSidebarCategoriesArgs{userID, teamID}
|
||||
_returns := &Z_GetChannelSidebarCategoriesReturns{}
|
||||
if err := g.client.Call("Plugin.GetChannelSidebarCategories", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetChannelSidebarCategories API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetChannelSidebarCategories(args *Z_GetChannelSidebarCategoriesArgs, returns *Z_GetChannelSidebarCategoriesReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetChannelSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetChannelSidebarCategories(args.A, args.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetChannelSidebarCategories called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpdateChannelSidebarCategoriesArgs struct {
|
||||
A string
|
||||
B string
|
||||
C []*model.SidebarCategoryWithChannels
|
||||
}
|
||||
|
||||
type Z_UpdateChannelSidebarCategoriesReturns struct {
|
||||
A []*model.SidebarCategoryWithChannels
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) UpdateChannelSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
_args := &Z_UpdateChannelSidebarCategoriesArgs{userID, teamID, categories}
|
||||
_returns := &Z_UpdateChannelSidebarCategoriesReturns{}
|
||||
if err := g.client.Call("Plugin.UpdateChannelSidebarCategories", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to UpdateChannelSidebarCategories API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) UpdateChannelSidebarCategories(args *Z_UpdateChannelSidebarCategoriesArgs, returns *Z_UpdateChannelSidebarCategoriesReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
UpdateChannelSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.UpdateChannelSidebarCategories(args.A, args.B, args.C)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API UpdateChannelSidebarCategories called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_SearchUsersArgs struct {
|
||||
A *model.UserSearch
|
||||
}
|
||||
|
||||
@@ -168,6 +168,31 @@ func (_m *API) CreateChannel(channel *model.Channel) (*model.Channel, *model.App
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateChannelSidebarCategory provides a mock function with given fields: userID, teamID, newCategory
|
||||
func (_m *API) CreateChannelSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
ret := _m.Called(userID, teamID, newCategory)
|
||||
|
||||
var r0 *model.SidebarCategoryWithChannels
|
||||
if rf, ok := ret.Get(0).(func(string, string, *model.SidebarCategoryWithChannels) *model.SidebarCategoryWithChannels); ok {
|
||||
r0 = rf(userID, teamID, newCategory)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.SidebarCategoryWithChannels)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, *model.SidebarCategoryWithChannels) *model.AppError); ok {
|
||||
r1 = rf(userID, teamID, newCategory)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateCommand provides a mock function with given fields: cmd
|
||||
func (_m *API) CreateCommand(cmd *model.Command) (*model.Command, error) {
|
||||
ret := _m.Called(cmd)
|
||||
@@ -814,6 +839,31 @@ func (_m *API) GetChannelMembersForUser(teamID string, userID string, page int,
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetChannelSidebarCategories provides a mock function with given fields: userID, teamID
|
||||
func (_m *API) GetChannelSidebarCategories(userID string, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||
ret := _m.Called(userID, teamID)
|
||||
|
||||
var r0 *model.OrderedSidebarCategories
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
|
||||
r1 = rf(userID, teamID)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetChannelStats provides a mock function with given fields: channelId
|
||||
func (_m *API) GetChannelStats(channelId string) (*model.ChannelStats, *model.AppError) {
|
||||
ret := _m.Called(channelId)
|
||||
@@ -3196,6 +3246,31 @@ func (_m *API) UpdateChannelMemberRoles(channelId string, userID string, newRole
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdateChannelSidebarCategories provides a mock function with given fields: userID, teamID, categories
|
||||
func (_m *API) UpdateChannelSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||
ret := _m.Called(userID, teamID, categories)
|
||||
|
||||
var r0 []*model.SidebarCategoryWithChannels
|
||||
if rf, ok := ret.Get(0).(func(string, string, []*model.SidebarCategoryWithChannels) []*model.SidebarCategoryWithChannels); ok {
|
||||
r0 = rf(userID, teamID, categories)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.SidebarCategoryWithChannels)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, []*model.SidebarCategoryWithChannels) *model.AppError); ok {
|
||||
r1 = rf(userID, teamID, categories)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdateCommand provides a mock function with given fields: commandID, updatedCmd
|
||||
func (_m *API) UpdateCommand(commandID string, updatedCmd *model.Command) (*model.Command, error) {
|
||||
ret := _m.Called(commandID, updatedCmd)
|
||||
|
||||
Ссылка в новой задаче
Block a user