Refactor Get/Create Direct Channel into one function (#9867)
* refactor GetDirectChannel and CreateDirectChannel in one function * remove CreateDirectChannel plugin api and update GetDirectChannel and GetGroupChannel plugin api * update tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
09eae76c00
Коммит
1bcf08aa4b
@@ -52,11 +52,6 @@ type API interface {
|
||||
// CreateUser creates a user.
|
||||
CreateUser(user *model.User) (*model.User, *model.AppError)
|
||||
|
||||
// CreateDirectChannel creates a Direct channel.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError)
|
||||
|
||||
// DeleteUser deletes a user.
|
||||
DeleteUser(userId string) *model.AppError
|
||||
|
||||
@@ -196,9 +191,11 @@ type API interface {
|
||||
GetChannelStats(channelId string) (*model.ChannelStats, *model.AppError)
|
||||
|
||||
// GetDirectChannel gets a direct message channel.
|
||||
// If the channel does not exist it will create it.
|
||||
GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError)
|
||||
|
||||
// GetGroupChannel gets a group message channel.
|
||||
// If the channel does not exist it will create it.
|
||||
GetGroupChannel(userIds []string) (*model.Channel, *model.AppError)
|
||||
|
||||
// UpdateChannel updates a channel.
|
||||
|
||||
@@ -767,36 +767,6 @@ func (s *apiRPCServer) CreateUser(args *Z_CreateUserArgs, returns *Z_CreateUserR
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_CreateDirectChannelArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_CreateDirectChannelReturns struct {
|
||||
A *model.Channel
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
|
||||
_args := &Z_CreateDirectChannelArgs{userId1, userId2}
|
||||
_returns := &Z_CreateDirectChannelReturns{}
|
||||
if err := g.client.Call("Plugin.CreateDirectChannel", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to CreateDirectChannel API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) CreateDirectChannel(args *Z_CreateDirectChannelArgs, returns *Z_CreateDirectChannelReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.CreateDirectChannel(args.A, args.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API CreateDirectChannel called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_DeleteUserArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
@@ -112,31 +112,6 @@ func (_m *API) CreateChannel(channel *model.Channel) (*model.Channel, *model.App
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateDirectChannel provides a mock function with given fields: userId1, userId2
|
||||
func (_m *API) CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
|
||||
ret := _m.Called(userId1, userId2)
|
||||
|
||||
var r0 *model.Channel
|
||||
if rf, ok := ret.Get(0).(func(string, string) *model.Channel); ok {
|
||||
r0 = rf(userId1, userId2)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.Channel)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
|
||||
r1 = rf(userId1, userId2)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreatePost provides a mock function with given fields: post
|
||||
func (_m *API) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
|
||||
ret := _m.Called(post)
|
||||
@@ -606,20 +581,6 @@ func (_m *API) GetConfig() *model.Config {
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetPluginConfig provides a mock function with given fields:
|
||||
func (_m *API) GetPluginConfig() map[string]interface{} {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 map[string]interface{}
|
||||
if rf, ok := ret.Get(0).(func() map[string]interface{}); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(map[string]interface{})
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetDirectChannel provides a mock function with given fields: userId1, userId2
|
||||
func (_m *API) GetDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
|
||||
ret := _m.Called(userId1, userId2)
|
||||
@@ -850,6 +811,22 @@ func (_m *API) GetLDAPUserAttributes(userId string, attributes []string) (map[st
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPluginConfig provides a mock function with given fields:
|
||||
func (_m *API) GetPluginConfig() map[string]interface{} {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 map[string]interface{}
|
||||
if rf, ok := ret.Get(0).(func() map[string]interface{}); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(map[string]interface{})
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetPluginStatus provides a mock function with given fields: id
|
||||
func (_m *API) GetPluginStatus(id string) (*model.PluginStatus, *model.AppError) {
|
||||
ret := _m.Called(id)
|
||||
@@ -1890,13 +1867,13 @@ func (_m *API) SaveConfig(config *model.Config) *model.AppError {
|
||||
return r0
|
||||
}
|
||||
|
||||
// SavePluginConfig provides a mock function with given fields: pluginConfig
|
||||
func (_m *API) SavePluginConfig(pluginConfig map[string]interface{}) *model.AppError {
|
||||
ret := _m.Called(pluginConfig)
|
||||
// SavePluginConfig provides a mock function with given fields: config
|
||||
func (_m *API) SavePluginConfig(config map[string]interface{}) *model.AppError {
|
||||
ret := _m.Called(config)
|
||||
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(map[string]interface{}) *model.AppError); ok {
|
||||
r0 = rf(pluginConfig)
|
||||
r0 = rf(config)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
|
||||
Ссылка в новой задаче
Block a user