bff for callbacks
This commit is contained in:
36
api/pkg/db/internal/mongo/callbacksdb/list.go
Normal file
36
api/pkg/db/internal/mongo/callbacksdb/list.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package callbacksdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/repository"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
mauth "github.com/tech/sendico/pkg/mutil/db/auth"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
func (db *CallbacksDB) List(
|
||||
ctx context.Context,
|
||||
accountRef,
|
||||
organizationRef,
|
||||
_ bson.ObjectID,
|
||||
cursor *model.ViewCursor,
|
||||
) ([]model.Callback, error) {
|
||||
res, err := mauth.GetProtectedObjects[model.Callback](
|
||||
ctx,
|
||||
db.DBImp.Logger,
|
||||
accountRef,
|
||||
organizationRef,
|
||||
model.ActionRead,
|
||||
repository.OrgFilter(organizationRef),
|
||||
cursor,
|
||||
db.Enforcer,
|
||||
db.DBImp.Repository,
|
||||
)
|
||||
if errors.Is(err, merrors.ErrNoData) {
|
||||
return []model.Callback{}, nil
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user