Skip to content

Commit

Permalink
license webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal-Delange committed Jul 25, 2024
1 parent c9a0ad5 commit 1935576
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion repositories/convoy_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (repo ConvoyRepository) ListWebhooks(ctx context.Context, organizationId st
checkPerPageLimit(ctx, len(endpoints))

if len(endpoints) == 0 {
return make([]models.Webhook, 0, 0), nil
return make([]models.Webhook, 0), nil
}

endpointMap := make(map[string]convoy.ModelsEndpointResponse)
Expand Down
2 changes: 2 additions & 0 deletions repositories/dbmodels/db_license.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type DBLicense struct {
AnalyticsEntitlement bool `db:"analytics_entitlement"`
DataEnrichment bool `db:"data_enrichment"`
UserRoles bool `db:"user_roles"`
Webhooks bool `db:"webhooks"`
}

const TABLE_LICENSES = "licenses"
Expand All @@ -43,6 +44,7 @@ func AdaptLicense(db DBLicense) (models.License, error) {
Analytics: db.AnalyticsEntitlement,
DataEnrichment: db.DataEnrichment,
UserRoles: db.UserRoles,
Webhooks: db.Webhooks,
},
}, nil
}
2 changes: 1 addition & 1 deletion repositories/license_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (repo *MarbleDbRepository) GetLicenseById(ctx context.Context, exec Executo
return SqlToModel(
ctx,
exec,
selectLicenses().Where("id = ?", licenseId),
selectLicenses().Where(squirrel.Eq{"id": licenseId}),
dbmodels.AdaptLicense,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE licenses
ADD COLUMN webhooks BOOL NOT NULL DEFAULT FALSE;

-- +goose StatementEnd
-- +goose Down
ALTER TABLE licenses
DROP COLUMN webhooks;

-- +goose StatementBegin
-- +goose StatementEnd
6 changes: 6 additions & 0 deletions usecases/license_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/checkmarble/marble-backend/models"
"github.com/checkmarble/marble-backend/repositories"
"github.com/checkmarble/marble-backend/usecases/executor_factory"
"github.com/checkmarble/marble-backend/utils"
"github.com/cockroachdb/errors"
"github.com/google/uuid"
)

Expand Down Expand Up @@ -129,6 +131,10 @@ func (usecase *PublicLicenseUseCase) ValidateLicense(ctx context.Context, licens
exec := usecase.executorFactory.NewExecutor()
license, err := usecase.licenseRepository.GetLicenseByKey(ctx, exec, licenseKey)
if err != nil {
if !errors.Is(err, models.NotFoundError) {
utils.LogAndReportSentryError(ctx, err)
}

return models.LicenseValidation{
LicenseValidationCode: models.NOT_FOUND,
}, nil
Expand Down

0 comments on commit 1935576

Please sign in to comment.