fix: refs for db provider and few utils

This commit is contained in:
Lakhan Samani
2023-07-31 16:42:11 +05:30
parent 146561bacb
commit 15a4be5431
82 changed files with 394 additions and 533 deletions

View File

@@ -7,7 +7,7 @@ import (
// GetPagination helps getting pagination data from paginated input
// also returns default limit and offset if pagination data is not present
func GetPagination(paginatedInput *model.PaginatedInput) model.Pagination {
func GetPagination(paginatedInput *model.PaginatedInput) *model.Pagination {
limit := int64(constants.DefaultLimit)
page := int64(1)
@@ -21,7 +21,7 @@ func GetPagination(paginatedInput *model.PaginatedInput) model.Pagination {
}
}
return model.Pagination{
return &model.Pagination{
Limit: limit,
Offset: (page - 1) * limit,
Page: page,

View File

@@ -18,10 +18,10 @@ import (
// RegisterEvent util to register event
// TODO change user to user ref
func RegisterEvent(ctx context.Context, eventName string, authRecipe string, user models.User) error {
func RegisterEvent(ctx context.Context, eventName string, authRecipe string, user *models.User) error {
webhooks, err := db.Provider.GetWebhookByEventName(ctx, eventName)
if err != nil {
log.Debug("Error getting webhook: %v", err)
log.Debug("error getting webhook: %v", err)
return err
}
for _, webhook := range webhooks {
@@ -63,7 +63,7 @@ func RegisterEvent(ctx context.Context, eventName string, authRecipe string, use
continue
}
if envKey == constants.TestEnv {
_, err := db.Provider.AddWebhookLog(ctx, models.WebhookLog{
_, err := db.Provider.AddWebhookLog(ctx, &models.WebhookLog{
HttpStatus: 200,
Request: string(requestBody),
Response: string(`{"message": "test"}`),
@@ -104,7 +104,7 @@ func RegisterEvent(ctx context.Context, eventName string, authRecipe string, use
}
statusCode := int64(resp.StatusCode)
_, err = db.Provider.AddWebhookLog(ctx, models.WebhookLog{
_, err = db.Provider.AddWebhookLog(ctx, &models.WebhookLog{
HttpStatus: statusCode,
Request: string(requestBody),
Response: string(responseBytes),