skip auto-reply and csat send when contact has no email

This commit is contained in:
Abhinav Raut
2026-05-15 11:59:38 +05:30
parent f6a4ad537f
commit b5000c7bc4
+8 -1
View File
@@ -1287,6 +1287,9 @@ func (m *Manager) ApplyAction(action amodels.RuleAction, conv models.Conversatio
case amodels.ActionReply:
// Automated replies always go to the contact only. CCs from the
// conversation history are deliberately not carried forward.
if conv.Contact.Email.String == "" {
return fmt.Errorf("auto-reply skipped: contact has no email for conversation: %s", conv.UUID)
}
_, err := m.QueueReply(
[]mmodels.Media{},
conv.InboxID,
@@ -1356,8 +1359,12 @@ func (m *Manager) RemoveConversationAssignee(uuid, typ string, actor umodels.Use
return nil
}
// SendCSATReply sends a CSAT reply message to a conversation. No-op if one was already sent.
// SendCSATReply sends a CSAT reply message to a conversation. No-op if one was already sent or contact has no email.
func (m *Manager) SendCSATReply(actorUserID int, conversation models.Conversation) error {
if conversation.Contact.Email.String == "" {
m.lo.Info("CSAT reply skipped: contact has no email for conversation: %s", "conversation_uuid", conversation.UUID)
return nil
}
csatResp, err := m.csatStore.Create(conversation.ID)
if err != nil {
if errors.Is(err, csat.ErrCSATAlreadyExists) {