ultisuite-backend/internal/api/contacts/automation_hooks.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

32 lines
800 B
Go

package contacts
import (
"context"
"github.com/ultisuite/ulti-backend/internal/automation"
"github.com/ultisuite/ulti-backend/internal/mail/rules"
"github.com/ultisuite/ulti-backend/internal/nextcloud"
)
type contactAutomation interface {
OnContactEvent(ctx context.Context, externalUserID string, trigger rules.TriggerType, payload automation.ContactPayload)
}
func (h *Handler) SetAutomation(d contactAutomation) {
h.automation = d
}
func contactPayloadFrom(bookID string, contact *nextcloud.Contact) automation.ContactPayload {
if contact == nil {
return automation.ContactPayload{BookID: bookID}
}
return automation.ContactPayload{
ID: contact.UID,
BookID: bookID,
Name: contact.FullName,
Email: contact.Email,
Phone: contact.Phone,
Org: contact.Org,
}
}