MM-18816 Adding ability to add users as another user to the plugin API. (#12562)
* Adding ability to add users as anouther user to the plugin API. * Documentation feedback.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d7ee3553fa
Коммит
e62471dff6
@@ -406,6 +406,17 @@ func (api *PluginAPI) AddChannelMember(channelId, userId string) (*model.Channel
|
||||
return api.app.AddChannelMember(userId, channel, userRequestorId, postRootId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) AddUserToChannel(channelId, userId, asUserId string) (*model.ChannelMember, *model.AppError) {
|
||||
postRootId := ""
|
||||
|
||||
channel, err := api.GetChannel(channelId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api.app.AddChannelMember(userId, channel, asUserId, postRootId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
return api.app.GetChannelMember(channelId, userId)
|
||||
}
|
||||
|
||||
@@ -1439,3 +1439,15 @@ func TestPluginAPIGetUnsanitizedConfig(t *testing.T) {
|
||||
assert.NotEqual(t, config.SqlSettings.DataSourceSearchReplicas[i], model.FAKE_SETTING)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginAddUserToChannel(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
member, err := api.AddUserToChannel(th.BasicChannel.Id, th.BasicUser.Id, th.BasicUser2.Id)
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, member)
|
||||
require.Equal(t, th.BasicChannel.Id, member.ChannelId)
|
||||
require.Equal(t, th.BasicUser.Id, member.UserId)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user