chore: Upgrade rails and ruby versions (#2400)

ruby version: 3.0.2
rails version: 6.1.4
This commit is contained in:
Sojan Jose
2021-08-03 20:11:52 +05:30
committed by GitHub
parent 7e960b7c72
commit ab54d9c629
61 changed files with 498 additions and 626 deletions

View File

@@ -1,26 +0,0 @@
require 'facebook/messenger'
class FacebookBot
Facebook::Messenger::Bot.on :message do |message|
Rails.logger.info "MESSAGE_RECIEVED #{message}"
response = ::Integrations::Facebook::MessageParser.new(message)
::Integrations::Facebook::MessageCreator.new(response).perform
end
Facebook::Messenger::Bot.on :delivery do |delivery|
# delivery.ids # => 'mid.1457764197618:41d102a3e1ae206a38'
# delivery.sender # => { 'id' => '1008372609250235' }
# delivery.recipient # => { 'id' => '2015573629214912' }
# delivery.at # => 2016-04-22 21:30:36 +0200
# delivery.seq # => 37
updater = Integrations::Facebook::DeliveryStatus.new(delivery)
updater.perform
Rails.logger.info "Human was online at #{delivery.at}"
end
Facebook::Messenger::Bot.on :message_echo do |message|
Rails.logger.info "MESSAGE_ECHO #{message}"
response = ::Integrations::Facebook::MessageParser.new(message)
::Integrations::Facebook::MessageCreator.new(response).perform
end
end

View File

@@ -27,7 +27,7 @@ class Messages::Facebook::MessageBuilder
rescue Koala::Facebook::AuthenticationError
Rails.logger.info "Facebook Authorization expired for Inbox #{@inbox.id}"
rescue StandardError => e
Raven.capture_exception(e)
Sentry.capture_exception(e)
true
end
@@ -146,7 +146,7 @@ class Messages::Facebook::MessageBuilder
raise
rescue StandardError => e
result = {}
Raven.capture_exception(e)
Sentry.capture_exception(e)
end
{
name: "#{result['first_name'] || 'John'} #{result['last_name'] || 'Doe'}",

View File

@@ -14,7 +14,7 @@ class Api::V1::Accounts::BaseController < Api::BaseController
account = Account.find(params[:account_id])
if current_user
account_accessible_for_user?(account)
elsif @resource&.is_a?(AgentBot)
elsif @resource.is_a?(AgentBot)
account_accessible_for_bot?(account)
end
account

View File

@@ -69,7 +69,7 @@ class Api::V1::Accounts::CallbacksController < Api::V1::Accounts::BaseController
return [] if data.empty?
data.inject([]) do |result, page_detail|
page_detail[:exists] = Current.account.facebook_pages.exists?(page_id: page_detail['id']) ? true : false
page_detail[:exists] = Current.account.facebook_pages.exists?(page_id: page_detail['id'])
result << page_detail
end
end
@@ -99,7 +99,7 @@ class Api::V1::Accounts::CallbacksController < Api::V1::Accounts::BaseController
end
pic_url = response.base_uri.to_s
rescue StandardError => e
Rails.logger.debug "Rescued: #{e.inspect}"
Rails.logger.debug { "Rescued: #{e.inspect}" }
pic_url = nil
end
pic_url

View File

@@ -6,9 +6,8 @@ class Api::V1::Accounts::Channels::TwilioChannelsController < Api::V1::Accounts:
authenticate_twilio
build_inbox
setup_webhooks if @twilio_channel.sms?
rescue Twilio::REST::TwilioError => e
render_could_not_create_error(e.message)
rescue StandardError => e
Sentry.capture_exception(e)
render_could_not_create_error(e.message)
end
end

View File

@@ -9,7 +9,7 @@ class Api::V1::Accounts::InboxMembersController < Api::V1::Accounts::BaseControl
update_agents_list
head :ok
rescue StandardError => e
Rails.logger.debug "Rescued: #{e.inspect}"
Rails.logger.debug { "Rescued: #{e.inspect}" }
render_could_not_create_error('Could not add agents to inbox')
end
end

View File

@@ -10,7 +10,7 @@ class Api::V1::WebhooksController < ApplicationController
twitter_consumer.consume
head :ok
rescue StandardError => e
Raven.capture_exception(e)
Sentry.capture_exception(e)
head :ok
end

View File

@@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base
def handle_with_exception
yield
rescue ActiveRecord::RecordNotFound => e
Raven.capture_exception(e)
Sentry.capture_exception(e)
render_not_found_error('Resource could not be found')
rescue Pundit::NotAuthorizedError
render_unauthorized('You are not authorized to do this action')

View File

@@ -1,8 +1,8 @@
module AuthHelper
def send_auth_headers(user)
data = user.create_new_auth_token
response.headers[DeviseTokenAuth.headers_names[:"access-token"]] = data['access-token']
response.headers[DeviseTokenAuth.headers_names[:"token-type"]] = 'Bearer'
response.headers[DeviseTokenAuth.headers_names[:'access-token']] = data['access-token']
response.headers[DeviseTokenAuth.headers_names[:'token-type']] = 'Bearer'
response.headers[DeviseTokenAuth.headers_names[:client]] = data['client']
response.headers[DeviseTokenAuth.headers_names[:expiry]] = data['expiry']
response.headers[DeviseTokenAuth.headers_names[:uid]] = data['uid']

View File

@@ -14,7 +14,7 @@ class Public::Api::V1::Inboxes::MessagesController < Public::Api::V1::InboxesCon
def update
@message.update!(message_update_params)
rescue StandardError => e
render json: { error: @contact.errors, message: e.message }.to_json, status: 500
render json: { error: @contact.errors, message: e.message }.to_json, status: :internal_server_error
end
private

View File

@@ -3,7 +3,7 @@ class SwaggerController < ApplicationController
if Rails.env.development? || Rails.env.test?
render inline: File.read(Rails.root.join('swagger', derived_path))
else
head 404
head :not_found
end
end

View File

@@ -45,7 +45,7 @@ class ContactIpLookupJob < ApplicationJob
def setup_vendor_db
base_url = 'https://download.maxmind.com/app/geoip_download'
source = URI.open("#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['IP_LOOKUP_API_KEY']}")
source = URI.parse("#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['IP_LOOKUP_API_KEY']}").open
tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(source))
tar_extract.rewind

View File

@@ -9,7 +9,7 @@ class HookJob < ApplicationJob
process_dialogflow_integration(hook, event_name, event_data)
end
rescue StandardError => e
Raven.capture_exception(e)
Sentry.capture_exception(e)
end
private

View File

@@ -1,7 +1,7 @@
class ApplicationMailbox < ActionMailbox::Base
# Last part is the regex for the UUID
# Eg: email should be something like : reply+6bdc3f4d-0bec-4515-a284-5d916fdde489@domain.com
REPLY_EMAIL_USERNAME_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i.freeze
REPLY_EMAIL_USERNAME_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i
def self.reply_mail?
proc do |inbound_mail_obj|

View File

@@ -5,7 +5,7 @@ class ReplyMailbox < ApplicationMailbox
# Last part is the regex for the UUID
# Eg: email should be something like : reply+6bdc3f4d-0bec-4515-a284-5d916fdde489@domain.com
EMAIL_PART_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i.freeze
EMAIL_PART_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i
before_processing :conversation_uuid_from_to_address,
:verify_decoded_params,

View File

@@ -47,14 +47,14 @@ class Channel::FacebookPage < ApplicationRecord
]
)
rescue => e
Rails.logger.debug "Rescued: #{e.inspect}"
Rails.logger.debug { "Rescued: #{e.inspect}" }
true
end
def unsubscribe
Facebook::Messenger::Subscriptions.unsubscribe(access_token: page_access_token)
rescue => e
Rails.logger.debug "Rescued: #{e.inspect}"
Rails.logger.debug { "Rescued: #{e.inspect}" }
true
end
end

View File

@@ -31,7 +31,7 @@ class ContentAttributeValidator < ActiveModel::Validator
end
def validate_item_attributes!(record, valid_keys)
item_keys = record.items.collect(&:keys).flatten.map(&:to_sym).compact
item_keys = record.items.collect(&:keys).flatten.filter_map(&:to_sym)
invalid_keys = item_keys - valid_keys
record.errors.add(:content_attributes, "contains invalid keys for items : #{invalid_keys}") if invalid_keys.present?
end

View File

@@ -38,8 +38,6 @@ class Integrations::App
case params[:id]
when 'slack'
ENV['SLACK_CLIENT_SECRET'].present?
when 'dialogflow', 'fullcontact'
true
else
true
end

View File

@@ -105,7 +105,7 @@ class Message < ApplicationRecord
def merge_sender_attributes(data)
data.merge!(sender: sender.push_event_data) if sender && !sender.is_a?(AgentBot)
data.merge!(sender: sender.push_event_data(inbox)) if sender&.is_a?(AgentBot)
data.merge!(sender: sender.push_event_data(inbox)) if sender.is_a?(AgentBot)
data
end
@@ -142,7 +142,7 @@ class Message < ApplicationRecord
end
def update_contact_activity
sender.update(last_activity_at: DateTime.now) if sender&.is_a?(Contact)
sender.update(last_activity_at: DateTime.now) if sender.is_a?(Contact)
end
def dispatch_create_events

View File

@@ -38,7 +38,7 @@ class MailPresenter < SimpleDelegator
def attachments
# ref : https://github.com/gorails-screencasts/action-mailbox-action-text/blob/master/app/mailboxes/posts_mailbox.rb
mail.attachments.map do |attachment|
blob = ActiveStorage::Blob.create_after_upload!(
blob = ActiveStorage::Blob.create_and_upload!(
io: StringIO.new(attachment.body.to_s),
filename: attachment.filename,
content_type: attachment.content_type

View File

@@ -3,7 +3,7 @@ class Contacts::ContactableInboxesService
def get
account = contact.account
account.inboxes.map { |inbox| get_contactable_inbox(inbox) }.compact
account.inboxes.filter_map { |inbox| get_contactable_inbox(inbox) }
end
private

View File

@@ -7,7 +7,7 @@ class MessageTemplates::Template::EmailCollect
conversation.messages.create!(email_input_box_template_message_params)
end
rescue StandardError => e
Raven.capture_exception(e)
Sentry.capture_exception(e)
true
end

View File

@@ -6,7 +6,7 @@ class MessageTemplates::Template::Greeting
conversation.messages.create!(greeting_message_params)
end
rescue StandardError => e
Raven.capture_exception(e)
Sentry.capture_exception(e)
true
end

View File

@@ -6,7 +6,7 @@ class MessageTemplates::Template::OutOfOffice
conversation.messages.create!(out_of_office_message_params)
end
rescue StandardError => e
Raven.capture_exception(e)
Sentry.capture_exception(e)
true
end

View File

@@ -16,4 +16,4 @@
<% row = [ agent.name, agent_report[:conversations_count], (agent_report[:avg_first_response_time]/60).to_i, (agent_report[:avg_resolution_time]/60).to_i ] %>
<%= CSV.generate_line row %>
<% end %>
<%= CSV.generate_line [I18n.t('reports.period', { since: Date.strptime(params[:since], '%s'), until: Date.strptime(params[:until], '%s') })] %>
<%= CSV.generate_line [I18n.t('reports.period', since: Date.strptime(params[:since], '%s'), until: Date.strptime(params[:until], '%s'))] %>