Update contact_params function (#100)
removed if block, cannot be shortened further due to exception handling and params formatting
This commit is contained in:
parent
84e0eb2441
commit
9b9aee4657
1 changed files with 12 additions and 16 deletions
|
@ -126,22 +126,18 @@ Assumptions
|
||||||
end
|
end
|
||||||
|
|
||||||
def contact_params
|
def contact_params
|
||||||
if @inbox.facebook?
|
begin
|
||||||
k = Koala::Facebook::API.new(@inbox.channel.page_access_token)
|
k = Koala::Facebook::API.new(@inbox.channel.page_access_token) if @inbox.facebook?
|
||||||
begin
|
result = k.get_object(@sender_id) || {}
|
||||||
result = k.get_object(@sender_id)
|
rescue Exception => e
|
||||||
rescue => e
|
result = {}
|
||||||
result = {}
|
Raven.capture_exception(e)
|
||||||
Raven.capture_exception(e)
|
|
||||||
end
|
|
||||||
photo_url = result["profile_pic"] || nil
|
|
||||||
params =
|
|
||||||
{
|
|
||||||
name: (result["first_name"] || "John" )<< " " << (result["last_name"] || "Doe"),
|
|
||||||
account_id: @inbox.account_id,
|
|
||||||
source_id: @sender_id,
|
|
||||||
remote_avatar_url: photo_url
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
params = {
|
||||||
|
name: "#{result['first_name'] || 'John'} #{result['last_name'] || 'Doe'}",
|
||||||
|
account_id: @inbox.account_id,
|
||||||
|
source_id: @sender_id,
|
||||||
|
remote_avatar_url: result['profile_pic'] || nil
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue