outbox for gateways

This commit is contained in:
Stephan D
2026-02-18 01:35:28 +01:00
parent 974caf286c
commit 69531cee73
221 changed files with 12172 additions and 782 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/tech/sendico/pkg/mlogger"
pkgmodel "github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/mservice"
mutil "github.com/tech/sendico/pkg/mutil/db"
mauth "github.com/tech/sendico/pkg/mutil/db/auth"
"go.mongodb.org/mongo-driver/v2/bson"
"go.uber.org/zap"
@@ -50,7 +51,7 @@ func NewPaymentMethods(logger mlogger.Logger, repo repository.Repository, enforc
for _, def := range indexes {
if err := repo.CreateIndex(def); err != nil {
logger.Error("failed to ensure payment methods index", zap.Error(err), zap.String("collection", repo.Collection()))
logger.Error("Failed to ensure payment methods index", zap.Error(err), zap.String("collection", repo.Collection()))
return nil, err
}
}
@@ -112,6 +113,18 @@ func (p *PaymentMethods) Get(ctx context.Context, accountRef, methodRef bson.Obj
return method, nil
}
func (p *PaymentMethods) GetPrivate(ctx context.Context, methodRef bson.ObjectID) (*pkgmodel.PaymentMethod, error) {
if methodRef == bson.NilObjectID {
return nil, merrors.InvalidArgument("paymentMethodsStore: method_ref is required")
}
method := &pkgmodel.PaymentMethod{}
if err := p.repo.Get(ctx, methodRef, method); err != nil {
return nil, err
}
return method, nil
}
func (p *PaymentMethods) Update(ctx context.Context, accountRef bson.ObjectID, method *pkgmodel.PaymentMethod) error {
if method == nil {
return merrors.InvalidArgument("paymentMethodsStore: nil payment method")
@@ -193,6 +206,27 @@ func (p *PaymentMethods) List(ctx context.Context, accountRef, organizationRef,
return items, err
}
func (p *PaymentMethods) ListPrivate(ctx context.Context, organizationRef, recipientRef bson.ObjectID, cursor *pkgmodel.ViewCursor) ([]pkgmodel.PaymentMethod, error) {
if organizationRef == bson.NilObjectID {
return nil, merrors.InvalidArgument("paymentMethodsStore: organization_ref is required")
}
if recipientRef == bson.NilObjectID {
return nil, merrors.InvalidArgument("paymentMethodsStore: recipient_ref is required")
}
items, err := mutil.GetObjects[pkgmodel.PaymentMethod](
ctx,
p.logger,
repository.OrgFilter(organizationRef).And(repository.Filter("recipientRef", recipientRef)),
cursor,
p.repo,
)
if errors.Is(err, merrors.ErrNoData) {
return []pkgmodel.PaymentMethod{}, nil
}
return items, err
}
func (p *PaymentMethods) SetArchivedByRecipient(ctx context.Context, recipientRef bson.ObjectID, archived bool) (int, error) {
if recipientRef == bson.NilObjectID {
return 0, merrors.InvalidArgument("paymentMethodsStore: recipient_ref is required")