Allow webapp to request legacy cloud products. (#18528)

* Change internal getProducts to filter on a set of families instead of a single family.
* Extend /products endpoint to be able to return any of the current four sets of product families.
* Use include_legacy query param to decide which cloud products to request.
Этот коммит содержится в:
Nathaniel Allred
2021-10-07 11:48:56 -05:00
коммит произвёл GitHub
родитель d13b3604ea
Коммит fbe4f75953
3 изменённых файлов: 12 добавлений и 9 удалений

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

@@ -138,7 +138,10 @@ func getCloudProducts(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
products, err := c.App.Cloud().GetCloudProducts(c.AppContext.Session().UserId)
includeLegacyProducts := r.URL.Query().Get("include_legacy") == "true"
products, err := c.App.Cloud().GetCloudProducts(c.AppContext.Session().UserId, includeLegacyProducts)
if err != nil {
c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
return

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

@@ -8,7 +8,7 @@ import (
)
type CloudInterface interface {
GetCloudProducts(userID string) ([]*model.Product, error)
GetCloudProducts(userID string, includeLegacyProducts bool) ([]*model.Product, error)
CreateCustomerPayment(userID string) (*model.StripeSetupIntent, error)
ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error

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

@@ -97,13 +97,13 @@ func (_m *CloudInterface) GetCloudCustomer(userID string) (*model.CloudCustomer,
return r0, r1
}
// GetCloudProducts provides a mock function with given fields: userID
func (_m *CloudInterface) GetCloudProducts(userID string) ([]*model.Product, error) {
ret := _m.Called(userID)
// GetCloudProducts provides a mock function with given fields: userID, includeLegacyProducts
func (_m *CloudInterface) GetCloudProducts(userID string, includeLegacyProducts bool) ([]*model.Product, error) {
ret := _m.Called(userID, includeLegacyProducts)
var r0 []*model.Product
if rf, ok := ret.Get(0).(func(string) []*model.Product); ok {
r0 = rf(userID)
if rf, ok := ret.Get(0).(func(string, bool) []*model.Product); ok {
r0 = rf(userID, includeLegacyProducts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.Product)
@@ -111,8 +111,8 @@ func (_m *CloudInterface) GetCloudProducts(userID string) ([]*model.Product, err
}
var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(userID)
if rf, ok := ret.Get(1).(func(string, bool) error); ok {
r1 = rf(userID, includeLegacyProducts)
} else {
r1 = ret.Error(1)
}