MM-47228 - restrict guest invitation flow if subscription plan does n… (#21195)
* MM-47228 - restrict guest invitation flow if subscription plan does not support it * fix i18n texts and add unit test * test the scenario where guest invites are blocked by subscription * cover the success scenarios for cloud free trial and paid subscription * fix go vet * use the cloud prefix for the sku * fix unit tests * check the licence value to determine if the guest accounts are enabled * remove unnecessary changes for getting the subscription information * restrict user demotion if guestAccounts is not available in license Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6e9b808efd
Коммит
9a804a96fe
11
api4/team.go
11
api4/team.go
@@ -1462,12 +1462,12 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
graceful := r.URL.Query().Get("graceful") != ""
|
||||
if c.App.Channels().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invate_guests_to_channels.license.error", nil, "", http.StatusNotImplemented)
|
||||
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invite_guests_to_channels.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
if !*c.App.Config().GuestAccountsSettings.Enable {
|
||||
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invate_guests_to_channels.disabled.error", nil, "", http.StatusNotImplemented)
|
||||
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invite_guests_to_channels.disabled.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1485,6 +1485,13 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
guestEnabled := c.App.Channels().License() != nil && *c.App.Channels().License().Features.GuestAccounts
|
||||
|
||||
if !guestEnabled {
|
||||
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invite_guests_to_channels.disabled.error", nil, "", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
var guestsInvite model.GuestsInvite
|
||||
if err := json.NewDecoder(r.Body).Decode(&guestsInvite); err != nil {
|
||||
c.Err = model.NewAppError("Api4.inviteGuestsToChannels", "api.team.invite_guests_to_channels.invalid_body.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
|
||||
Ссылка в новой задаче
Block a user