Adding terms_accepted and receive_emails_accepted params to request trial (#14937)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3e9ec51890
Коммит
a4fc0fcfb7
@@ -153,22 +153,28 @@ func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *c.App.Config().ExperimentalSettings.RestrictSystemAdmin {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var usersNumber struct {
|
var trialRequest struct {
|
||||||
Users int `json:"users"`
|
Users int `json:"users"`
|
||||||
|
TermsAccepted bool `json:"terms_accepted"`
|
||||||
|
ReceiveEmailsAccepted bool `json:"receive_emails_accepted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
b, readErr := ioutil.ReadAll(r.Body)
|
b, readErr := ioutil.ReadAll(r.Body)
|
||||||
if readErr != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
json.Unmarshal(b, &usersNumber)
|
json.Unmarshal(b, &trialRequest)
|
||||||
if usersNumber.Users == 0 {
|
if !trialRequest.TermsAccepted {
|
||||||
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.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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,12 +185,14 @@ func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trialLicenseRequest := &model.TrialLicenseRequest{
|
trialLicenseRequest := &model.TrialLicenseRequest{
|
||||||
ServerID: c.App.DiagnosticId(),
|
ServerID: c.App.DiagnosticId(),
|
||||||
Name: currentUser.GetDisplayName(model.SHOW_FULLNAME),
|
Name: currentUser.GetDisplayName(model.SHOW_FULLNAME),
|
||||||
Email: currentUser.Email,
|
Email: currentUser.Email,
|
||||||
SiteName: *c.App.Config().TeamSettings.SiteName,
|
SiteName: *c.App.Config().TeamSettings.SiteName,
|
||||||
SiteURL: *c.App.Config().ServiceSettings.SiteURL,
|
SiteURL: *c.App.Config().ServiceSettings.SiteURL,
|
||||||
Users: usersNumber.Users,
|
Users: trialRequest.Users,
|
||||||
|
TermsAccepted: trialRequest.TermsAccepted,
|
||||||
|
ReceiveEmailsAccepted: trialRequest.ReceiveEmailsAccepted,
|
||||||
}
|
}
|
||||||
|
|
||||||
if trialLicenseRequest.SiteURL == "" {
|
if trialLicenseRequest.SiteURL == "" {
|
||||||
|
|||||||
@@ -1500,6 +1500,10 @@
|
|||||||
"id": "api.license.request-trial.bad-request",
|
"id": "api.license.request-trial.bad-request",
|
||||||
"translation": "The number of users requested is not correct."
|
"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",
|
"id": "api.license.request_trial_license.app_error",
|
||||||
"translation": "Unable to get a trial license, please try again or contact with support@mattermost.com."
|
"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 {
|
type TrialLicenseRequest struct {
|
||||||
ServerID string `json:"server_id"`
|
ServerID string `json:"server_id"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
SiteURL string `json:"site_url"`
|
SiteURL string `json:"site_url"`
|
||||||
SiteName string `json:"site_name"`
|
SiteName string `json:"site_name"`
|
||||||
Users int `json:"users"`
|
Users int `json:"users"`
|
||||||
|
TermsAccepted bool `json:"terms_accepted"`
|
||||||
|
ReceiveEmailsAccepted bool `json:"receive_emails_accepted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tlr *TrialLicenseRequest) ToJson() string {
|
func (tlr *TrialLicenseRequest) ToJson() string {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user