Add trial license api (#14603)
* Initial request trial api creation * Adding test license public certificate * Adding go client method * Applying changes to use production environment * Removing accidentally added strings Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1c9891c65e
Коммит
e0edd2bebb
@@ -4,6 +4,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -12,6 +13,8 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
const requestTrialURL = "https://customers.mattermost.com/api/v1/trials"
|
||||
|
||||
func (a *App) LoadLicense() {
|
||||
licenseId := ""
|
||||
props, err := a.Srv().Store.System().Get()
|
||||
@@ -214,3 +217,22 @@ func (a *App) GetSanitizedClientLicense() map[string]string {
|
||||
|
||||
return sanitizedLicense
|
||||
}
|
||||
|
||||
// RequestTrialLicense request a trial license from the mattermost offical license server
|
||||
func (a *App) RequestTrialLicense(trialRequest *model.TrialLicenseRequest) *model.AppError {
|
||||
resp, err := http.Post(requestTrialURL, "application/json", bytes.NewBuffer([]byte(trialRequest.ToJson())))
|
||||
if err != nil {
|
||||
return model.NewAppError("RequestTrialLicense", "api.license.request_trial_license.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
licenseResponse := model.MapFromJson(resp.Body)
|
||||
|
||||
if _, err := a.SaveLicense([]byte(licenseResponse["license"])); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.ReloadConfig()
|
||||
a.InvalidateAllCaches()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user