fixed doc env vars + mongo v2 migration
This commit is contained in:
@@ -7,11 +7,11 @@ import (
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/mutil/mzap"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func SetArchived[T storable.Storable](ctx context.Context, logger mlogger.Logger, newArchived bool, objectRef primitive.ObjectID, repo repository.Repository) error {
|
||||
func SetArchived[T storable.Storable](ctx context.Context, logger mlogger.Logger, newArchived bool, objectRef bson.ObjectID, repo repository.Repository) error {
|
||||
objs, err := GetObjects[T](ctx, logger, repository.IDFilter(objectRef), nil, repo)
|
||||
if err != nil {
|
||||
logger.Warn("Failed to fetch object", zap.Error(err), mzap.ObjRef("object_ref", objectRef))
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/tech/sendico/pkg/db/repository/builder"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
mutil "github.com/tech/sendico/pkg/mutil/db"
|
||||
"github.com/tech/sendico/pkg/mutil/mzap"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -40,7 +40,7 @@ import (
|
||||
func GetAccountBoundObjects[T any](
|
||||
ctx context.Context,
|
||||
logger mlogger.Logger,
|
||||
accountRef, organizationRef primitive.ObjectID,
|
||||
accountRef, organizationRef bson.ObjectID,
|
||||
filter builder.Query,
|
||||
cursor *model.ViewCursor,
|
||||
enforcer auth.Enforcer,
|
||||
@@ -70,7 +70,7 @@ func GetAccountBoundObjects[T any](
|
||||
return nil, merrors.NoData("no_account_bound_objects_found")
|
||||
}
|
||||
|
||||
allowed := make([]primitive.ObjectID, 0, len(allObjects))
|
||||
allowed := make([]bson.ObjectID, 0, len(allObjects))
|
||||
for _, ref := range allObjects {
|
||||
allowed = append(allowed, *ref.GetID())
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
mutil "github.com/tech/sendico/pkg/mutil/db"
|
||||
"github.com/tech/sendico/pkg/mutil/mzap"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func GetProtectedObjects[T any](
|
||||
ctx context.Context,
|
||||
logger mlogger.Logger,
|
||||
accountRef, organizationRef primitive.ObjectID,
|
||||
accountRef, organizationRef bson.ObjectID,
|
||||
action model.Action,
|
||||
filter builder.Query,
|
||||
cursor *model.ViewCursor,
|
||||
@@ -44,7 +44,7 @@ func GetProtectedObjects[T any](
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allowed := make([]primitive.ObjectID, 0, len(res))
|
||||
allowed := make([]bson.ObjectID, 0, len(res))
|
||||
for _, ref := range refs {
|
||||
if ok := res[*ref.GetID()]; ok {
|
||||
allowed = append(allowed, *ref.GetID())
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"github.com/tech/sendico/pkg/db/repository"
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func GetObjectByID(ctx context.Context, logger mlogger.Logger, id string, val storable.Storable, repo repository.Repository) error {
|
||||
p, err := primitive.ObjectIDFromHex(id)
|
||||
p, err := bson.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
logger.Warn("Failed to decode object reference", zap.String("reference", id), zap.String("collection", val.Collection()))
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user