Skip to content

Commit

Permalink
increase the limit of rwebhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed May 11, 2024
1 parent 79ae901 commit 3610762
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions api/pkg/handlers/webhook_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ func (h *WebhookHandler) Store(c *fiber.Ctx) error {
return h.responseUnprocessableEntity(c, errors, "validation errors while storing webhook")
}

webhooks, err := h.service.Index(ctx, h.userIDFomContext(c), repositories.IndexParams{Skip: 0, Limit: 3})
webhooks, err := h.service.Index(ctx, h.userIDFomContext(c), repositories.IndexParams{Skip: 0, Limit: 10})
if err != nil {
ctxLogger.Error(stacktrace.Propagate(err, fmt.Sprintf("cannot index webhooks for user [%s]", h.userIDFomContext(c))))
return h.responsePaymentRequired(c, "You can't create more than 1 webhook contact us to upgrade your account.")
return h.responseInternalServerError(c)
}

if len(webhooks) > 1 {
ctxLogger.Warn(stacktrace.NewError(fmt.Sprintf("user with ID [%s] wants to create more than 2 webhooks", h.userIDFomContext(c))))
return h.responsePaymentRequired(c, "You can't create more than 2 webhooks contact us to upgrade your account.")
if len(webhooks) == 10 {
ctxLogger.Warn(stacktrace.NewError(fmt.Sprintf("user with ID [%s] wants to create more than 5 webhooks", h.userIDFomContext(c))))
return h.responsePaymentRequired(c, "You can't create more than 10 webhooks contact us to upgrade to our enterprise plan.")
}

webhook, err := h.service.Store(ctx, request.ToStoreParams(h.userFromContext(c)))
Expand Down
4 changes: 2 additions & 2 deletions api/pkg/services/webhook_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (service *WebhookService) Index(ctx context.Context, userID entities.UserID
return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
}

ctxLogger.Info(fmt.Sprintf("fetched [%d] messages with prams [%+#v]", len(webhooks), params))
ctxLogger.Info(fmt.Sprintf("fetched [%d] webhooks with prams [%+#v]", len(webhooks), params))
return webhooks, nil
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func (service *WebhookService) Store(ctx context.Context, params *WebhookStorePa
return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
}

ctxLogger.Info(fmt.Sprintf("webhook saved with id [%s] in the [%T]", webhook.ID, service.repository))
ctxLogger.Info(fmt.Sprintf("webhook saved with id [%s] for user [%s] in the [%T]", webhook.ID, webhook.UserID, service.repository))
return webhook, nil
}

Expand Down

0 comments on commit 3610762

Please sign in to comment.