ultisuite-backend/internal/api/mail/webhook_scope.go
R3D347HR4Y 082cac36b2 feat(automation): dispatch rules/webhooks on mail, drive, contacts
Wire automation dispatcher to IMAP sync, drive mutations, and contact CRUD.
Add webhook event_types and mail/drive/contacts scope filters (migration 30).
2026-06-07 15:51:47 +02:00

51 lines
1.1 KiB
Go

package mail
import (
"encoding/json"
"github.com/ultisuite/ulti-backend/internal/automation"
)
func marshalWebhookEventTypes(types []string) ([]byte, error) {
if types == nil {
types = []string{}
}
return json.Marshal(types)
}
func marshalWebhookMailScope(scope *webhookMailScope) ([]byte, error) {
out := automation.MailScope{AllAccounts: true}
if scope != nil {
out.AllAccounts = scope.AllAccounts
out.AccountIDs = scope.AccountIDs
if out.AccountIDs == nil {
out.AccountIDs = []string{}
}
}
return json.Marshal(out)
}
func marshalWebhookDriveScope(scope *webhookDriveScope) ([]byte, error) {
out := automation.DriveScope{AllFolders: true}
if scope != nil {
out.AllFolders = scope.AllFolders
out.FolderPaths = scope.FolderPaths
if out.FolderPaths == nil {
out.FolderPaths = []string{}
}
}
return json.Marshal(out)
}
func marshalWebhookContactsScope(scope *webhookContactsScope) ([]byte, error) {
out := automation.ContactsScope{AllBooks: true}
if scope != nil {
out.AllBooks = scope.AllBooks
out.BookIDs = scope.BookIDs
if out.BookIDs == nil {
out.BookIDs = []string{}
}
}
return json.Marshal(out)
}