Wire automation dispatcher to IMAP sync, drive mutations, and contact CRUD. Add webhook event_types and mail/drive/contacts scope filters (migration 30).
32 lines
800 B
Go
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,
|
|
}
|
|
}
|