summaryrefslogtreecommitdiff
path: root/app/models/customer_relations/contact.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/customer_relations/contact.rb')
-rw-r--r--app/models/customer_relations/contact.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/customer_relations/contact.rb b/app/models/customer_relations/contact.rb
index 168f1c48a6c..a981351f4a0 100644
--- a/app/models/customer_relations/contact.rb
+++ b/app/models/customer_relations/contact.rb
@@ -26,6 +26,18 @@ class CustomerRelations::Contact < ApplicationRecord
validate :validate_email_format
validate :unique_email_for_group_hierarchy
+ def self.reference_prefix
+ '[contact:'
+ end
+
+ def self.reference_prefix_quoted
+ '["contact:'
+ end
+
+ def self.reference_postfix
+ ']'
+ end
+
def self.find_ids_by_emails(group, emails)
raise ArgumentError, "Cannot lookup more than #{MAX_PLUCK} emails" if emails.length > MAX_PLUCK
@@ -33,6 +45,12 @@ class CustomerRelations::Contact < ApplicationRecord
.pluck(:id)
end
+ def self.exists_for_group?(group)
+ return false unless group
+
+ exists?(group_id: group.self_and_ancestor_ids)
+ end
+
private
def validate_email_format