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
@@ -297,7 +297,7 @@ func (api *PluginAPI) GetChannelStats(channelId string) (*model.ChannelStats, *m
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError) {
|
||||
return api.app.GetDirectChannel(userId1, userId2)
|
||||
return api.app.GetOrCreateDirectChannel(userId1, userId2)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
|
||||
@@ -523,25 +523,6 @@ func (api *PluginAPI) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
|
||||
_, err := api.app.GetUser(userId1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = api.app.GetUser(userId2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dm, err := api.app.CreateDirectChannel(userId1, userId2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dm, nil
|
||||
}
|
||||
|
||||
// Plugin Section
|
||||
|
||||
func (api *PluginAPI) GetPlugins() ([]*model.Manifest, *model.AppError) {
|
||||
|
||||
Ссылка в новой задаче
Block a user