[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 <mario@defrutos.org>
Этот коммит содержится в:
Mario de Frutos Dieguez
2021-03-05 09:23:39 +01:00
коммит произвёл GitHub
родитель 633d82f0ac
Коммит 5203fc8608
8 изменённых файлов: 190 добавлений и 166 удалений

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

@@ -54,10 +54,9 @@ func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
subscription, appErr := c.App.Cloud().GetSubscription() subscription, err := c.App.Cloud().GetSubscription(c.App.Session().UserId)
if err != nil {
if appErr != nil { c.Err = model.NewAppError("Api4.getSubscription", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
c.Err = model.NewAppError("Api4.getSubscription", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError)
return return
} }
@@ -76,7 +75,7 @@ func getSubscriptionStats(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
subscription, appErr := c.App.Cloud().GetSubscription() subscription, appErr := c.App.Cloud().GetSubscription("")
if appErr != nil { if appErr != nil {
c.Err = model.NewAppError("Api4.getSubscriptionStats", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) 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 return
} }
products, appErr := c.App.Cloud().GetCloudProducts() products, err := c.App.Cloud().GetCloudProducts(c.App.Session().UserId)
if appErr != nil { if err != nil {
c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -137,9 +136,9 @@ func getCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
customer, appErr := c.App.Cloud().GetCloudCustomer() customer, err := c.App.Cloud().GetCloudCustomer(c.App.Session().UserId)
if appErr != nil { if err != nil {
c.Err = model.NewAppError("Api4.getCloudCustomer", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.getCloudCustomer", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -175,7 +174,7 @@ func updateCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
customer, appErr := c.App.Cloud().UpdateCloudCustomer(customerInfo) customer, appErr := c.App.Cloud().UpdateCloudCustomer(c.App.Session().UserId, customerInfo)
if appErr != nil { if appErr != nil {
c.Err = model.NewAppError("Api4.updateCloudCustomer", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.updateCloudCustomer", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError)
return return
@@ -213,7 +212,7 @@ func updateCloudCustomerAddress(c *Context, w http.ResponseWriter, r *http.Reque
return return
} }
customer, appErr := c.App.Cloud().UpdateCloudCustomerAddress(address) customer, appErr := c.App.Cloud().UpdateCloudCustomerAddress(c.App.Session().UserId, address)
if appErr != nil { if appErr != nil {
c.Err = model.NewAppError("Api4.updateCloudCustomerAddress", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.updateCloudCustomerAddress", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError)
return return
@@ -242,9 +241,9 @@ func createCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) {
auditRec := c.MakeAuditRecord("createCustomerPayment", audit.Fail) auditRec := c.MakeAuditRecord("createCustomerPayment", audit.Fail)
defer c.LogAuditRec(auditRec) defer c.LogAuditRec(auditRec)
intent, appErr := c.App.Cloud().CreateCustomerPayment() intent, err := c.App.Cloud().CreateCustomerPayment(c.App.Session().UserId)
if appErr != nil { if err != nil {
c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -285,9 +284,9 @@ func confirmCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request)
return return
} }
appErr := c.App.Cloud().ConfirmCustomerPayment(confirmRequest) err = c.App.Cloud().ConfirmCustomerPayment(c.App.Session().UserId, confirmRequest)
if appErr != nil { if err != nil {
c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -307,7 +306,7 @@ func getInvoicesForSubscription(c *Context, w http.ResponseWriter, r *http.Reque
return return
} }
invoices, appErr := c.App.Cloud().GetInvoicesForSubscription() invoices, appErr := c.App.Cloud().GetInvoicesForSubscription(c.App.Session().UserId)
if appErr != nil { if appErr != nil {
c.Err = model.NewAppError("Api4.getInvoicesForSubscription", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.getInvoicesForSubscription", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError)
return return
@@ -338,7 +337,7 @@ func getSubscriptionInvoicePDF(c *Context, w http.ResponseWriter, r *http.Reques
return 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 { if appErr != nil {
c.Err = model.NewAppError("Api4.getSuscriptionInvoicePDF", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.getSuscriptionInvoicePDF", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError)
return return
@@ -398,20 +397,20 @@ func sendAdminUpgradeRequestEmail(c *Context, w http.ResponseWriter, r *http.Req
return return
} }
user, err := c.App.GetUser(c.App.Session().UserId) user, appErr := c.App.GetUser(c.App.Session().UserId)
if err != nil { if appErr != nil {
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", err.Id, nil, err.Error(), err.StatusCode) c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", appErr.Id, nil, appErr.Error(), appErr.StatusCode)
return return
} }
sub, err := c.App.Cloud().GetSubscription() sub, err := c.App.Cloud().GetSubscription(c.App.Session().UserId)
if err != nil { if err != nil {
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
return return
} }
if err = c.App.SendAdminUpgradeRequestEmail(user.Username, sub, model.InviteLimitation); err != nil { if appErr = c.App.SendAdminUpgradeRequestEmail(user.Username, sub, model.InviteLimitation); appErr != nil {
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", err.Id, nil, err.Error(), err.StatusCode) c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", appErr.Id, nil, appErr.Error(), appErr.StatusCode)
return return
} }
@@ -424,14 +423,14 @@ func sendAdminUpgradeRequestEmailOnJoin(c *Context, w http.ResponseWriter, r *ht
return return
} }
sub, err := c.App.Cloud().GetSubscription() sub, err := c.App.Cloud().GetSubscription("")
if err != nil { if err != nil {
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmailOnJoin", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmailOnJoin", "api.cloud.request_error", nil, err.Error(), http.StatusInternalServerError)
return return
} }
if err = c.App.SendAdminUpgradeRequestEmail("", sub, model.JoinLimitation); err != nil { if appErr := c.App.SendAdminUpgradeRequestEmail("", sub, model.JoinLimitation); appErr != nil {
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", err.Id, nil, err.Error(), err.StatusCode) c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", appErr.Id, nil, appErr.Error(), appErr.StatusCode)
return return
} }

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

@@ -1206,9 +1206,14 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit
var invitesOverLimit []*model.EmailInviteWithError var invitesOverLimit []*model.EmailInviteWithError
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && cloudUserLimit > 0 { 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 { if subErr != nil {
c.Err = subErr c.Err = model.NewAppError(
"Api4.inviteUsersToTeam",
"api.team.cloud.subscription.error",
nil,
subErr.Error(),
http.StatusInternalServerError)
return return
} }
if subscription == nil || subscription.IsPaidTier != "true" { 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 cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit
var invitesOverLimit []*model.EmailInviteWithError var invitesOverLimit []*model.EmailInviteWithError
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && cloudUserLimit > 0 && c.IsSystemAdmin() { if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && cloudUserLimit > 0 && c.IsSystemAdmin() {
subscription, subErr := c.App.Cloud().GetSubscription() subscription, err := c.App.Cloud().GetSubscription(c.App.Session().UserId)
if subErr != nil { if err != nil {
c.Err = subErr c.Err = model.NewAppError(
"Api4.inviteGuestsToChannel",
"api.team.cloud.subscription.error",
nil,
err.Error(),
http.StatusInternalServerError)
return return
} }
if subscription == nil || subscription.IsPaidTier != "true" { if subscription == nil || subscription.IsPaidTier != "true" {

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

@@ -84,9 +84,14 @@ func (a *App) CheckAndSendUserLimitWarningEmails() *model.AppError {
return nil return nil
} }
subscription, subErr := a.Cloud().GetSubscription() subscription, err := a.Cloud().GetSubscription(a.Session().UserId)
if subErr != nil { if err != nil {
return subErr return model.NewAppError(
"app.CheckAndSendUserLimitWarningEmails",
"api.cloud.get_subscription.error",
nil,
err.Error(),
http.StatusInternalServerError)
} }
if subscription != nil && subscription.IsPaidTier == "true" { if subscription != nil && subscription.IsPaidTier == "true" {
@@ -101,21 +106,40 @@ func (a *App) CheckAndSendUserLimitWarningEmails() *model.AppError {
if remainingUsers > 0 { if remainingUsers > 0 {
return nil return nil
} }
sysAdmins, err := a.getSysAdminsEmailRecipients() sysAdmins, appErr := a.getSysAdminsEmailRecipients()
if err != nil { if appErr != nil {
return err 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 // -1 means they are 1 user over the limit - we only want to send the email for the 11th user
if remainingUsers == -1 { if remainingUsers == -1 {
// Over limit by 1 user // Over limit by 1 user
for admin := range sysAdmins { 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 { } else if remainingUsers == 0 {
// At limit // At limit
for admin := range sysAdmins { 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 return nil

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

@@ -150,9 +150,9 @@ func RegisterMessageExportInterface(f func(*Server) einterfaces.MessageExportInt
messageExportInterface = f 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 cloudInterface = f
} }
@@ -217,7 +217,4 @@ func (a *App) initEnterprise() {
} }
}) })
} }
if cloudInterface != nil {
a.srv.Cloud = cloudInterface(a)
}
} }

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

@@ -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) s.telemetryService = telemetry.New(s, s.Store, s.SearchEngine, s.Log)
emailService, err := NewEmailService(s) emailService, err := NewEmailService(s)

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

@@ -8,16 +8,16 @@ import (
) )
type CloudInterface interface { type CloudInterface interface {
GetCloudProducts() ([]*model.Product, *model.AppError) GetCloudProducts(userID string) ([]*model.Product, error)
CreateCustomerPayment() (*model.StripeSetupIntent, *model.AppError) CreateCustomerPayment(userID string) (*model.StripeSetupIntent, error)
ConfirmCustomerPayment(*model.ConfirmPaymentMethodRequest) *model.AppError ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error
GetCloudCustomer() (*model.CloudCustomer, *model.AppError) GetCloudCustomer(userID string) (*model.CloudCustomer, error)
UpdateCloudCustomer(customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, *model.AppError) UpdateCloudCustomer(userID string, customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, error)
UpdateCloudCustomerAddress(address *model.Address) (*model.CloudCustomer, *model.AppError) UpdateCloudCustomerAddress(userID string, address *model.Address) (*model.CloudCustomer, error)
GetSubscription() (*model.Subscription, *model.AppError) GetSubscription(userID string) (*model.Subscription, error)
GetInvoicesForSubscription() ([]*model.Invoice, *model.AppError) GetInvoicesForSubscription(userID string) ([]*model.Invoice, error)
GetInvoicePDF(invoiceID string) ([]byte, string, *model.AppError) GetInvoicePDF(userID, invoiceID string) ([]byte, string, error)
} }

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

@@ -14,104 +14,96 @@ type CloudInterface struct {
mock.Mock mock.Mock
} }
// ConfirmCustomerPayment provides a mock function with given fields: _a0 // ConfirmCustomerPayment provides a mock function with given fields: userID, confirmRequest
func (_m *CloudInterface) ConfirmCustomerPayment(_a0 *model.ConfirmPaymentMethodRequest) *model.AppError { func (_m *CloudInterface) ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error {
ret := _m.Called(_a0) ret := _m.Called(userID, confirmRequest)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(*model.ConfirmPaymentMethodRequest) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string, *model.ConfirmPaymentMethodRequest) error); ok {
r0 = rf(_a0) r0 = rf(userID, confirmRequest)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
} }
// CreateCustomerPayment provides a mock function with given fields: // CreateCustomerPayment provides a mock function with given fields: userID
func (_m *CloudInterface) CreateCustomerPayment() (*model.StripeSetupIntent, *model.AppError) { func (_m *CloudInterface) CreateCustomerPayment(userID string) (*model.StripeSetupIntent, error) {
ret := _m.Called() ret := _m.Called(userID)
var r0 *model.StripeSetupIntent var r0 *model.StripeSetupIntent
if rf, ok := ret.Get(0).(func() *model.StripeSetupIntent); ok { if rf, ok := ret.Get(0).(func(string) *model.StripeSetupIntent); ok {
r0 = rf() r0 = rf(userID)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.StripeSetupIntent) r0 = ret.Get(0).(*model.StripeSetupIntent)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func() *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf() r1 = rf(userID)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetCloudCustomer provides a mock function with given fields: // GetCloudCustomer provides a mock function with given fields: userID
func (_m *CloudInterface) GetCloudCustomer() (*model.CloudCustomer, *model.AppError) { func (_m *CloudInterface) GetCloudCustomer(userID string) (*model.CloudCustomer, error) {
ret := _m.Called() ret := _m.Called(userID)
var r0 *model.CloudCustomer var r0 *model.CloudCustomer
if rf, ok := ret.Get(0).(func() *model.CloudCustomer); ok { if rf, ok := ret.Get(0).(func(string) *model.CloudCustomer); ok {
r0 = rf() r0 = rf(userID)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.CloudCustomer) r0 = ret.Get(0).(*model.CloudCustomer)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func() *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf() r1 = rf(userID)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetCloudProducts provides a mock function with given fields: // GetCloudProducts provides a mock function with given fields: userID
func (_m *CloudInterface) GetCloudProducts() ([]*model.Product, *model.AppError) { func (_m *CloudInterface) GetCloudProducts(userID string) ([]*model.Product, error) {
ret := _m.Called() ret := _m.Called(userID)
var r0 []*model.Product var r0 []*model.Product
if rf, ok := ret.Get(0).(func() []*model.Product); ok { if rf, ok := ret.Get(0).(func(string) []*model.Product); ok {
r0 = rf() r0 = rf(userID)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.Product) r0 = ret.Get(0).([]*model.Product)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func() *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf() r1 = rf(userID)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetInvoicePDF provides a mock function with given fields: invoiceID // GetInvoicePDF provides a mock function with given fields: userID, invoiceID
func (_m *CloudInterface) GetInvoicePDF(invoiceID string) ([]byte, string, *model.AppError) { func (_m *CloudInterface) GetInvoicePDF(userID string, invoiceID string) ([]byte, string, error) {
ret := _m.Called(invoiceID) ret := _m.Called(userID, invoiceID)
var r0 []byte var r0 []byte
if rf, ok := ret.Get(0).(func(string) []byte); ok { if rf, ok := ret.Get(0).(func(string, string) []byte); ok {
r0 = rf(invoiceID) r0 = rf(userID, invoiceID)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).([]byte) r0 = ret.Get(0).([]byte)
@@ -119,119 +111,109 @@ func (_m *CloudInterface) GetInvoicePDF(invoiceID string) ([]byte, string, *mode
} }
var r1 string var r1 string
if rf, ok := ret.Get(1).(func(string) string); ok { if rf, ok := ret.Get(1).(func(string, string) string); ok {
r1 = rf(invoiceID) r1 = rf(userID, invoiceID)
} else { } else {
r1 = ret.Get(1).(string) r1 = ret.Get(1).(string)
} }
var r2 *model.AppError var r2 error
if rf, ok := ret.Get(2).(func(string) *model.AppError); ok { if rf, ok := ret.Get(2).(func(string, string) error); ok {
r2 = rf(invoiceID) r2 = rf(userID, invoiceID)
} else { } else {
if ret.Get(2) != nil { r2 = ret.Error(2)
r2 = ret.Get(2).(*model.AppError)
}
} }
return r0, r1, r2 return r0, r1, r2
} }
// GetInvoicesForSubscription provides a mock function with given fields: // GetInvoicesForSubscription provides a mock function with given fields: userID
func (_m *CloudInterface) GetInvoicesForSubscription() ([]*model.Invoice, *model.AppError) { func (_m *CloudInterface) GetInvoicesForSubscription(userID string) ([]*model.Invoice, error) {
ret := _m.Called() ret := _m.Called(userID)
var r0 []*model.Invoice var r0 []*model.Invoice
if rf, ok := ret.Get(0).(func() []*model.Invoice); ok { if rf, ok := ret.Get(0).(func(string) []*model.Invoice); ok {
r0 = rf() r0 = rf(userID)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.Invoice) r0 = ret.Get(0).([]*model.Invoice)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func() *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf() r1 = rf(userID)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetSubscription provides a mock function with given fields: // GetSubscription provides a mock function with given fields: userID
func (_m *CloudInterface) GetSubscription() (*model.Subscription, *model.AppError) { func (_m *CloudInterface) GetSubscription(userID string) (*model.Subscription, error) {
ret := _m.Called() ret := _m.Called(userID)
var r0 *model.Subscription var r0 *model.Subscription
if rf, ok := ret.Get(0).(func() *model.Subscription); ok { if rf, ok := ret.Get(0).(func(string) *model.Subscription); ok {
r0 = rf() r0 = rf(userID)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.Subscription) r0 = ret.Get(0).(*model.Subscription)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func() *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf() r1 = rf(userID)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// UpdateCloudCustomer provides a mock function with given fields: customerInfo // UpdateCloudCustomer provides a mock function with given fields: userID, customerInfo
func (_m *CloudInterface) UpdateCloudCustomer(customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, *model.AppError) { func (_m *CloudInterface) UpdateCloudCustomer(userID string, customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, error) {
ret := _m.Called(customerInfo) ret := _m.Called(userID, customerInfo)
var r0 *model.CloudCustomer var r0 *model.CloudCustomer
if rf, ok := ret.Get(0).(func(*model.CloudCustomerInfo) *model.CloudCustomer); ok { if rf, ok := ret.Get(0).(func(string, *model.CloudCustomerInfo) *model.CloudCustomer); ok {
r0 = rf(customerInfo) r0 = rf(userID, customerInfo)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.CloudCustomer) r0 = ret.Get(0).(*model.CloudCustomer)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(*model.CloudCustomerInfo) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, *model.CloudCustomerInfo) error); ok {
r1 = rf(customerInfo) r1 = rf(userID, customerInfo)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// UpdateCloudCustomerAddress provides a mock function with given fields: address // UpdateCloudCustomerAddress provides a mock function with given fields: userID, address
func (_m *CloudInterface) UpdateCloudCustomerAddress(address *model.Address) (*model.CloudCustomer, *model.AppError) { func (_m *CloudInterface) UpdateCloudCustomerAddress(userID string, address *model.Address) (*model.CloudCustomer, error) {
ret := _m.Called(address) ret := _m.Called(userID, address)
var r0 *model.CloudCustomer var r0 *model.CloudCustomer
if rf, ok := ret.Get(0).(func(*model.Address) *model.CloudCustomer); ok { if rf, ok := ret.Get(0).(func(string, *model.Address) *model.CloudCustomer); ok {
r0 = rf(address) r0 = rf(userID, address)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.CloudCustomer) r0 = ret.Get(0).(*model.CloudCustomer)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(*model.Address) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, *model.Address) error); ok {
r1 = rf(address) r1 = rf(userID, address)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1

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

@@ -479,6 +479,14 @@
"id": "api.cloud.app_error", "id": "api.cloud.app_error",
"translation": "Internal error during cloud api request." "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", "id": "api.cloud.license_error",
"translation": "Your license does not support cloud requests." "translation": "Your license does not support cloud requests."
@@ -2434,6 +2442,10 @@
"id": "api.team.add_user_to_team_from_invite.guest.app_error", "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." "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", "id": "api.team.demote_user_to_guest.disabled.error",
"translation": "Guest accounts are disabled." "translation": "Guest accounts are disabled."
@@ -6247,16 +6259,8 @@
"translation": " attached a file." "translation": " attached a file."
}, },
{ {
"id": "ent.cloud.authentication_failed", "id": "ent.cloud.subscription.error",
"translation": "Unable to authenticate to CWS" "translation": "Error getting cloud subscription"
},
{
"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.cluster.404.app_error", "id": "ent.cluster.404.app_error",