Merge pull request #21801 from mattermost/MM-48125-downgrade-to-starter-email-says-upgrade-with-billing-start-date
- Ensure upgrade emails are not sent out when downgrading to the starter/free plan by checking if the new subscription's product SKU is cloud-starter.
Этот коммит содержится в:
@@ -96,6 +96,8 @@ func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
userId := c.AppContext.Session().UserId
|
||||||
|
|
||||||
if !c.App.Channels().License().IsCloud() {
|
if !c.App.Channels().License().IsCloud() {
|
||||||
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.license_error", nil, "", http.StatusInternalServerError)
|
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.license_error", nil, "", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -118,13 +120,13 @@ func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSubscription, appErr := c.App.Cloud().GetSubscription(c.AppContext.Session().UserId)
|
currentSubscription, appErr := c.App.Cloud().GetSubscription(userId)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
|
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
changedSub, err := c.App.Cloud().ChangeSubscription(c.AppContext.Session().UserId, currentSubscription.ID, subscriptionChange)
|
changedSub, err := c.App.Cloud().ChangeSubscription(userId, currentSubscription.ID, subscriptionChange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||||
return
|
return
|
||||||
@@ -141,6 +143,11 @@ func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
c.Logger.Error("Error finding the new cloud product", mlog.Err(err))
|
c.Logger.Error("Error finding the new cloud product", mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if product.SKU == string(model.SkuCloudStarter) {
|
||||||
|
w.Write(json)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
isYearly := product.IsYearly()
|
isYearly := product.IsYearly()
|
||||||
|
|
||||||
// Log failures for purchase confirmation email, but don't show an error to the user so as not to confuse them
|
// Log failures for purchase confirmation email, but don't show an error to the user so as not to confuse them
|
||||||
|
|||||||
@@ -42,6 +42,20 @@ const (
|
|||||||
SubscriptionFamilyOnPrem = SubscriptionFamily("on-prem")
|
SubscriptionFamilyOnPrem = SubscriptionFamily("on-prem")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ProductSku string
|
||||||
|
|
||||||
|
const (
|
||||||
|
SkuStarterGov = ProductSku("starter-gov")
|
||||||
|
SkuProfessionalGov = ProductSku("professional-gov")
|
||||||
|
SkuEnterpriseGov = ProductSku("enterprise-gov")
|
||||||
|
SkuStarter = ProductSku("starter")
|
||||||
|
SkuProfessional = ProductSku("professional")
|
||||||
|
SkuEnterprise = ProductSku("enterprise")
|
||||||
|
SkuCloudStarter = ProductSku("cloud-starter")
|
||||||
|
SkuCloudProfessional = ProductSku("cloud-professional")
|
||||||
|
SkuCloudEnterprise = ProductSku("cloud-enterprise")
|
||||||
|
)
|
||||||
|
|
||||||
// Product model represents a product on the cloud system.
|
// Product model represents a product on the cloud system.
|
||||||
type Product struct {
|
type Product struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user