Skip to content

Commit

Permalink
fix: use free tier perks when dashboard user doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly committed Jan 14, 2025
1 parent a5fe199 commit 7c068f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions backend/pkg/api/data_access/data_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/types"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
)

type DataAccessor interface {
Expand Down Expand Up @@ -202,4 +201,4 @@ func (d *DataAccessService) Close() {
}
}

var ErrNotFound = errors.New("not found")
var ErrNotFound = db.ErrNotFound
8 changes: 8 additions & 0 deletions backend/pkg/api/handlers/handler_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ func (h *HandlerService) getDashboardPremiumPerks(ctx context.Context, id types.
}
userInfo, err := h.daService.GetUserInfo(ctx, dashboardUser.UserId)
if err != nil {
if errors.Is(err, dataaccess.ErrNotFound) {
log.Warn("user not found for dashboard owner, returning free tier perks", log.Fields{"dashboard_id": id.Id, "user_id_of_dashboard": dashboardUser.UserId})
perk, err := h.daService.GetFreeTierPerks(ctx)
if err != nil {
return nil, err
}
return perk, nil
}
return nil, err
}

Expand Down

0 comments on commit 7c068f4

Please sign in to comment.