From b208bbc43e174a3b2e4ad7a4e3dfb9195f7cbb9d Mon Sep 17 00:00:00 2001 From: Shota Gvinepadze Date: Thu, 31 Oct 2019 12:49:50 +0400 Subject: [PATCH] [MM-18830] Unhelpful error message when adding bot to a channel before adding to team (#12844) * Fix error message * Rename User to Username * Add '@' to the username --- app/command_invite.go | 4 ++++ app/command_invite_test.go | 2 +- i18n/en.json | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/command_invite.go b/app/command_invite.go index da747a9b95..7aa6bf91d8 100644 --- a/app/command_invite.go +++ b/app/command_invite.go @@ -143,6 +143,10 @@ 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" { + text = args.T("api.command_invite.user_not_in_team.app_error", map[string]interface{}{ + "Username": userProfile.Username, + }) } else { text = args.T("api.command_invite.fail.app_error") } diff --git a/app/command_invite_test.go b/app/command_invite_test.go index 71eb582154..354b373b77 100644 --- a/app/command_invite_test.go +++ b/app/command_invite_test.go @@ -94,7 +94,7 @@ func TestInviteProvider(t *testing.T) { }, { desc: "try to add a user which is not part of the team", - expected: "api.command_invite.fail.app_error", + expected: "api.command_invite.user_not_in_team.app_error", msg: basicUser4.Username, }, { diff --git a/i18n/en.json b/i18n/en.json index 4ecfb9dfe6..784942e5b1 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -798,6 +798,10 @@ "id": "api.command_invite.user_already_in_channel.app_error", "translation": "{{.User}} is already in the channel." }, + { + "id": "api.command_invite.user_not_in_team.app_error", + "translation": "@{{.Username}} is not a member of the team." + }, { "id": "api.command_invite_people.permission.app_error", "translation": "You don't have permission to invite new users to this server."