fixed wallet listing ignoring org reference

This commit is contained in:
Stephan D
2026-01-14 17:25:21 +01:00
parent 62bc2644d4
commit 343911ebe7
33 changed files with 408 additions and 304 deletions

View File

@@ -70,7 +70,7 @@ type ManagedWalletFilter struct {
// ManagedWalletList contains paginated wallet results.
type ManagedWalletList struct {
Items []*ManagedWallet
Items []ManagedWallet
NextCursor string
}

View File

@@ -14,6 +14,7 @@ import (
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/mlogger"
"github.com/tech/sendico/pkg/mservice"
mutil "github.com/tech/sendico/pkg/mutil/db"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.uber.org/zap"
@@ -184,17 +185,7 @@ func (w *Wallets) List(ctx context.Context, filter model.ManagedWalletFilter) (*
fetchLimit := limit + 1
query = query.Sort(repository.IDField(), true).Limit(&fetchLimit)
wallets := make([]*model.ManagedWallet, 0, fetchLimit)
decoder := func(cur *mongo.Cursor) error {
item := &model.ManagedWallet{}
if err := cur.Decode(item); err != nil {
return err
}
wallets = append(wallets, item)
return nil
}
listErr := w.walletRepo.FindManyByFilter(ctx, query, decoder)
wallets, listErr := mutil.GetObjects[model.ManagedWallet](ctx, w.logger, query, nil, w.walletRepo)
if listErr != nil && !errors.Is(listErr, merrors.ErrNoData) {
w.logger.Warn("Wallet list failed", append(fields, zap.Error(listErr))...)
return nil, listErr