From a7da2428b0ed7ffe95b4b761452976bc54d0516c Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Sun, 20 Oct 2019 01:41:24 +0530 Subject: [PATCH] upgrade facebook messenger gem (#159) - carrierwave local config - upgrade facebook messenger gem to support facebook graph api 4.0 --- Gemfile | 2 +- Gemfile.lock | 72 +++++++++++++++--------------- app/models/inbox.rb | 2 +- config/initializers/carrierwave.rb | 64 ++++++++++++++------------ 4 files changed, 72 insertions(+), 68 deletions(-) diff --git a/Gemfile b/Gemfile index 8468d231d..72c365640 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,7 @@ gem 'chargebee', '~>2' ##--- gems for channels ---## -gem 'facebook-messenger', '~> 0.11.1' +gem 'facebook-messenger' gem 'twitter' gem 'telegram-bot-ruby' # facebook client diff --git a/Gemfile.lock b/Gemfile.lock index 5409efa51..db2561c8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/rails/rails.git - revision: a4ea17f6b6c11e1b0b550a40cfd3811a56cc94d7 + revision: 7f6d2914c64e7b5224784152fc2d315b6b5b9d60 specs: actioncable (6.1.0.alpha) actionpack (= 6.1.0.alpha) @@ -59,7 +59,7 @@ GIT i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - zeitwerk (~> 2.1, >= 2.1.8) + zeitwerk (~> 2.2) rails (6.1.0.alpha) actioncable (= 6.1.0.alpha) actionmailbox (= 6.1.0.alpha) @@ -84,12 +84,13 @@ GIT GIT remote: https://github.com/lynndylanhurley/devise_token_auth - revision: 2a32f18ccce15638a74e72f6cfde5cf15a808d3f + revision: d886f476c625a1bf9673f03b95fb629e75ac2875 specs: devise_token_auth (1.1.3) bcrypt (~> 3.0) devise (> 3.5.2, < 5) rails (>= 4.2.0, < 6.1) + sprockets (= 3.7.2) GIT remote: https://github.com/mbleigh/acts-as-taggable-on @@ -100,7 +101,7 @@ GIT GIT remote: https://github.com/plataformatec/devise - revision: f48b6f1651233a39c52dd70e9ac6c35f70086062 + revision: c5de66245460920f9ce98af43c20188c8948f036 specs: devise (4.7.1) bcrypt (~> 3.0) @@ -117,8 +118,8 @@ GEM ast (2.4.0) attr_extras (6.2.1) aws-eventstream (1.0.3) - aws-partitions (1.220.0) - aws-sdk-core (3.68.1) + aws-partitions (1.226.0) + aws-sdk-core (3.69.1) aws-eventstream (~> 1.0, >= 1.0.2) aws-partitions (~> 1.0) aws-sigv4 (~> 1.1) @@ -126,7 +127,7 @@ GEM aws-sdk-kms (1.24.0) aws-sdk-core (~> 3, >= 3.61.1) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.48.0) + aws-sdk-s3 (1.50.0) aws-sdk-core (~> 3, >= 3.61.1) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) @@ -140,7 +141,7 @@ GEM bindex (0.8.1) bootsnap (1.4.5) msgpack (~> 1.0) - brakeman (4.6.1) + brakeman (4.7.0) buftok (0.2.0) builder (3.2.3) byebug (11.0.1) @@ -169,34 +170,31 @@ GEM coffee-script-source (1.12.2) concurrent-ruby (1.1.5) connection_pool (2.2.2) - crass (1.0.4) + crass (1.0.5) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) diff-lcs (1.3) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - dotenv (0.7.0) equalizer (0.0.11) erubi (1.9.0) execjs (2.7.0) - facebook-messenger (0.11.1) + facebook-messenger (1.4.1) httparty (~> 0.13, >= 0.13.7) - rack (>= 1.6.4) + rack (>= 1.4.5) factory_bot (5.1.1) activesupport (>= 4.2.0) factory_bot_rails (5.1.1) factory_bot (~> 5.1.0) railties (>= 4.2.0) - faker (2.1.2) - i18n (>= 0.8) - faraday (0.16.2) + faker (2.6.0) + i18n (>= 1.6, < 1.8) + faraday (0.17.0) multipart-post (>= 1.2, < 3) ffi (1.11.1) figaro (1.1.1) thor (~> 0.14) - foreman (0.64.0) - dotenv (~> 0.7.0) - thor (>= 0.13.6) + foreman (0.86.0) globalid (0.4.2) activesupport (>= 4.2.0) hashie (3.6.0) @@ -263,7 +261,7 @@ GEM method_source (0.9.2) mime-types (3.3) mime-types-data (~> 3.2015) - mime-types-data (3.2019.0904) + mime-types-data (3.2019.1009) mimemagic (0.3.3) mini_magick (4.9.5) mini_mime (1.0.2) @@ -271,7 +269,7 @@ GEM minitest (5.12.2) mock_redis (0.22.0) msgpack (1.3.1) - multi_json (1.13.1) + multi_json (1.14.1) multi_xml (0.6.0) multipart-post (2.1.1) naught (1.1.0) @@ -336,23 +334,23 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rspec-core (3.8.2) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.5) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.2) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.2) + rspec-support (~> 3.9.0) + rspec-rails (3.9.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.3) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.0) rubocop (0.73.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) @@ -361,16 +359,16 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) ruby-progressbar (1.10.1) - ruby-vips (2.0.15) + ruby-vips (2.0.16) ffi (~> 1.9) seed_dump (3.3.1) activerecord (>= 4) activesupport (>= 4) - sentry-raven (2.11.3) + sentry-raven (2.12.0) faraday (>= 0.7.6, < 1.0) shoulda-matchers (4.1.2) activesupport (>= 4.2.0) - sidekiq (6.0.1) + sidekiq (6.0.2) connection_pool (>= 2.2.2) rack (>= 2.0.0) rack-protection (>= 2.0.0) @@ -441,7 +439,7 @@ GEM websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) wisper (2.0.0) - zeitwerk (2.1.10) + zeitwerk (2.2.0) PLATFORMS ruby @@ -457,7 +455,7 @@ DEPENDENCIES coffee-rails devise! devise_token_auth! - facebook-messenger (~> 0.11.1) + facebook-messenger factory_bot_rails faker figaro diff --git a/app/models/inbox.rb b/app/models/inbox.rb index b3f38d86e..fce953ff5 100644 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -44,6 +44,6 @@ class Inbox < ApplicationRecord end def subscribe_webhook - Facebook::Messenger::Subscriptions.subscribe(access_token: channel.page_access_token) + Facebook::Messenger::Subscriptions.subscribe(access_token: channel.page_access_token, subscribed_fields: %w[message_mention messages messaging_account_linking messaging_checkout_updates message_echoes message_deliveries messaging_game_plays messaging_optins messaging_optouts messaging_payments messaging_postbacks messaging_pre_checkouts message_reads messaging_referrals messaging_handovers messaging_policy_enforcement messaging_page_feedback messaging_appointments messaging_direct_sends]) end end diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 5ef5e787c..787e54e29 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -1,31 +1,37 @@ CarrierWave.configure do |config| - config.storage = :aws - config.aws_bucket = ENV['S3_BUCKET_NAME'] - config.aws_acl = 'authenticated-read' - - # Optionally define an asset host for configurations that are fronted by a - # content host, such as CloudFront. - #config.asset_host = 'http://example.com' - - # The maximum period for authenticated_urls is only 7 days. - config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7 - - # Set custom options such as cache control to leverage browser caching - config.aws_attributes = { - expires: 1.week.from_now.httpdate, - cache_control: 'max-age=604800' - } - - config.aws_credentials = { - access_key_id: ENV['AWS_ACCESS_KEY_ID'], - secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], - region: ENV['AWS_REGION'] # Required - } - - # Optional: Signing of download urls, e.g. for serving private content through - # CloudFront. Be sure you have the `cloudfront-signer` gem installed and - # configured: - # config.aws_signer = -> (unsigned_url, options) do - # Aws::CF::Signer.sign_url(unsigned_url, options) - # end + config.storage = :file +end + +if Rails.env.production? + CarrierWave.configure do |config| + config.storage = :aws + config.aws_bucket = ENV['S3_BUCKET_NAME'] + config.aws_acl = 'authenticated-read' + + # Optionally define an asset host for configurations that are fronted by a + # content host, such as CloudFront. + #config.asset_host = 'http://example.com' + + # The maximum period for authenticated_urls is only 7 days. + config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7 + + # Set custom options such as cache control to leverage browser caching + config.aws_attributes = { + expires: 1.week.from_now.httpdate, + cache_control: 'max-age=604800' + } + + config.aws_credentials = { + access_key_id: ENV['AWS_ACCESS_KEY_ID'], + secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], + region: ENV['AWS_REGION'] # Required + } + + # Optional: Signing of download urls, e.g. for serving private content through + # CloudFront. Be sure you have the `cloudfront-signer` gem installed and + # configured: + # config.aws_signer = -> (unsigned_url, options) do + # Aws::CF::Signer.sign_url(unsigned_url, options) + # end + end end