feat: IP lookup (#1315)
- feature to store contact IP for accounts - IP lookup through geocoder gem - ability to do IP lookup through external APIs - add commit hook to prevent push to develop and master - migrations to fix default values for jsonb columns
This commit is contained in:
@@ -40,6 +40,7 @@ class Contact < ApplicationRecord
|
||||
before_validation :prepare_email_attribute
|
||||
after_create_commit :dispatch_create_event
|
||||
after_update_commit :dispatch_update_event
|
||||
after_commit :ip_lookup
|
||||
|
||||
def get_source_id(inbox_id)
|
||||
contact_inboxes.find_by!(inbox_id: inbox_id).source_id
|
||||
@@ -68,6 +69,12 @@ class Contact < ApplicationRecord
|
||||
}
|
||||
end
|
||||
|
||||
def ip_lookup
|
||||
return unless account.feature_enabled?('ip_lookup')
|
||||
|
||||
ContactIpLookupJob.perform_later(self)
|
||||
end
|
||||
|
||||
def prepare_email_attribute
|
||||
# So that the db unique constraint won't throw error when email is ''
|
||||
self.email = nil if email.blank?
|
||||
|
||||
Reference in New Issue
Block a user