chore: Improve location display in sidebar (#1509)

- Log IP Address on widget load
- Save country code to contact
This commit is contained in:
Pranav Raj S
2020-12-13 22:23:56 +05:30
committed by GitHub
parent 060ef4a427
commit edb09d5a9c
10 changed files with 57 additions and 33 deletions

View File

@@ -35,7 +35,6 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
def create
ActiveRecord::Base.transaction do
@contact = Current.account.contacts.new(contact_params)
set_ip
@contact.save!
@contact_inbox = build_contact_inbox
end
@@ -43,7 +42,6 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
def update
@contact.assign_attributes(contact_update_params)
set_ip
@contact.save!
rescue ActiveRecord::RecordInvalid => e
render json: {
@@ -99,11 +97,4 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
def fetch_contact
@contact = Current.account.contacts.includes(contact_inboxes: [:inbox]).find(params[:id])
end
def set_ip
return if @contact.account.feature_enabled?('ip_lookup')
@contact[:additional_attributes][:created_at_ip] ||= request.remote_ip
@contact[:additional_attributes][:updated_at_ip] = request.remote_ip
end
end