remove webhook queries in favor of using existing ones that ignore deleted webhooks, enforce not implemented for cloud users, get seats from license.features.users.
Этот коммит содержится в:
@@ -313,21 +313,9 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var subscription *model.Subscription
|
if c.App.Cloud() == nil {
|
||||||
var err error
|
c.Err = model.NewAppError("cloudTrueUpReviewNotAllowed", "app.job.true_up_review_not_allowd", nil, "", http.StatusNotImplemented)
|
||||||
if c.App.Cloud() != nil {
|
return
|
||||||
// Subscription Data
|
|
||||||
userId := c.AppContext.Session().UserId
|
|
||||||
subscription, err = c.App.Cloud().GetSubscription(userId)
|
|
||||||
if err != nil || subscription == nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
seats := 0
|
|
||||||
if subscription != nil {
|
|
||||||
seats = subscription.Seats
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Customer Info & Usage Analytics
|
// Customer Info & Usage Analytics
|
||||||
@@ -338,12 +326,12 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Webhook, calls, boards, and playbook counts
|
// Webhook, calls, boards, and playbook counts
|
||||||
incomingWebhookCount, err := c.App.Srv().Store().Webhook().GetIncomingTotal()
|
incomingWebhookCount, err := c.App.Srv().Store().Webhook().AnalyticsIncomingCount("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
outgoingWebhookCount, err := c.App.Srv().Store().Webhook().GetOutgoingTotal()
|
outgoingWebhookCount, err := c.App.Srv().Store().Webhook().AnalyticsOutgoingCount("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -395,7 +383,7 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
ServerVersion: model.CurrentVersion,
|
ServerVersion: model.CurrentVersion,
|
||||||
ServerInstallationType: os.Getenv(telemetry.EnvVarInstallType),
|
ServerInstallationType: os.Getenv(telemetry.EnvVarInstallType),
|
||||||
LicenseId: license.Id,
|
LicenseId: license.Id,
|
||||||
LicensedSeats: seats,
|
LicensedSeats: *license.Features.Users,
|
||||||
LicensePlan: license.SkuName,
|
LicensePlan: license.SkuName,
|
||||||
CustomerName: license.Customer.Name,
|
CustomerName: license.Customer.Name,
|
||||||
ActiveUsers: activeUserCount,
|
ActiveUsers: activeUserCount,
|
||||||
|
|||||||
@@ -12480,24 +12480,6 @@ func (s *OpenTracingLayerWebhookStore) GetIncomingListByUser(userID string, offs
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerWebhookStore) GetIncomingTotal() (int64, error) {
|
|
||||||
origCtx := s.Root.Store.Context()
|
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "WebhookStore.GetIncomingTotal")
|
|
||||||
s.Root.Store.SetContext(newCtx)
|
|
||||||
defer func() {
|
|
||||||
s.Root.Store.SetContext(origCtx)
|
|
||||||
}()
|
|
||||||
|
|
||||||
defer span.Finish()
|
|
||||||
result, err := s.WebhookStore.GetIncomingTotal()
|
|
||||||
if err != nil {
|
|
||||||
span.LogFields(spanlog.Error(err))
|
|
||||||
ext.Error.Set(span, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *OpenTracingLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
func (s *OpenTracingLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "WebhookStore.GetOutgoing")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "WebhookStore.GetOutgoing")
|
||||||
@@ -12624,24 +12606,6 @@ func (s *OpenTracingLayerWebhookStore) GetOutgoingListByUser(userID string, offs
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerWebhookStore) GetOutgoingTotal() (int64, error) {
|
|
||||||
origCtx := s.Root.Store.Context()
|
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "WebhookStore.GetOutgoingTotal")
|
|
||||||
s.Root.Store.SetContext(newCtx)
|
|
||||||
defer func() {
|
|
||||||
s.Root.Store.SetContext(origCtx)
|
|
||||||
}()
|
|
||||||
|
|
||||||
defer span.Finish()
|
|
||||||
result, err := s.WebhookStore.GetOutgoingTotal()
|
|
||||||
if err != nil {
|
|
||||||
span.LogFields(spanlog.Error(err))
|
|
||||||
ext.Error.Set(span, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *OpenTracingLayerWebhookStore) InvalidateWebhookCache(webhook string) {
|
func (s *OpenTracingLayerWebhookStore) InvalidateWebhookCache(webhook string) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "WebhookStore.InvalidateWebhookCache")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "WebhookStore.InvalidateWebhookCache")
|
||||||
|
|||||||
@@ -14232,27 +14232,6 @@ func (s *RetryLayerWebhookStore) GetIncomingListByUser(userID string, offset int
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RetryLayerWebhookStore) GetIncomingTotal() (int64, error) {
|
|
||||||
|
|
||||||
tries := 0
|
|
||||||
for {
|
|
||||||
result, err := s.WebhookStore.GetIncomingTotal()
|
|
||||||
if err == nil {
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
if !isRepeatableError(err) {
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
tries++
|
|
||||||
if tries >= 3 {
|
|
||||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *RetryLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
func (s *RetryLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
||||||
|
|
||||||
tries := 0
|
tries := 0
|
||||||
@@ -14400,27 +14379,6 @@ func (s *RetryLayerWebhookStore) GetOutgoingListByUser(userID string, offset int
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RetryLayerWebhookStore) GetOutgoingTotal() (int64, error) {
|
|
||||||
|
|
||||||
tries := 0
|
|
||||||
for {
|
|
||||||
result, err := s.WebhookStore.GetOutgoingTotal()
|
|
||||||
if err == nil {
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
if !isRepeatableError(err) {
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
tries++
|
|
||||||
if tries >= 3 {
|
|
||||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *RetryLayerWebhookStore) InvalidateWebhookCache(webhook string) {
|
func (s *RetryLayerWebhookStore) InvalidateWebhookCache(webhook string) {
|
||||||
|
|
||||||
s.WebhookStore.InvalidateWebhookCache(webhook)
|
s.WebhookStore.InvalidateWebhookCache(webhook)
|
||||||
|
|||||||
@@ -400,39 +400,3 @@ func (s SqlWebhookStore) AnalyticsOutgoingCount(teamId string) (int64, error) {
|
|||||||
}
|
}
|
||||||
return count, nil
|
return count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) GetIncomingTotal() (int64, error) {
|
|
||||||
queryBuilder :=
|
|
||||||
s.getQueryBuilder().
|
|
||||||
Select("COUNT(*)").
|
|
||||||
From("IncomingWebhooks")
|
|
||||||
|
|
||||||
queryString, args, err := queryBuilder.ToSql()
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.Wrap(err, "incoming_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
var count int64
|
|
||||||
if err := s.GetReplicaX().Get(&count, queryString, args...); err != nil {
|
|
||||||
return 0, errors.Wrap(err, "failed to count total IncomingWebooks")
|
|
||||||
}
|
|
||||||
return count, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s SqlWebhookStore) GetOutgoingTotal() (int64, error) {
|
|
||||||
queryBuilder :=
|
|
||||||
s.getQueryBuilder().
|
|
||||||
Select("COUNT(*)").
|
|
||||||
From("OutgoingWebhooks")
|
|
||||||
|
|
||||||
queryString, args, err := queryBuilder.ToSql()
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.Wrap(err, "outgoing_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
var count int64
|
|
||||||
if err := s.GetReplicaX().Get(&count, queryString, args...); err != nil {
|
|
||||||
return 0, errors.Wrap(err, "failed to count total OutgoingWebhooks")
|
|
||||||
}
|
|
||||||
return count, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -615,9 +615,6 @@ type WebhookStore interface {
|
|||||||
AnalyticsOutgoingCount(teamID string) (int64, error)
|
AnalyticsOutgoingCount(teamID string) (int64, error)
|
||||||
InvalidateWebhookCache(webhook string)
|
InvalidateWebhookCache(webhook string)
|
||||||
ClearCaches()
|
ClearCaches()
|
||||||
|
|
||||||
GetOutgoingTotal() (int64, error)
|
|
||||||
GetIncomingTotal() (int64, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandStore interface {
|
type CommandStore interface {
|
||||||
|
|||||||
@@ -227,27 +227,6 @@ func (_m *WebhookStore) GetIncomingListByUser(userID string, offset int, limit i
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIncomingTotal provides a mock function with given fields:
|
|
||||||
func (_m *WebhookStore) GetIncomingTotal() (int64, error) {
|
|
||||||
ret := _m.Called()
|
|
||||||
|
|
||||||
var r0 int64
|
|
||||||
if rf, ok := ret.Get(0).(func() int64); ok {
|
|
||||||
r0 = rf()
|
|
||||||
} else {
|
|
||||||
r0 = ret.Get(0).(int64)
|
|
||||||
}
|
|
||||||
|
|
||||||
var r1 error
|
|
||||||
if rf, ok := ret.Get(1).(func() error); ok {
|
|
||||||
r1 = rf()
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOutgoing provides a mock function with given fields: id
|
// GetOutgoing provides a mock function with given fields: id
|
||||||
func (_m *WebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
func (_m *WebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
||||||
ret := _m.Called(id)
|
ret := _m.Called(id)
|
||||||
@@ -409,27 +388,6 @@ func (_m *WebhookStore) GetOutgoingListByUser(userID string, offset int, limit i
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOutgoingTotal provides a mock function with given fields:
|
|
||||||
func (_m *WebhookStore) GetOutgoingTotal() (int64, error) {
|
|
||||||
ret := _m.Called()
|
|
||||||
|
|
||||||
var r0 int64
|
|
||||||
if rf, ok := ret.Get(0).(func() int64); ok {
|
|
||||||
r0 = rf()
|
|
||||||
} else {
|
|
||||||
r0 = ret.Get(0).(int64)
|
|
||||||
}
|
|
||||||
|
|
||||||
var r1 error
|
|
||||||
if rf, ok := ret.Get(1).(func() error); ok {
|
|
||||||
r1 = rf()
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
|
||||||
|
|
||||||
// InvalidateWebhookCache provides a mock function with given fields: webhook
|
// InvalidateWebhookCache provides a mock function with given fields: webhook
|
||||||
func (_m *WebhookStore) InvalidateWebhookCache(webhook string) {
|
func (_m *WebhookStore) InvalidateWebhookCache(webhook string) {
|
||||||
_m.Called(webhook)
|
_m.Called(webhook)
|
||||||
|
|||||||
@@ -11240,22 +11240,6 @@ func (s *TimerLayerWebhookStore) GetIncomingListByUser(userID string, offset int
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerWebhookStore) GetIncomingTotal() (int64, error) {
|
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
result, err := s.WebhookStore.GetIncomingTotal()
|
|
||||||
|
|
||||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
|
||||||
if s.Root.Metrics != nil {
|
|
||||||
success := "false"
|
|
||||||
if err == nil {
|
|
||||||
success = "true"
|
|
||||||
}
|
|
||||||
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingTotal", success, elapsed)
|
|
||||||
}
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *TimerLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
func (s *TimerLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
@@ -11368,22 +11352,6 @@ func (s *TimerLayerWebhookStore) GetOutgoingListByUser(userID string, offset int
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerWebhookStore) GetOutgoingTotal() (int64, error) {
|
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
result, err := s.WebhookStore.GetOutgoingTotal()
|
|
||||||
|
|
||||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
|
||||||
if s.Root.Metrics != nil {
|
|
||||||
success := "false"
|
|
||||||
if err == nil {
|
|
||||||
success = "true"
|
|
||||||
}
|
|
||||||
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingTotal", success, elapsed)
|
|
||||||
}
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *TimerLayerWebhookStore) InvalidateWebhookCache(webhook string) {
|
func (s *TimerLayerWebhookStore) InvalidateWebhookCache(webhook string) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user