🚨Fix Rubocop lint errors

This commit is contained in:
Pranav Raj S
2019-10-20 14:17:26 +05:30
committed by GitHub
parent dd018f3682
commit 94c6d6db6f
124 changed files with 774 additions and 914 deletions

View File

@@ -1,9 +1,7 @@
# frozen_string_literal: true
module CustomExceptions::Account
class InvalidEmail < CustomExceptions::Base
def message
if @data[:disposable]
I18n.t 'errors.signup.disposable_email'
@@ -15,13 +13,13 @@ module CustomExceptions::Account
class UserExists < CustomExceptions::Base
def message
I18n.t('errors.signup.email_already_exists', email: @data[:email])
I18n.t('errors.signup.email_already_exists', email: @data[:email])
end
end
class UserErrors < CustomExceptions::Base
def message
@data[:errors].full_messages.join(",")
@data[:errors].full_messages.join(',')
end
end
@@ -30,6 +28,4 @@ module CustomExceptions::Account
I18n.t 'errors.signup.failed'
end
end
end

View File

@@ -1,7 +1,6 @@
# frozen_string_literal: true
class CustomExceptions::Base < ::StandardError
def to_hash
{
message: message
@@ -15,5 +14,4 @@ class CustomExceptions::Base < ::StandardError
def initialize(data)
@data = data
end
end

View File

@@ -3,31 +3,31 @@
module CustomExceptions::Report
class InvalidIdentity < CustomExceptions::Base
def message
"Invalid type"
'Invalid type'
end
end
class IdentityNotFound < CustomExceptions::Base
def message
"Type with the specified id not found"
'Type with the specified id not found'
end
end
class MetricNotFound < CustomExceptions::Base
def message
"Metric for the specified type not found"
'Metric for the specified type not found'
end
end
class InvalidStartTime < CustomExceptions::Base
def message
"Invalid start_time"
'Invalid start_time'
end
end
class InvalidEndTime < CustomExceptions::Base
def message
"Invalid end_time"
'Invalid end_time'
end
end
end

View File

@@ -9,6 +9,6 @@ class Events::Base
end
def method_name
name.to_s.gsub('.','_')
name.to_s.gsub('.', '_')
end
end

View File

@@ -1,7 +1,6 @@
# frozen_string_literal: true
class Integrations::Facebook::DeliveryStatus
def initialize(params)
@params = params
end

View File

@@ -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

View File

@@ -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"}}

View File

@@ -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

View File

@@ -49,4 +49,4 @@ class Integrations::Widget::OutgoingMessageBuilder
user_id: user.id
}
end
end
end

View File

@@ -4,16 +4,16 @@ module Redis::Alfred
$alfred.rpoplpush(source, destination)
end
def lpush(key,value)
$alfred.lpush(key,value)
def lpush(key, value)
$alfred.lpush(key, value)
end
def delete(key)
$alfred.del(key)
end
def lrem(key,value,count=0)
$alfred.lrem(key,count,value)
def lrem(key, value, count = 0)
$alfred.lrem(key, count, value)
end
end
end

View File

@@ -1,43 +1,43 @@
# frozen_string_literal: true
class Reports::UpdateIdentity
attr_reader :account, :identity
attr_accessor :timestamp
def initialize(account, timestamp = Time.now)
@account, @timestamp = account, timestamp
@account = account
@timestamp = timestamp
end
def incr_conversations_count(step=1)
def incr_conversations_count(step = 1)
update_conversations_count(:incr, step)
end
def decr_conversations_count(step=1)
def decr_conversations_count(step = 1)
update_conversations_count(:decr, step)
end
def incr_incoming_messages_count(step=1)
def incr_incoming_messages_count(step = 1)
update_incoming_messages_count(:incr, step)
end
def decr_incoming_messages_count(step=1)
def decr_incoming_messages_count(step = 1)
update_incoming_messages_count(:decr, step)
end
def incr_outgoing_messages_count(step=1)
def incr_outgoing_messages_count(step = 1)
update_outgoing_messages_count(:incr, step)
end
def decr_outgoing_messages_count(step=1)
def decr_outgoing_messages_count(step = 1)
update_outgoing_messages_count(:decr, step)
end
def incr_resolutions_count(step=1)
def incr_resolutions_count(step = 1)
update_resolutions_count(:incr, step)
end
def decr_resolutions_count(step=1)
def decr_resolutions_count(step = 1)
update_resolutions_count(:decr, step)
end

View File

@@ -1,11 +1,10 @@
# frozen_string_literal: true
class Webhooks::Chargebee
SUPPORTED_EVENTS = [:subscription_created, :subscription_trial_end_reminder,
:subscription_activated, :subscription_cancelled,
:subscription_reactivated, :subscription_deleted,
:subscription_renewed, :payment_source_added, :subscription_changed ]
:subscription_renewed, :payment_source_added, :subscription_changed].freeze
attr_accessor :params, :account
@@ -29,7 +28,7 @@ class Webhooks::Chargebee
def trial_ends_on
trial_end = @params[:content][:subscription][:trial_end]
DateTime.strptime(trial_end,'%s')
DateTime.strptime(trial_end, '%s')
end
def supported_event?
@@ -68,18 +67,17 @@ class Webhooks::Chargebee
end
def subscription_reactivated
#TODO send mail to user that account is reactivated
# TODO: send mail to user that account is reactivated
subscription.active!
Raven.capture_message("subscription reactivated for #{customer_id}")
end
def subscription_renewed
#TODO Needs this to show payment history.
# TODO: Needs this to show payment history.
Raven.capture_message("subscription renewed for #{customer_id}")
end
def subscription_deleted
end
def subscription_deleted; end
def payment_source_added
Raven.capture_message("payment source added for #{customer_id}")