Chore: Housekeeping tasks (#721)

- End point to return api version
- Move agent bot listener to sync dispatcher
- gem update
This commit is contained in:
Sojan Jose
2020-04-16 15:05:01 +05:30
committed by GitHub
parent 55892e37f9
commit 743bddc065
8 changed files with 59 additions and 18 deletions

View File

@@ -82,10 +82,10 @@ GEM
rake (>= 10.4, < 14.0) rake (>= 10.4, < 14.0)
ast (2.4.0) ast (2.4.0)
attr_extras (6.2.3) attr_extras (6.2.3)
aws-eventstream (1.0.3) aws-eventstream (1.1.0)
aws-partitions (1.294.0) aws-partitions (1.296.0)
aws-sdk-core (3.92.0) aws-sdk-core (3.94.0)
aws-eventstream (~> 1.0, >= 1.0.2) aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0) aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1) aws-sigv4 (~> 1.1)
jmespath (~> 1.0) jmespath (~> 1.0)
@@ -113,7 +113,7 @@ GEM
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.4.6) bootsnap (1.4.6)
msgpack (~> 1.0) msgpack (~> 1.0)
brakeman (4.8.0) brakeman (4.8.1)
browser (4.0.0) browser (4.0.0)
builder (3.2.4) builder (3.2.4)
bullet (6.1.0) bullet (6.1.0)
@@ -179,7 +179,7 @@ GEM
foreman (0.87.1) foreman (0.87.1)
globalid (0.4.2) globalid (0.4.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
google-api-client (0.37.2) google-api-client (0.38.0)
addressable (~> 2.5, >= 2.5.1) addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.9) googleauth (~> 0.9)
httpclient (>= 2.8.1, < 3.0) httpclient (>= 2.8.1, < 3.0)
@@ -193,20 +193,20 @@ GEM
google-cloud-env (1.3.1) google-cloud-env (1.3.1)
faraday (>= 0.17.3, < 2.0) faraday (>= 0.17.3, < 2.0)
google-cloud-errors (1.0.0) google-cloud-errors (1.0.0)
google-cloud-storage (1.25.1) google-cloud-storage (1.26.0)
addressable (~> 2.5) addressable (~> 2.5)
digest-crc (~> 0.4) digest-crc (~> 0.4)
google-api-client (~> 0.33) google-api-client (~> 0.33)
google-cloud-core (~> 1.2) google-cloud-core (~> 1.2)
googleauth (~> 0.9) googleauth (~> 0.9)
mini_mime (~> 1.0) mini_mime (~> 1.0)
googleauth (0.11.0) googleauth (0.12.0)
faraday (>= 0.17.3, < 2.0) faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0) jwt (>= 1.4, < 3.0)
memoist (~> 0.16) memoist (~> 0.16)
multi_json (~> 1.11) multi_json (~> 1.11)
os (>= 0.9, < 2.0) os (>= 0.9, < 2.0)
signet (~> 0.12) signet (~> 0.14)
groupdate (5.0.0) groupdate (5.0.0)
activesupport (>= 5) activesupport (>= 5)
haikunator (1.1.0) haikunator (1.1.0)
@@ -253,7 +253,7 @@ GEM
listen (3.2.1) listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.4.0) loofah (2.5.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.1) mail (2.7.1)
@@ -284,21 +284,21 @@ GEM
orm_adapter (0.5.0) orm_adapter (0.5.0)
os (1.1.0) os (1.1.0)
parallel (1.19.1) parallel (1.19.1)
parser (2.7.1.0) parser (2.7.1.1)
ast (~> 2.4.0) ast (~> 2.4.0)
pg (1.2.3) pg (1.2.3)
pry (0.13.0) pry (0.13.1)
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
pry-rails (0.3.9) pry-rails (0.3.9)
pry (>= 0.10.4) pry (>= 0.10.4)
public_suffix (4.0.3) public_suffix (4.0.4)
puma (4.3.3) puma (4.3.3)
nio4r (~> 2.0) nio4r (~> 2.0)
pundit (2.1.0) pundit (2.1.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
rack (2.2.2) rack (2.2.2)
rack-cache (1.11.0) rack-cache (1.11.1)
rack (>= 0.4) rack (>= 0.4)
rack-cors (1.1.1) rack-cors (1.1.1)
rack (>= 2.0.0) rack (>= 2.0.0)
@@ -388,7 +388,7 @@ GEM
unicode-display_width (>= 1.4.0, < 2.0) unicode-display_width (>= 1.4.0, < 2.0)
rubocop-performance (1.5.2) rubocop-performance (1.5.2)
rubocop (>= 0.71.0) rubocop (>= 0.71.0)
rubocop-rails (2.5.1) rubocop-rails (2.5.2)
activesupport activesupport
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 0.72.0) rubocop (>= 0.72.0)
@@ -463,7 +463,7 @@ GEM
unf_ext (0.0.7.7) unf_ext (0.0.7.7)
unicode-display_width (1.7.0) unicode-display_width (1.7.0)
uniform_notifier (1.13.0) uniform_notifier (1.13.0)
valid_email2 (3.2.1) valid_email2 (3.2.2)
activemodel (>= 3.2) activemodel (>= 3.2)
mail (~> 2.5) mail (~> 2.5)
virtus (1.0.5) virtus (1.0.5)

View File

@@ -0,0 +1,8 @@
class ApiController < ApplicationController
skip_before_action :set_current_user, only: [:index]
skip_before_action :check_subscription, only: [:index]
def index
render json: { version: Chatwoot.config[:version], timestamp: Time.now.utc.to_formatted_s(:db) }
end
end

View File

@@ -9,7 +9,7 @@ class AsyncDispatcher < BaseDispatcher
end end
def listeners def listeners
listeners = [AgentBotListener.instance, EmailNotificationListener.instance, ReportingListener.instance, WebhookListener.instance] listeners = [EmailNotificationListener.instance, ReportingListener.instance, WebhookListener.instance]
listeners << EventListener.instance listeners << EventListener.instance
listeners << SubscriptionListener.instance if ENV['BILLING_ENABLED'] listeners << SubscriptionListener.instance if ENV['BILLING_ENABLED']
listeners listeners

View File

@@ -5,6 +5,6 @@ class SyncDispatcher < BaseDispatcher
end end
def listeners def listeners
[ActionCableListener.instance] [ActionCableListener.instance, AgentBotListener.instance]
end end
end end

14
config/app.yml Normal file
View File

@@ -0,0 +1,14 @@
shared: &shared
version: '1.4.0'
development:
<<: *shared
production:
<<: *shared
staging:
<<: *shared
test:
<<: *shared

View File

@@ -30,5 +30,12 @@ module Chatwoot
config.action_dispatch.default_headers = { config.action_dispatch.default_headers = {
'X-Frame-Options' => 'ALLOWALL' 'X-Frame-Options' => 'ALLOWALL'
} }
# Custom chatwoot configurations
config.x = config_for(:app).with_indifferent_access
end
def self.config
@config ||= Rails.configuration.x
end end
end end

View File

@@ -17,6 +17,7 @@ Rails.application.routes.draw do
resource :widget, only: [:show] resource :widget, only: [:show]
get '/api', to: 'api#index'
namespace :api, defaults: { format: 'json' } do namespace :api, defaults: { format: 'json' } do
namespace :v1 do namespace :v1 do
# ---------------------------------- # ----------------------------------

View File

@@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.describe 'API Base', type: :request do
describe 'request to api base url' do
it 'returns api version' do
get '/api/'
expect(response).to have_http_status(:success)
expect(response.body).to include(Chatwoot.config[:version])
end
end
end