From 10ae09758920c6ef559739659e4d1232d8503cae Mon Sep 17 00:00:00 2001 From: Said Atrahouch Date: Mon, 12 Sep 2022 17:39:17 +0200 Subject: [PATCH 1/3] [MM-45580] Send deliquency since to end users and allow new notify admin request --- api4/cloud.go | 29 +++++++++++----------- api4/cloud_test.go | 56 +++++++++++++++++++++++-------------------- model/notify_admin.go | 2 ++ 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/api4/cloud.go b/api4/cloud.go index e71659537f..e86a9b0aca 100644 --- a/api4/cloud.go +++ b/api4/cloud.go @@ -67,20 +67,21 @@ func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) { // if it is an end user, return basic subscription data without sensitive information if !c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionSysconsoleReadBilling) { subscription = &model.Subscription{ - ID: subscription.ID, - ProductID: subscription.ProductID, - IsFreeTrial: subscription.IsFreeTrial, - TrialEndAt: subscription.TrialEndAt, - CustomerID: "", - AddOns: []string{}, - StartAt: 0, - EndAt: 0, - CreateAt: 0, - Seats: 0, - Status: "", - DNS: "", - IsPaidTier: "", - LastInvoice: &model.Invoice{}, + ID: subscription.ID, + ProductID: subscription.ProductID, + IsFreeTrial: subscription.IsFreeTrial, + TrialEndAt: subscription.TrialEndAt, + CustomerID: "", + AddOns: []string{}, + StartAt: 0, + EndAt: 0, + CreateAt: 0, + Seats: 0, + Status: "", + DNS: "", + IsPaidTier: "", + LastInvoice: &model.Invoice{}, + DelinquentSince: subscription.DelinquentSince, } } diff --git a/api4/cloud_test.go b/api4/cloud_test.go index 45c0eaa5ae..16da33ae88 100644 --- a/api4/cloud_test.go +++ b/api4/cloud_test.go @@ -111,36 +111,40 @@ func Test_getCloudLimits(t *testing.T) { } func Test_GetSubscription(t *testing.T) { + deliquencySince := int64(2000000000) + subscription := &model.Subscription{ - ID: "MySubscriptionID", - CustomerID: "MyCustomer", - ProductID: "SomeProductId", - AddOns: []string{}, - StartAt: 1000000000, - EndAt: 2000000000, - CreateAt: 1000000000, - Seats: 10, - IsFreeTrial: "true", - DNS: "some.dns.server", - IsPaidTier: "false", - TrialEndAt: 2000000000, - LastInvoice: &model.Invoice{}, + ID: "MySubscriptionID", + CustomerID: "MyCustomer", + ProductID: "SomeProductId", + AddOns: []string{}, + StartAt: 1000000000, + EndAt: 2000000000, + CreateAt: 1000000000, + Seats: 10, + IsFreeTrial: "true", + DNS: "some.dns.server", + IsPaidTier: "false", + TrialEndAt: 2000000000, + LastInvoice: &model.Invoice{}, + DelinquentSince: &deliquencySince, } userFacingSubscription := &model.Subscription{ - ID: "MySubscriptionID", - CustomerID: "", - ProductID: "SomeProductId", - AddOns: []string{}, - StartAt: 0, - EndAt: 0, - CreateAt: 0, - Seats: 0, - IsFreeTrial: "true", - DNS: "", - IsPaidTier: "", - TrialEndAt: 2000000000, - LastInvoice: &model.Invoice{}, + ID: "MySubscriptionID", + CustomerID: "", + ProductID: "SomeProductId", + AddOns: []string{}, + StartAt: 0, + EndAt: 0, + CreateAt: 0, + Seats: 0, + IsFreeTrial: "true", + DNS: "", + IsPaidTier: "", + TrialEndAt: 2000000000, + LastInvoice: &model.Invoice{}, + DelinquentSince: &deliquencySince, } t.Run("NON Admin users receive the user facing subscription", func(t *testing.T) { diff --git a/model/notify_admin.go b/model/notify_admin.go index 729050a804..edd11572ef 100644 --- a/model/notify_admin.go +++ b/model/notify_admin.go @@ -22,6 +22,7 @@ const ( PaidFeatureUnlimitedBoardcards = MattermostPaidFeature("mattermost.feature.unlimited_board_cards") PaidFeatureAllProfessionalfeatures = MattermostPaidFeature("mattermost.feature.all_professional") PaidFeatureAllEnterprisefeatures = MattermostPaidFeature("mattermost.feature.all_enterprise") + UpgradeDowngradeWorkspace = MattermostPaidFeature("mattermost.feature.upgrade_downgrade_workspace") ) var validSKUs map[string]struct{} = map[string]struct{}{ @@ -42,6 +43,7 @@ var paidFeatures map[MattermostPaidFeature]struct{} = map[MattermostPaidFeature] PaidFeatureUnlimitedBoardcards: {}, PaidFeatureAllProfessionalfeatures: {}, PaidFeatureAllEnterprisefeatures: {}, + UpgradeDowngradeWorkspace: {}, } type NotifyAdminToUpgradeRequest struct { From aaabf71ceb8f36b0b71ff1286cc3b4235fa8c1f5 Mon Sep 17 00:00:00 2001 From: Said Atrahouch Date: Tue, 13 Sep 2022 13:06:04 +0200 Subject: [PATCH 2/3] Update model/notify_admin.go Co-authored-by: Maria A Nunez --- model/notify_admin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/notify_admin.go b/model/notify_admin.go index edd11572ef..0ac0dd9743 100644 --- a/model/notify_admin.go +++ b/model/notify_admin.go @@ -22,7 +22,7 @@ const ( PaidFeatureUnlimitedBoardcards = MattermostPaidFeature("mattermost.feature.unlimited_board_cards") PaidFeatureAllProfessionalfeatures = MattermostPaidFeature("mattermost.feature.all_professional") PaidFeatureAllEnterprisefeatures = MattermostPaidFeature("mattermost.feature.all_enterprise") - UpgradeDowngradeWorkspace = MattermostPaidFeature("mattermost.feature.upgrade_downgrade_workspace") + UpgradeDowngradedWorkspace = MattermostPaidFeature("mattermost.feature.upgrade_downgraded_workspace") ) var validSKUs map[string]struct{} = map[string]struct{}{ From fb3b2a4f47fb67f988e0209de3b9a21ed45315df Mon Sep 17 00:00:00 2001 From: Said Atrahouch Date: Tue, 13 Sep 2022 13:13:35 +0200 Subject: [PATCH 3/3] [MM-45580] Update with the typo the map --- model/notify_admin.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/notify_admin.go b/model/notify_admin.go index 0ac0dd9743..247b28e11e 100644 --- a/model/notify_admin.go +++ b/model/notify_admin.go @@ -22,7 +22,7 @@ const ( PaidFeatureUnlimitedBoardcards = MattermostPaidFeature("mattermost.feature.unlimited_board_cards") PaidFeatureAllProfessionalfeatures = MattermostPaidFeature("mattermost.feature.all_professional") PaidFeatureAllEnterprisefeatures = MattermostPaidFeature("mattermost.feature.all_enterprise") - UpgradeDowngradedWorkspace = MattermostPaidFeature("mattermost.feature.upgrade_downgraded_workspace") + UpgradeDowngradedWorkspace = MattermostPaidFeature("mattermost.feature.upgrade_downgraded_workspace") ) var validSKUs map[string]struct{} = map[string]struct{}{ @@ -43,7 +43,7 @@ var paidFeatures map[MattermostPaidFeature]struct{} = map[MattermostPaidFeature] PaidFeatureUnlimitedBoardcards: {}, PaidFeatureAllProfessionalfeatures: {}, PaidFeatureAllEnterprisefeatures: {}, - UpgradeDowngradeWorkspace: {}, + UpgradeDowngradedWorkspace: {}, } type NotifyAdminToUpgradeRequest struct {