move api/server to api/edge/bff

This commit is contained in:
Stephan D
2026-02-28 00:39:20 +01:00
parent 34182af3b8
commit 98db0e4e9e
248 changed files with 406 additions and 18 deletions

View File

@@ -0,0 +1,22 @@
package recipientimp
import (
messaging "github.com/tech/sendico/pkg/messaging/envelope"
notifications "github.com/tech/sendico/pkg/messaging/notifications/object"
"github.com/tech/sendico/pkg/model"
nm "github.com/tech/sendico/pkg/model/notification"
"go.mongodb.org/mongo-driver/v2/bson"
)
func (a *RecipientAPI) notification(
recipient *model.Recipient,
actorAccountRef bson.ObjectID,
t nm.NotificationAction,
) messaging.Envelope {
objectRef := bson.NilObjectID
if recipient != nil {
objectRef = recipient.ID
}
return notifications.Object(a.Name(), actorAccountRef, a.Name(), objectRef, t)
}

View File

@@ -0,0 +1,50 @@
package recipientimp
import (
"context"
"github.com/tech/sendico/pkg/db/recipient"
"github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/mservice"
eapi "github.com/tech/sendico/server/interface/api"
"github.com/tech/sendico/server/internal/server/papitemplate"
"go.uber.org/zap"
)
type RecipientAPI struct {
papitemplate.ProtectedAPI[model.Recipient]
db recipient.DB
}
func (a *RecipientAPI) Name() mservice.Type {
return mservice.Recipients
}
func (a *RecipientAPI) Finish(_ context.Context) error {
return nil
}
func CreateAPI(a eapi.API) (*RecipientAPI, error) {
dbFactory := func() (papitemplate.ProtectedDB[model.Recipient], error) {
return a.DBFactory().NewRecipientsDB()
}
res := &RecipientAPI{}
p, err := papitemplate.CreateAPI(a, dbFactory, mservice.Organizations, mservice.Recipients)
if err != nil {
return nil, err
}
res.ProtectedAPI = *p.
WithNotifications(res.notification).
WithNoCreateNotification().
WithNoUpdateNotification().
Build()
if res.db, err = a.DBFactory().NewRecipientsDB(); err != nil {
res.Logger.Warn("Failed to create recipients database", zap.Error(err))
return nil, err
}
return res, nil
}