Fix panic (#17055)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8ede4abf4d
Коммит
8612f3a4d1
@@ -1283,6 +1283,11 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
guestsInvite := model.GuestsInviteFromJson(r.Body)
|
||||
if guestsInvite == nil {
|
||||
c.Err = model.NewAppError("Api4.inviteGuestsToChannels", "api.team.invite_guests_to_channels.invalid_body.app_error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
for i, email := range guestsInvite.Emails {
|
||||
guestsInvite.Emails[i] = strings.ToLower(email)
|
||||
}
|
||||
|
||||
@@ -2924,6 +2924,13 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
require.True(t, okMsg, "should return true")
|
||||
|
||||
t.Run("invalid data in request body", func(t *testing.T) {
|
||||
res, err := th.SystemAdminClient.DoApiPost(th.SystemAdminClient.GetTeamRoute(th.BasicTeam.Id)+"/invite-guests/email", "bad data")
|
||||
require.Error(t, err)
|
||||
require.Equal(t, "api.team.invite_guests_to_channels.invalid_body.app_error", err.Id)
|
||||
require.Equal(t, http.StatusBadRequest, res.StatusCode)
|
||||
})
|
||||
|
||||
nameFormat := *th.App.Config().TeamSettings.TeammateNameDisplay
|
||||
expectedSubject := i18n.T("api.templates.invite_guest_subject",
|
||||
map[string]interface{}{"SenderName": th.SystemAdminUser.GetDisplayName(nameFormat),
|
||||
|
||||
@@ -2518,6 +2518,10 @@
|
||||
"id": "api.team.invite_guests.channel_in_invalid_team.app_error",
|
||||
"translation": "The channels of the invite must be part of the team of the invite."
|
||||
},
|
||||
{
|
||||
"id": "api.team.invite_guests_to_channels.invalid_body.app_error",
|
||||
"translation": "Invalid or missing request body."
|
||||
},
|
||||
{
|
||||
"id": "api.team.invite_members.disabled.app_error",
|
||||
"translation": "Email invitations are disabled."
|
||||
|
||||
Ссылка в новой задаче
Block a user