package automation

import (
	"github.com/nexuscrm/shared/pkg/constants"
	"github.com/nexuscrm/shared/pkg/models"
)

// newSystemAutomationUser builds the identity for scheduled and record-triggered
// automation that runs without a real end-user (Salesforce "system context").
//
// Security is enforced via constants.WithSecurityContext(ctx, SystemContext, ...)
// on the context — that bypasses process-field, CRUD/FLS, and RLS checks at the
// persistence layer. The user session itself carries only an identity (for audit /
// OwnerId attribution), NOT elevated permissions, so the permission-service layer
// can still distinguish automation from a real admin if needed.
func newSystemAutomationUser() *models.UserSession {
	email := constants.SystemUserEmail

	return &models.UserSession{
		ID:    constants.SystemUserID,
		Name:  constants.SystemSchedulerUserName,
		Email: &email,
	}
}
