From 5203fc86086eb13a408e55c70829aac313e8f89d Mon Sep 17 00:00:00 2001 From: Mario de Frutos Dieguez Date: Fri, 5 Mar 2021 09:23:39 +0100 Subject: [PATCH] [MM-28694] Add MM User information in the CWS request headers (#15824) * Include user data in the cloud endpoints Those headers will include the user ID and Email so we can use them in CWS * Removed AppError from enterprise/cloud We're removing the AppError from all the places that don't belong to the app or api4 packages. * Remove unused i18n strings * Move it to the server init of enterprise Also moved the initialization of the enterprise part in the server after the store is initialized * Initialize after the store is set in NewServer The ideal way to do it should be to move the initEnterprise call after the store is set but that would lead to undesired side-effects so we initialize the cloud part alone. Signed-off-by: Mario de Frutos --- api4/cloud.go | 59 +++++---- api4/team.go | 20 +++- app/cloud.go | 40 +++++-- app/enterprise.go | 7 +- app/server.go | 8 ++ einterfaces/cloud.go | 18 +-- einterfaces/mocks/CloudInterface.go | 180 +++++++++++++--------------- i18n/en.json | 24 ++-- 8 files changed, 190 insertions(+), 166 deletions(-) diff --git a/api4/cloud.go b/api4/cloud.go index a329d5f6c2..62737f53f8 100644 --- a/api4/cloud.go +++ b/api4/cloud.go @@ -54,10 +54,9 @@ func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) { return } - subscription, appErr := c.App.Cloud().GetSubscription() - - if appErr != nil { - c.Err = model.NewAppError("Api4.getSubscription", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) + subscription, err := c.App.Cloud().GetSubscription(c.App.Session().UserId) + if err != nil { + c.Err = model.NewAppError("Api4.getSubscription", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) return } @@ -76,7 +75,7 @@ func getSubscriptionStats(c *Context, w http.ResponseWriter, r *http.Request) { return } - subscription, appErr := c.App.Cloud().GetSubscription() + subscription, appErr := c.App.Cloud().GetSubscription("") if appErr != nil { c.Err = model.NewAppError("Api4.getSubscriptionStats", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) @@ -111,9 +110,9 @@ func getCloudProducts(c *Context, w http.ResponseWriter, r *http.Request) { return } - products, appErr := c.App.Cloud().GetCloudProducts() - if appErr != nil { - c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) + products, err := c.App.Cloud().GetCloudProducts(c.App.Session().UserId) + if err != nil { + c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) return } @@ -137,9 +136,9 @@ func getCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) { return } - customer, appErr := c.App.Cloud().GetCloudCustomer() - if appErr != nil { - c.Err = model.NewAppError("Api4.getCloudCustomer", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) + customer, err := c.App.Cloud().GetCloudCustomer(c.App.Session().UserId) + if err != nil { + c.Err = model.NewAppError("Api4.getCloudCustomer", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) return } @@ -175,7 +174,7 @@ func updateCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) { return } - customer, appErr := c.App.Cloud().UpdateCloudCustomer(customerInfo) + customer, appErr := c.App.Cloud().UpdateCloudCustomer(c.App.Session().UserId, customerInfo) if appErr != nil { c.Err = model.NewAppError("Api4.updateCloudCustomer", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) return @@ -213,7 +212,7 @@ func updateCloudCustomerAddress(c *Context, w http.ResponseWriter, r *http.Reque return } - customer, appErr := c.App.Cloud().UpdateCloudCustomerAddress(address) + customer, appErr := c.App.Cloud().UpdateCloudCustomerAddress(c.App.Session().UserId, address) if appErr != nil { c.Err = model.NewAppError("Api4.updateCloudCustomerAddress", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) return @@ -242,9 +241,9 @@ func createCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) { auditRec := c.MakeAuditRecord("createCustomerPayment", audit.Fail) defer c.LogAuditRec(auditRec) - intent, appErr := c.App.Cloud().CreateCustomerPayment() - if appErr != nil { - c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) + intent, err := c.App.Cloud().CreateCustomerPayment(c.App.Session().UserId) + if err != nil { + c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) return } @@ -285,9 +284,9 @@ func confirmCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) return } - appErr := c.App.Cloud().ConfirmCustomerPayment(confirmRequest) - if appErr != nil { - c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) + err = c.App.Cloud().ConfirmCustomerPayment(c.App.Session().UserId, confirmRequest) + if err != nil { + c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) return } @@ -307,7 +306,7 @@ func getInvoicesForSubscription(c *Context, w http.ResponseWriter, r *http.Reque return } - invoices, appErr := c.App.Cloud().GetInvoicesForSubscription() + invoices, appErr := c.App.Cloud().GetInvoicesForSubscription(c.App.Session().UserId) if appErr != nil { c.Err = model.NewAppError("Api4.getInvoicesForSubscription", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) return @@ -338,7 +337,7 @@ func getSubscriptionInvoicePDF(c *Context, w http.ResponseWriter, r *http.Reques return } - pdfData, filename, appErr := c.App.Cloud().GetInvoicePDF(c.Params.InvoiceId) + pdfData, filename, appErr := c.App.Cloud().GetInvoicePDF(c.App.Session().UserId, c.Params.InvoiceId) if appErr != nil { c.Err = model.NewAppError("Api4.getSuscriptionInvoicePDF", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) return @@ -398,20 +397,20 @@ func sendAdminUpgradeRequestEmail(c *Context, w http.ResponseWriter, r *http.Req return } - user, err := c.App.GetUser(c.App.Session().UserId) - if err != nil { - c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", err.Id, nil, err.Error(), err.StatusCode) + user, appErr := c.App.GetUser(c.App.Session().UserId) + if appErr != nil { + c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", appErr.Id, nil, appErr.Error(), appErr.StatusCode) return } - sub, err := c.App.Cloud().GetSubscription() + sub, err := c.App.Cloud().GetSubscription(c.App.Session().UserId) if err != nil { c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) return } - if err = c.App.SendAdminUpgradeRequestEmail(user.Username, sub, model.InviteLimitation); err != nil { - c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", err.Id, nil, err.Error(), err.StatusCode) + if appErr = c.App.SendAdminUpgradeRequestEmail(user.Username, sub, model.InviteLimitation); appErr != nil { + c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", appErr.Id, nil, appErr.Error(), appErr.StatusCode) return } @@ -424,14 +423,14 @@ func sendAdminUpgradeRequestEmailOnJoin(c *Context, w http.ResponseWriter, r *ht return } - sub, err := c.App.Cloud().GetSubscription() + sub, err := c.App.Cloud().GetSubscription("") if err != nil { c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmailOnJoin", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) return } - if err = c.App.SendAdminUpgradeRequestEmail("", sub, model.JoinLimitation); err != nil { - c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", err.Id, nil, err.Error(), err.StatusCode) + if appErr := c.App.SendAdminUpgradeRequestEmail("", sub, model.JoinLimitation); appErr != nil { + c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", appErr.Id, nil, appErr.Error(), appErr.StatusCode) return } diff --git a/api4/team.go b/api4/team.go index 4b76e575ec..cdc6bf09af 100644 --- a/api4/team.go +++ b/api4/team.go @@ -1206,9 +1206,14 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) { cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit var invitesOverLimit []*model.EmailInviteWithError if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && cloudUserLimit > 0 { - subscription, subErr := c.App.Cloud().GetSubscription() + subscription, subErr := c.App.Cloud().GetSubscription(c.App.Session().UserId) if subErr != nil { - c.Err = subErr + c.Err = model.NewAppError( + "Api4.inviteUsersToTeam", + "api.team.cloud.subscription.error", + nil, + subErr.Error(), + http.StatusInternalServerError) return } if subscription == nil || subscription.IsPaidTier != "true" { @@ -1294,9 +1299,14 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request) cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit var invitesOverLimit []*model.EmailInviteWithError if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && cloudUserLimit > 0 && c.IsSystemAdmin() { - subscription, subErr := c.App.Cloud().GetSubscription() - if subErr != nil { - c.Err = subErr + subscription, err := c.App.Cloud().GetSubscription(c.App.Session().UserId) + if err != nil { + c.Err = model.NewAppError( + "Api4.inviteGuestsToChannel", + "api.team.cloud.subscription.error", + nil, + err.Error(), + http.StatusInternalServerError) return } if subscription == nil || subscription.IsPaidTier != "true" { diff --git a/app/cloud.go b/app/cloud.go index 38ed8c81d6..3cfe257294 100644 --- a/app/cloud.go +++ b/app/cloud.go @@ -84,9 +84,14 @@ func (a *App) CheckAndSendUserLimitWarningEmails() *model.AppError { return nil } - subscription, subErr := a.Cloud().GetSubscription() - if subErr != nil { - return subErr + subscription, err := a.Cloud().GetSubscription(a.Session().UserId) + if err != nil { + return model.NewAppError( + "app.CheckAndSendUserLimitWarningEmails", + "api.cloud.get_subscription.error", + nil, + err.Error(), + http.StatusInternalServerError) } if subscription != nil && subscription.IsPaidTier == "true" { @@ -101,21 +106,40 @@ func (a *App) CheckAndSendUserLimitWarningEmails() *model.AppError { if remainingUsers > 0 { return nil } - sysAdmins, err := a.getSysAdminsEmailRecipients() - if err != nil { - return err + sysAdmins, appErr := a.getSysAdminsEmailRecipients() + if appErr != nil { + return model.NewAppError( + "app.CheckAndSendUserLimitWarningEmails", + "api.cloud.get_admins_emails.error", + nil, + appErr.Error(), + http.StatusInternalServerError) } // -1 means they are 1 user over the limit - we only want to send the email for the 11th user if remainingUsers == -1 { // Over limit by 1 user for admin := range sysAdmins { - a.Srv().EmailService.SendOverUserLimitWarningEmail(sysAdmins[admin].Email, sysAdmins[admin].Locale, *a.Config().ServiceSettings.SiteURL) + _, appErr := a.Srv().EmailService.SendOverUserLimitWarningEmail(sysAdmins[admin].Email, sysAdmins[admin].Locale, *a.Config().ServiceSettings.SiteURL) + if appErr != nil { + a.Log().Error( + "Error sending user limit warning email to admin", + mlog.String("username", sysAdmins[admin].Username), + mlog.Err(err), + ) + } } } else if remainingUsers == 0 { // At limit for admin := range sysAdmins { - a.Srv().EmailService.SendAtUserLimitWarningEmail(sysAdmins[admin].Email, sysAdmins[admin].Locale, *a.Config().ServiceSettings.SiteURL) + _, appErr := a.Srv().EmailService.SendAtUserLimitWarningEmail(sysAdmins[admin].Email, sysAdmins[admin].Locale, *a.Config().ServiceSettings.SiteURL) + if appErr != nil { + a.Log().Error( + "Error sending user limit warning email to admin", + mlog.String("username", sysAdmins[admin].Username), + mlog.Err(err), + ) + } } } return nil diff --git a/app/enterprise.go b/app/enterprise.go index 19884d2dbf..d4a5c84601 100644 --- a/app/enterprise.go +++ b/app/enterprise.go @@ -150,9 +150,9 @@ func RegisterMessageExportInterface(f func(*Server) einterfaces.MessageExportInt messageExportInterface = f } -var cloudInterface func(*App) einterfaces.CloudInterface +var cloudInterface func(*Server) einterfaces.CloudInterface -func RegisterCloudInterface(f func(*App) einterfaces.CloudInterface) { +func RegisterCloudInterface(f func(*Server) einterfaces.CloudInterface) { cloudInterface = f } @@ -217,7 +217,4 @@ func (a *App) initEnterprise() { } }) } - if cloudInterface != nil { - a.srv.Cloud = cloudInterface(a) - } } diff --git a/app/server.go b/app/server.go index 46c4c0598b..0000945ef9 100644 --- a/app/server.go +++ b/app/server.go @@ -416,6 +416,14 @@ func NewServer(options ...Option) (*Server, error) { }) + // This enterprise init should happen after the store is set + // but we don't want to move the s.initEnterprise() call because + // we had side-effects with that in the past and needs further + // investigation + if cloudInterface != nil { + s.Cloud = cloudInterface(s) + } + s.telemetryService = telemetry.New(s, s.Store, s.SearchEngine, s.Log) emailService, err := NewEmailService(s) diff --git a/einterfaces/cloud.go b/einterfaces/cloud.go index 6c56cac473..771989b83f 100644 --- a/einterfaces/cloud.go +++ b/einterfaces/cloud.go @@ -8,16 +8,16 @@ import ( ) type CloudInterface interface { - GetCloudProducts() ([]*model.Product, *model.AppError) + GetCloudProducts(userID string) ([]*model.Product, error) - CreateCustomerPayment() (*model.StripeSetupIntent, *model.AppError) - ConfirmCustomerPayment(*model.ConfirmPaymentMethodRequest) *model.AppError + CreateCustomerPayment(userID string) (*model.StripeSetupIntent, error) + ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error - GetCloudCustomer() (*model.CloudCustomer, *model.AppError) - UpdateCloudCustomer(customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, *model.AppError) - UpdateCloudCustomerAddress(address *model.Address) (*model.CloudCustomer, *model.AppError) + GetCloudCustomer(userID string) (*model.CloudCustomer, error) + UpdateCloudCustomer(userID string, customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, error) + UpdateCloudCustomerAddress(userID string, address *model.Address) (*model.CloudCustomer, error) - GetSubscription() (*model.Subscription, *model.AppError) - GetInvoicesForSubscription() ([]*model.Invoice, *model.AppError) - GetInvoicePDF(invoiceID string) ([]byte, string, *model.AppError) + GetSubscription(userID string) (*model.Subscription, error) + GetInvoicesForSubscription(userID string) ([]*model.Invoice, error) + GetInvoicePDF(userID, invoiceID string) ([]byte, string, error) } diff --git a/einterfaces/mocks/CloudInterface.go b/einterfaces/mocks/CloudInterface.go index 9a78417e08..1f80e8abb8 100644 --- a/einterfaces/mocks/CloudInterface.go +++ b/einterfaces/mocks/CloudInterface.go @@ -14,104 +14,96 @@ type CloudInterface struct { mock.Mock } -// ConfirmCustomerPayment provides a mock function with given fields: _a0 -func (_m *CloudInterface) ConfirmCustomerPayment(_a0 *model.ConfirmPaymentMethodRequest) *model.AppError { - ret := _m.Called(_a0) +// ConfirmCustomerPayment provides a mock function with given fields: userID, confirmRequest +func (_m *CloudInterface) ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error { + ret := _m.Called(userID, confirmRequest) - var r0 *model.AppError - if rf, ok := ret.Get(0).(func(*model.ConfirmPaymentMethodRequest) *model.AppError); ok { - r0 = rf(_a0) + var r0 error + if rf, ok := ret.Get(0).(func(string, *model.ConfirmPaymentMethodRequest) error); ok { + r0 = rf(userID, confirmRequest) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.AppError) - } + r0 = ret.Error(0) } return r0 } -// CreateCustomerPayment provides a mock function with given fields: -func (_m *CloudInterface) CreateCustomerPayment() (*model.StripeSetupIntent, *model.AppError) { - ret := _m.Called() +// CreateCustomerPayment provides a mock function with given fields: userID +func (_m *CloudInterface) CreateCustomerPayment(userID string) (*model.StripeSetupIntent, error) { + ret := _m.Called(userID) var r0 *model.StripeSetupIntent - if rf, ok := ret.Get(0).(func() *model.StripeSetupIntent); ok { - r0 = rf() + if rf, ok := ret.Get(0).(func(string) *model.StripeSetupIntent); ok { + r0 = rf(userID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*model.StripeSetupIntent) } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func() *model.AppError); ok { - r1 = rf() + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(userID) } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } + r1 = ret.Error(1) } return r0, r1 } -// GetCloudCustomer provides a mock function with given fields: -func (_m *CloudInterface) GetCloudCustomer() (*model.CloudCustomer, *model.AppError) { - ret := _m.Called() +// GetCloudCustomer provides a mock function with given fields: userID +func (_m *CloudInterface) GetCloudCustomer(userID string) (*model.CloudCustomer, error) { + ret := _m.Called(userID) var r0 *model.CloudCustomer - if rf, ok := ret.Get(0).(func() *model.CloudCustomer); ok { - r0 = rf() + if rf, ok := ret.Get(0).(func(string) *model.CloudCustomer); ok { + r0 = rf(userID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*model.CloudCustomer) } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func() *model.AppError); ok { - r1 = rf() + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(userID) } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } + r1 = ret.Error(1) } return r0, r1 } -// GetCloudProducts provides a mock function with given fields: -func (_m *CloudInterface) GetCloudProducts() ([]*model.Product, *model.AppError) { - ret := _m.Called() +// GetCloudProducts provides a mock function with given fields: userID +func (_m *CloudInterface) GetCloudProducts(userID string) ([]*model.Product, error) { + ret := _m.Called(userID) var r0 []*model.Product - if rf, ok := ret.Get(0).(func() []*model.Product); ok { - r0 = rf() + if rf, ok := ret.Get(0).(func(string) []*model.Product); ok { + r0 = rf(userID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]*model.Product) } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func() *model.AppError); ok { - r1 = rf() + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(userID) } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } + r1 = ret.Error(1) } return r0, r1 } -// GetInvoicePDF provides a mock function with given fields: invoiceID -func (_m *CloudInterface) GetInvoicePDF(invoiceID string) ([]byte, string, *model.AppError) { - ret := _m.Called(invoiceID) +// GetInvoicePDF provides a mock function with given fields: userID, invoiceID +func (_m *CloudInterface) GetInvoicePDF(userID string, invoiceID string) ([]byte, string, error) { + ret := _m.Called(userID, invoiceID) var r0 []byte - if rf, ok := ret.Get(0).(func(string) []byte); ok { - r0 = rf(invoiceID) + if rf, ok := ret.Get(0).(func(string, string) []byte); ok { + r0 = rf(userID, invoiceID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]byte) @@ -119,119 +111,109 @@ func (_m *CloudInterface) GetInvoicePDF(invoiceID string) ([]byte, string, *mode } var r1 string - if rf, ok := ret.Get(1).(func(string) string); ok { - r1 = rf(invoiceID) + if rf, ok := ret.Get(1).(func(string, string) string); ok { + r1 = rf(userID, invoiceID) } else { r1 = ret.Get(1).(string) } - var r2 *model.AppError - if rf, ok := ret.Get(2).(func(string) *model.AppError); ok { - r2 = rf(invoiceID) + var r2 error + if rf, ok := ret.Get(2).(func(string, string) error); ok { + r2 = rf(userID, invoiceID) } else { - if ret.Get(2) != nil { - r2 = ret.Get(2).(*model.AppError) - } + r2 = ret.Error(2) } return r0, r1, r2 } -// GetInvoicesForSubscription provides a mock function with given fields: -func (_m *CloudInterface) GetInvoicesForSubscription() ([]*model.Invoice, *model.AppError) { - ret := _m.Called() +// GetInvoicesForSubscription provides a mock function with given fields: userID +func (_m *CloudInterface) GetInvoicesForSubscription(userID string) ([]*model.Invoice, error) { + ret := _m.Called(userID) var r0 []*model.Invoice - if rf, ok := ret.Get(0).(func() []*model.Invoice); ok { - r0 = rf() + if rf, ok := ret.Get(0).(func(string) []*model.Invoice); ok { + r0 = rf(userID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]*model.Invoice) } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func() *model.AppError); ok { - r1 = rf() + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(userID) } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } + r1 = ret.Error(1) } return r0, r1 } -// GetSubscription provides a mock function with given fields: -func (_m *CloudInterface) GetSubscription() (*model.Subscription, *model.AppError) { - ret := _m.Called() +// GetSubscription provides a mock function with given fields: userID +func (_m *CloudInterface) GetSubscription(userID string) (*model.Subscription, error) { + ret := _m.Called(userID) var r0 *model.Subscription - if rf, ok := ret.Get(0).(func() *model.Subscription); ok { - r0 = rf() + if rf, ok := ret.Get(0).(func(string) *model.Subscription); ok { + r0 = rf(userID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*model.Subscription) } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func() *model.AppError); ok { - r1 = rf() + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(userID) } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } + r1 = ret.Error(1) } return r0, r1 } -// UpdateCloudCustomer provides a mock function with given fields: customerInfo -func (_m *CloudInterface) UpdateCloudCustomer(customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, *model.AppError) { - ret := _m.Called(customerInfo) +// UpdateCloudCustomer provides a mock function with given fields: userID, customerInfo +func (_m *CloudInterface) UpdateCloudCustomer(userID string, customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, error) { + ret := _m.Called(userID, customerInfo) var r0 *model.CloudCustomer - if rf, ok := ret.Get(0).(func(*model.CloudCustomerInfo) *model.CloudCustomer); ok { - r0 = rf(customerInfo) + if rf, ok := ret.Get(0).(func(string, *model.CloudCustomerInfo) *model.CloudCustomer); ok { + r0 = rf(userID, customerInfo) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*model.CloudCustomer) } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func(*model.CloudCustomerInfo) *model.AppError); ok { - r1 = rf(customerInfo) + var r1 error + if rf, ok := ret.Get(1).(func(string, *model.CloudCustomerInfo) error); ok { + r1 = rf(userID, customerInfo) } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } + r1 = ret.Error(1) } return r0, r1 } -// UpdateCloudCustomerAddress provides a mock function with given fields: address -func (_m *CloudInterface) UpdateCloudCustomerAddress(address *model.Address) (*model.CloudCustomer, *model.AppError) { - ret := _m.Called(address) +// UpdateCloudCustomerAddress provides a mock function with given fields: userID, address +func (_m *CloudInterface) UpdateCloudCustomerAddress(userID string, address *model.Address) (*model.CloudCustomer, error) { + ret := _m.Called(userID, address) var r0 *model.CloudCustomer - if rf, ok := ret.Get(0).(func(*model.Address) *model.CloudCustomer); ok { - r0 = rf(address) + if rf, ok := ret.Get(0).(func(string, *model.Address) *model.CloudCustomer); ok { + r0 = rf(userID, address) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*model.CloudCustomer) } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func(*model.Address) *model.AppError); ok { - r1 = rf(address) + var r1 error + if rf, ok := ret.Get(1).(func(string, *model.Address) error); ok { + r1 = rf(userID, address) } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } + r1 = ret.Error(1) } return r0, r1 diff --git a/i18n/en.json b/i18n/en.json index 17f6d3364a..6b173ab7f8 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -479,6 +479,14 @@ "id": "api.cloud.app_error", "translation": "Internal error during cloud api request." }, + { + "id": "api.cloud.get_admins_emails.error", + "translation": "Error getting system admins email." + }, + { + "id": "api.cloud.get_subscription.error", + "translation": "Error getting cloud subscription." + }, { "id": "api.cloud.license_error", "translation": "Your license does not support cloud requests." @@ -2434,6 +2442,10 @@ "id": "api.team.add_user_to_team_from_invite.guest.app_error", "translation": "Guests are restricted from joining a team via an invite link. Please request a guest email invitation to the team." }, + { + "id": "api.team.cloud.subscription.error", + "translation": "Error getting cloud subscription" + }, { "id": "api.team.demote_user_to_guest.disabled.error", "translation": "Guest accounts are disabled." @@ -6247,16 +6259,8 @@ "translation": " attached a file." }, { - "id": "ent.cloud.authentication_failed", - "translation": "Unable to authenticate to CWS" - }, - { - "id": "ent.cloud.json_encode.error", - "translation": "Internal error marshaling request to CWS" - }, - { - "id": "ent.cloud.request_error", - "translation": "Error processing request to CWS" + "id": "ent.cloud.subscription.error", + "translation": "Error getting cloud subscription" }, { "id": "ent.cluster.404.app_error",