🚨Fix Rubocop lint errors
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Integrations::Facebook::DeliveryStatus
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Integrations::Facebook::MessageCreator
|
||||
|
||||
attr_reader :response
|
||||
|
||||
def initialize(response)
|
||||
@@ -9,23 +8,23 @@ class Integrations::Facebook::MessageCreator
|
||||
end
|
||||
|
||||
def perform
|
||||
#begin
|
||||
if outgoing_message_via_echo?
|
||||
create_outgoing_message
|
||||
else
|
||||
create_incoming_message
|
||||
end
|
||||
#rescue => e
|
||||
#Raven.capture_exception(e)
|
||||
#end
|
||||
# begin
|
||||
if outgoing_message_via_echo?
|
||||
create_outgoing_message
|
||||
else
|
||||
create_incoming_message
|
||||
end
|
||||
# rescue => e
|
||||
# Raven.capture_exception(e)
|
||||
# end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def outgoing_message_via_echo?
|
||||
response.echo? && !response.sent_from_chatwoot_app?
|
||||
#this means that it is an outgoing message from page, but not sent from chatwoot.
|
||||
#User can send from fb page directly on mobile messenger, so this case should be handled as outgoing message
|
||||
# this means that it is an outgoing message from page, but not sent from chatwoot.
|
||||
# User can send from fb page directly on mobile messenger, so this case should be handled as outgoing message
|
||||
end
|
||||
|
||||
def create_outgoing_message
|
||||
@@ -41,5 +40,4 @@ class Integrations::Facebook::MessageCreator
|
||||
mb.perform
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Integrations::Facebook::MessageParser
|
||||
|
||||
def initialize(response_json)
|
||||
@response = response_json
|
||||
end
|
||||
|
||||
def sender_id
|
||||
@response.sender["id"]
|
||||
@response.sender['id']
|
||||
end
|
||||
|
||||
def recipient_id
|
||||
@response.recipient["id"]
|
||||
@response.recipient['id']
|
||||
end
|
||||
|
||||
def time_stamp
|
||||
@@ -45,7 +44,6 @@ class Integrations::Facebook::MessageParser
|
||||
def sent_from_chatwoot_app?
|
||||
app_id && app_id == ENV['fb_app_id'].to_i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Sample Reponse
|
||||
@@ -67,6 +65,6 @@ end
|
||||
# }
|
||||
# }
|
||||
|
||||
#ECHO from own app
|
||||
# ECHO from own app
|
||||
|
||||
#{"sender"=>{"id"=>"379460302081528"}, "recipient"=>{"id"=>"403092229814994"}, "timestamp"=>1493270145685, "message"=>{"is_echo"=>true, "app_id"=>1847193292179369, "mid"=>"mid.$cAAED7rlYNsVh3xtylVbrdYqH8iEp", "seq"=>167221, "text"=>"sad"}}
|
||||
# {"sender"=>{"id"=>"379460302081528"}, "recipient"=>{"id"=>"403092229814994"}, "timestamp"=>1493270145685, "message"=>{"is_echo"=>true, "app_id"=>1847193292179369, "mid"=>"mid.$cAAED7rlYNsVh3xtylVbrdYqH8iEp", "seq"=>167221, "text"=>"sad"}}
|
||||
|
||||
@@ -32,11 +32,11 @@ class Integrations::Widget::IncomingMessageBuilder
|
||||
|
||||
def build_conversation
|
||||
@conversation ||=
|
||||
if (conversation = Conversation.find_by(conversation_params))
|
||||
conversation
|
||||
else
|
||||
Conversation.create!(conversation_params)
|
||||
end
|
||||
if (conversation = Conversation.find_by(conversation_params))
|
||||
conversation
|
||||
else
|
||||
Conversation.create!(conversation_params)
|
||||
end
|
||||
end
|
||||
|
||||
def build_message
|
||||
@@ -57,7 +57,7 @@ class Integrations::Widget::IncomingMessageBuilder
|
||||
account_id: @conversation.account_id,
|
||||
inbox_id: @conversation.inbox_id,
|
||||
message_type: 0,
|
||||
content: options[:content],
|
||||
content: options[:content]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,4 +49,4 @@ class Integrations::Widget::OutgoingMessageBuilder
|
||||
user_id: user.id
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user