From ba1e0dbda0f2505a29ccf8cb29734f2d9463a2ff Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Sun, 3 May 2020 12:16:11 +0530 Subject: [PATCH] Chore: Apple site association file for deep linking (#805) --- .env.example | 4 ++++ app/controllers/apple_app_controller.rb | 6 ++++++ app/controllers/home_controller.rb | 9 --------- app/views/apple_app/site_association.html.erb | 11 +++++++++++ config/routes.rb | 4 ++++ spec/controllers/apple_app_spec.rb | 10 ++++++++++ 6 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 app/controllers/apple_app_controller.rb delete mode 100644 app/controllers/home_controller.rb create mode 100644 app/views/apple_app/site_association.html.erb create mode 100644 spec/controllers/apple_app_spec.rb diff --git a/.env.example b/.env.example index 50b2fd1b2..9417315d3 100644 --- a/.env.example +++ b/.env.example @@ -89,6 +89,10 @@ TWITTER_CONSUMER_KEY= TWITTER_CONSUMER_SECRET= TWITTER_ENVIRONMENT= +### Change this env variable only if you are using a custom build mobile app +## Mobile app env variables +IOS_APP_ID=6C953F3RX2.com.chatwoot.app + #### This environment variables are only required in hosted version which has billing ENABLE_BILLING= diff --git a/app/controllers/apple_app_controller.rb b/app/controllers/apple_app_controller.rb new file mode 100644 index 000000000..1191cd66e --- /dev/null +++ b/app/controllers/apple_app_controller.rb @@ -0,0 +1,6 @@ +class AppleAppController < ApplicationController + def site_association + site_association_json = render_to_string action: 'site_association', layout: false + send_data site_association_json, filename: 'apple-app-site-association', type: 'application/json' + end +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb deleted file mode 100644 index d811b859e..000000000 --- a/app/controllers/home_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'rest-client' -require 'telegram/bot' - -class HomeController < ApplicationController - skip_before_action :verify_authenticity_token, only: [:telegram] - skip_before_action :authenticate_user!, only: [:telegram], raise: false - skip_before_action :set_current_user - skip_before_action :check_subscription -end diff --git a/app/views/apple_app/site_association.html.erb b/app/views/apple_app/site_association.html.erb new file mode 100644 index 000000000..80adc2959 --- /dev/null +++ b/app/views/apple_app/site_association.html.erb @@ -0,0 +1,11 @@ +{ + "applinks": { + "apps": [], + "details": [ + { + "appID": "<%= ENV['IOS_APP_ID'] %>", + "paths": [ "NOT /super_admin/*", "*" ] + } + ] + } +} diff --git a/config/routes.rb b/config/routes.rb index 051aca254..a3ea7d998 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -154,6 +154,10 @@ Rails.application.routes.draw do # Routes for testing resources :widget_tests, only: [:index] unless Rails.env.production? + # ---------------------------------------------------------------------- + # Routes for external service verifications + get 'apple-app-site-association' => 'apple_app#site_association' + # ---------------------------------------------------------------------- # Internal Monitoring Routes require 'sidekiq/web' diff --git a/spec/controllers/apple_app_spec.rb b/spec/controllers/apple_app_spec.rb new file mode 100644 index 000000000..ed9f986a0 --- /dev/null +++ b/spec/controllers/apple_app_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +describe '/apple-app-site-association', type: :request do + describe 'GET /apple-app-site-association' do + it 'renders the apple-app-site-association file' do + get '/apple-app-site-association' + expect(response).to have_http_status(:success) + end + end +end