[MM-20029] Fix incorrect bot message (#13392)

* Fix incorect bot message

* Edit whitespace
Этот коммит содержится в:
Shota Gvinepadze
2020-01-03 18:31:13 +04:00
коммит произвёл GitHub
родитель c3c250cd91
Коммит 69ab1ea1e4
2 изменённых файлов: 45 добавлений и 2 удалений

Просмотреть файл

@@ -143,7 +143,8 @@ func (me *InviteProvider) DoCommand(a *App, args *model.CommandArgs, message str
var text string
if err.Id == "api.channel.add_members.user_denied" {
text = args.T("api.command_invite.group_constrained_user_denied")
} else if err.Id == "store.sql_team.get_member.missing.app_error" {
} else if err.Id == "store.sql_team.get_member.missing.app_error" ||
err.Id == "api.channel.add_user.to.channel.failed.deleted.app_error" {
text = args.T("api.command_invite.user_not_in_team.app_error", map[string]interface{}{
"Username": userProfile.Username,
})

Просмотреть файл

@@ -27,6 +27,34 @@ func TestInviteProvider(t *testing.T) {
deactivatedUser := th.CreateUser()
th.App.UpdateActive(deactivatedUser, false)
var err *model.AppError
_, err = th.App.CreateBot(&model.Bot{
Username: "bot1",
OwnerId: basicUser3.Id,
Description: "a test bot",
})
require.Nil(t, err)
bot2, err := th.App.CreateBot(&model.Bot{
Username: "bot2",
OwnerId: basicUser3.Id,
Description: "a test bot",
})
require.Nil(t, err)
_, err = th.App.AddUserToTeam(th.BasicTeam.Id, bot2.UserId, basicUser3.Id)
require.Nil(t, err)
bot3, err := th.App.CreateBot(&model.Bot{
Username: "bot3",
OwnerId: basicUser3.Id,
Description: "a test bot",
})
require.Nil(t, err)
_, err = th.App.AddUserToTeam(th.BasicTeam.Id, bot3.UserId, basicUser3.Id)
require.Nil(t, err)
err = th.App.RemoveUserFromTeam(th.BasicTeam.Id, bot3.UserId, basicUser3.Id)
require.Nil(t, err)
InviteP := InviteProvider{}
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
@@ -44,7 +72,6 @@ func TestInviteProvider(t *testing.T) {
deactivatedUserPublicChannel := "@" + deactivatedUser.Username + " ~" + channel.Name
groupChannel := th.createChannel(th.BasicTeam, model.CHANNEL_PRIVATE)
var err *model.AppError
_, err = th.App.AddChannelMember(th.BasicUser.Id, groupChannel, "", "")
require.Nil(t, err)
groupChannel.GroupConstrained = model.NewBool(true)
@@ -122,6 +149,21 @@ func TestInviteProvider(t *testing.T) {
expected: "api.command_invite.missing_user.app_error",
msg: deactivatedUserPublicChannel,
},
{
desc: "try to add bot to a public channel",
expected: "api.command_invite.user_not_in_team.app_error",
msg: "@bot1",
},
{
desc: "add bot to a public channel",
expected: "",
msg: "@bot2",
},
{
desc: "try to add bot removed from a team to a public channel",
expected: "api.command_invite.user_not_in_team.app_error",
msg: "@bot3",
},
}
for _, test := range tests {