Skip to content

Commit 0444afe

Browse files
committed
fix: use free tier perks when dashboard user doesn't exist
1 parent 6e0066f commit 0444afe

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

backend/pkg/api/data_access/data_access.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/gobitfly/beaconchain/pkg/commons/log"
1515
"github.com/gobitfly/beaconchain/pkg/commons/types"
1616
"github.com/jmoiron/sqlx"
17-
"github.com/pkg/errors"
1817
)
1918

2019
type DataAccessor interface {
@@ -202,4 +201,4 @@ func (d *DataAccessService) Close() {
202201
}
203202
}
204203

205-
var ErrNotFound = errors.New("not found")
204+
var ErrNotFound = db.ErrNotFound

backend/pkg/api/handlers/handler_service.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ func (h *HandlerService) getDashboardPremiumPerks(ctx context.Context, id types.
207207
}
208208
userInfo, err := h.daService.GetUserInfo(ctx, dashboardUser.UserId)
209209
if err != nil {
210+
if errors.Is(err, dataaccess.ErrNotFound) {
211+
log.Warn("user not found for dashboard owner, returning free tier perks", log.Fields{"dashboard_id": id.Id, "user_id_of_dashboard": dashboardUser.UserId})
212+
perk, err := h.daService.GetFreeTierPerks(ctx)
213+
if err != nil {
214+
return nil, err
215+
}
216+
return perk, nil
217+
}
210218
return nil, err
211219
}
212220

0 commit comments

Comments
 (0)