Self-hosted in-product purchase (#21804)

* Self-hosted admins can purchase licenses in-app when `ServiceSettings,SelfHostedPurchase` is true (the default)
* Content Security Policy enables loading assets from `js.stripe.com/v3` when `ServiceSettings.SelfHostedPurchase` is true (the default).
* Add `hosted_customer` API subpath
* Add status of SelfHostedPurchase to telemetry config report.
* Support showing admins self-hosted invoices when `ServiceSettings.SelfHostedPurchase` is true (the default)

Co-authored-by: Conor Macpherson <116016004+ConorMacpherson@users.noreply.github.com>
Этот коммит содержится в:
Nathaniel Allred
2022-12-13 13:36:18 -06:00
коммит произвёл GitHub
родитель 6fd174a95f
Коммит a8fa3f29e9
16 изменённых файлов: 551 добавлений и 29 удалений

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

@@ -916,6 +916,7 @@ type AppIface interface {
Notification() einterfaces.NotificationInterface
NotificationsLog() *mlog.Logger
NotifyAndSetWarnMetricAck(warnMetricId string, sender *model.User, forceAck bool, isBot bool) *model.AppError
NotifySelfHostedSignupProgress(progress string, userId string)
NotifySharedChannelUserUpdate(user *model.User)
OpenInteractiveDialog(request model.OpenDialogRequest) *model.AppError
OriginChecker() func(*http.Request) bool

21
app/hosted_customer.go Обычный файл
Просмотреть файл

@@ -0,0 +1,21 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package app
import (
"github.com/mattermost/mattermost-server/v6/model"
)
func (a *App) NotifySelfHostedSignupProgress(progress string, userId string) {
// this is an event only the relevant admin should receive.
// If there is no progress, there is nothing to report.
// If there is no userId, we do not want to mistakenly broadcast to all users.
if progress == "" || userId == "" {
return
}
message := model.NewWebSocketEvent(model.WebsocketEventHostedCustomerSignupProgressUpdated, "", "", userId, nil, "")
message.Add("progress", progress)
a.Srv().Platform().Publish(message)
}

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

@@ -12632,6 +12632,21 @@ func (a *OpenTracingAppLayer) NotifyAndSetWarnMetricAck(warnMetricId string, sen
return resultVar0
}
func (a *OpenTracingAppLayer) NotifySelfHostedSignupProgress(progress string, userId string) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.NotifySelfHostedSignupProgress")
a.ctx = newCtx
a.app.Srv().Store().SetContext(newCtx)
defer func() {
a.app.Srv().Store().SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
a.app.NotifySelfHostedSignupProgress(progress, userId)
}
func (a *OpenTracingAppLayer) NotifySessionsExpired() error {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.NotifySessionsExpired")