29 lines
753 B
Go
29 lines
753 B
Go
package invitationdb
|
|
|
|
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/bson/primitive"
|
|
)
|
|
|
|
func (db *InvitationDB) List(ctx context.Context, accountRef, organizationRef, _ primitive.ObjectID, cursor *model.ViewCursor) ([]model.Invitation, error) {
|
|
res, err := mauth.GetProtectedObjects[model.Invitation](
|
|
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.Invitation{}, nil
|
|
}
|
|
return res, err
|
|
}
|