* 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>
Этот коммит содержится в:
Jesús Espino
2020-06-02 21:34:15 +02:00
коммит произвёл GitHub
родитель 1c9891c65e
Коммит e0edd2bebb
7 изменённых файлов: 138 добавлений и 0 удалений

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

@@ -253,6 +253,8 @@ type AppIface interface {
RenameChannel(channel *model.Channel, newChannelName string, newDisplayName string) (*model.Channel, *model.AppError)
// RenameTeam is used to rename the team Name and the DisplayName fields
RenameTeam(team *model.Team, newTeamName string, newDisplayName string) (*model.Team, *model.AppError)
// RequestTrialLicense request a trial license from the mattermost offical license server
RequestTrialLicense(trialRequest *model.TrialLicenseRequest) *model.AppError
// RevokeSessionsFromAllUsers will go through all the sessions active
// in the server and revoke them
RevokeSessionsFromAllUsers() *model.AppError

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

@@ -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
}

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

@@ -11395,6 +11395,28 @@ func (a *OpenTracingAppLayer) RenameTeam(team *model.Team, newTeamName string, n
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) RequestTrialLicense(trialRequest *model.TrialLicenseRequest) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RequestTrialLicense")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0 := a.app.RequestTrialLicense(trialRequest)
if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0))
ext.Error.Set(span, true)
}
return resultVar0
}
func (a *OpenTracingAppLayer) ResetPasswordFromToken(userSuppliedTokenString string, newPassword string) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.ResetPasswordFromToken")