Adding terms_accepted and receive_emails_accepted params to request trial (#14937)

Этот коммит содержится в:
Jesús Espino
2020-07-03 12:17:34 +02:00
коммит произвёл GitHub
родитель 3e9ec51890
Коммит a4fc0fcfb7
3 изменённых файлов: 33 добавлений и 19 удалений

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

@@ -153,22 +153,28 @@ func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
}
if *c.App.Config().ExperimentalSettings.RestrictSystemAdmin {
c.Err = model.NewAppError("removeLicense", "api.restricted_system_admin", nil, "", http.StatusForbidden)
c.Err = model.NewAppError("requestTrialLicense", "api.restricted_system_admin", nil, "", http.StatusForbidden)
return
}
var usersNumber struct {
Users int `json:"users"`
var trialRequest struct {
Users int `json:"users"`
TermsAccepted bool `json:"terms_accepted"`
ReceiveEmailsAccepted bool `json:"receive_emails_accepted"`
}
b, readErr := ioutil.ReadAll(r.Body)
if readErr != nil {
c.Err = model.NewAppError("removeLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
c.Err = model.NewAppError("requestTrialLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
return
}
json.Unmarshal(b, &usersNumber)
if usersNumber.Users == 0 {
c.Err = model.NewAppError("removeLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
json.Unmarshal(b, &trialRequest)
if !trialRequest.TermsAccepted {
c.Err = model.NewAppError("requestTrialLicense", "api.license.request-trial.bad-request.terms-not-accepted", nil, "", http.StatusBadRequest)
return
}
if trialRequest.Users == 0 {
c.Err = model.NewAppError("requestTrialLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
return
}
@@ -179,12 +185,14 @@ func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
}
trialLicenseRequest := &model.TrialLicenseRequest{
ServerID: c.App.DiagnosticId(),
Name: currentUser.GetDisplayName(model.SHOW_FULLNAME),
Email: currentUser.Email,
SiteName: *c.App.Config().TeamSettings.SiteName,
SiteURL: *c.App.Config().ServiceSettings.SiteURL,
Users: usersNumber.Users,
ServerID: c.App.DiagnosticId(),
Name: currentUser.GetDisplayName(model.SHOW_FULLNAME),
Email: currentUser.Email,
SiteName: *c.App.Config().TeamSettings.SiteName,
SiteURL: *c.App.Config().ServiceSettings.SiteURL,
Users: trialRequest.Users,
TermsAccepted: trialRequest.TermsAccepted,
ReceiveEmailsAccepted: trialRequest.ReceiveEmailsAccepted,
}
if trialLicenseRequest.SiteURL == "" {

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

@@ -1500,6 +1500,10 @@
"id": "api.license.request-trial.bad-request",
"translation": "The number of users requested is not correct."
},
{
"id": "api.license.request-trial.bad-request.terms-not-accepted",
"translation": "You must accept the Mattermost Software Evaluation Agreement and Privacy Policy to request a license."
},
{
"id": "api.license.request_trial_license.app_error",
"translation": "Unable to get a trial license, please try again or contact with support@mattermost.com."

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

@@ -41,12 +41,14 @@ type Customer struct {
}
type TrialLicenseRequest struct {
ServerID string `json:"server_id"`
Email string `json:"email"`
Name string `json:"name"`
SiteURL string `json:"site_url"`
SiteName string `json:"site_name"`
Users int `json:"users"`
ServerID string `json:"server_id"`
Email string `json:"email"`
Name string `json:"name"`
SiteURL string `json:"site_url"`
SiteName string `json:"site_name"`
Users int `json:"users"`
TermsAccepted bool `json:"terms_accepted"`
ReceiveEmailsAccepted bool `json:"receive_emails_accepted"`
}
func (tlr *TrialLicenseRequest) ToJson() string {