Skip to content

Commit

Permalink
Merge branch 'release/2.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sojan-official committed Jun 15, 2022
2 parents 63b1013 + c2114e4 commit 374b367
Show file tree
Hide file tree
Showing 715 changed files with 10,951 additions and 3,185 deletions.
7 changes: 3 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defaults: &defaults
working_directory: ~/build
docker:
# specify the version you desire here
- image: cimg/ruby:3.0.2-browsers
- image: cimg/ruby:3.0.4-browsers

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down Expand Up @@ -40,14 +40,13 @@ jobs:

- restore_cache:
keys:
- chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-{{ checksum "Gemfile.lock" }}
- chatwoot-bundle
- chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-v20220524-{{ checksum "Gemfile.lock" }}

- run: bundle install --frozen --path ~/.bundle
- save_cache:
paths:
- ~/.bundle
key: chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-{{ checksum "Gemfile.lock" }}
key: chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-v20220524-{{ checksum "Gemfile.lock" }}


# Only necessary if app uses webpacker or yarn in some other way
Expand Down
36 changes: 24 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,32 @@ module.exports = {
'jsx-a11y/label-has-for': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'import/no-unresolved': 'off',
'vue/max-attributes-per-line': ['error', {
'singleline': 20,
'multiline': {
'max': 1,
'allowFirstLine': false
'vue/max-attributes-per-line': [
'error',
{
singleline: 20,
multiline: {
max: 1,
allowFirstLine: false,
},
},
}],
'vue/html-self-closing': 'off',
"vue/no-v-html": 'off',
],
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
normal: 'always',
component: 'always',
},
svg: 'always',
math: 'always',
},
],
'vue/no-v-html': 'off',
'vue/singleline-html-element-content-newline': 'off',
'import/extensions': ['off'],
'no-console': 'error'
'no-console': 'error',
},
settings: {
'import/resolver': {
Expand All @@ -41,12 +55,10 @@ module.exports = {
},
env: {
browser: true,
node: true,
jest: true,
jasmine: true
node: true,
},
globals: {
__WEBPACK_ENV__: true,
bus: true,
},
};
2 changes: 1 addition & 1 deletion .github/workflows/run_foss_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2 # Not needed with a .ruby-version file
ruby-version: 3.0.4 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: yarn
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.2
3.0.4
10 changes: 4 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '3.0.2'
ruby '3.0.4'

##-- base gems for rails --##
gem 'rack-cors', require: 'rack/cors'
Expand Down Expand Up @@ -128,6 +128,9 @@ gem 'html2text'
# to calculate working hours
gem 'working_hours'

# full text search for articles
gem 'pg_search'

group :production, :staging do
# we dont want request timing out in development while using byebug
gem 'rack-timeout'
Expand Down Expand Up @@ -156,11 +159,6 @@ group :test do
end

group :development, :test do
# TODO: is this needed ?
# errors thrown by devise password gem
gem 'flay'
gem 'rspec'
# for error thrown by devise password gem
gem 'active_record_query_trace'
gem 'bundle-audit', require: false
gem 'byebug', platform: :mri
Expand Down
35 changes: 13 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/chatwoot/devise-secure_password
revision: de11e8765654b8242d42101ee9c8ffc8126f7975
revision: d777b04f12652d576b1272b8f39857e3e0b3fc26
specs:
devise-secure_password (2.0.1)
devise (>= 4.0.0, < 5.0.0)
Expand Down Expand Up @@ -182,7 +182,6 @@ GEM
regexp_parser (~> 2.2)
email_reply_trimmer (0.1.13)
erubi (1.10.0)
erubis (2.7.0)
et-orbi (1.2.7)
tzinfo
execjs (2.8.1)
Expand All @@ -204,11 +203,6 @@ GEM
faraday (~> 1)
ffi (1.15.5)
flag_shih_tzu (0.3.23)
flay (2.12.1)
erubis (~> 2.7.0)
path_expander (~> 1.0)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
foreman (0.87.2)
fugit (1.5.3)
et-orbi (~> 1, >= 1.2.7)
Expand Down Expand Up @@ -309,7 +303,7 @@ GEM
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jmespath (1.6.0)
jmespath (1.6.1)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -378,23 +372,25 @@ GEM
netrc (0.11.0)
newrelic_rpm (8.7.0)
nio4r (2.5.8)
nokogiri (1.13.5)
nokogiri (1.13.6)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.5-arm64-darwin)
nokogiri (1.13.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.5-x86_64-darwin)
nokogiri (1.13.6-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.5-x86_64-linux)
nokogiri (1.13.6-x86_64-linux)
racc (~> 1.4)
oauth (0.5.8)
orm_adapter (0.5.0)
os (1.1.4)
parallel (1.21.0)
parser (3.1.1.0)
ast (~> 2.4.1)
path_expander (1.1.0)
pg (1.3.2)
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
procore-sift (0.16.0)
rails (> 4.2.0)
pry (0.14.1)
Expand All @@ -409,7 +405,7 @@ GEM
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.6.0)
rack (2.2.3)
rack (2.2.3.1)
rack-attack (6.6.0)
rack (>= 1.0, < 3)
rack-cors (1.1.1)
Expand Down Expand Up @@ -468,10 +464,6 @@ GEM
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
Expand Down Expand Up @@ -681,7 +673,6 @@ DEPENDENCIES
faker
fcm
flag_shih_tzu
flay
foreman
geocoder
google-cloud-dialogflow
Expand All @@ -706,6 +697,7 @@ DEPENDENCIES
mock_redis
newrelic_rpm
pg
pg_search
procore-sift
pry-rails
puma
Expand All @@ -718,7 +710,6 @@ DEPENDENCIES
redis-namespace
responders
rest-client
rspec
rspec-rails (~> 5.0.0)
rubocop
rubocop-performance
Expand Down Expand Up @@ -752,7 +743,7 @@ DEPENDENCIES
working_hours

RUBY VERSION
ruby 3.0.2p107
ruby 3.0.4p208

BUNDLED WITH
2.3.10
2.3.15
2 changes: 1 addition & 1 deletion app/builders/messages/facebook/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def perform
end
ensure_contact_avatar
rescue Koala::Facebook::AuthenticationError
Rails.logger.error "Facebook Authorization expired for Inbox #{@inbox.id}"
@inbox.channel.authorization_error!
rescue StandardError => e
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
true
Expand Down
6 changes: 5 additions & 1 deletion app/builders/messages/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def campaign_id
@params[:campaign_id].present? ? { additional_attributes: { campaign_id: @params[:campaign_id] } } : {}
end

def template_params
@params[:template_params].present? ? { additional_attributes: { template_params: JSON.parse(@params[:template_params].to_json) } } : {}
end

def message_sender
return if @params[:sender_type] != 'AgentBot'

Expand All @@ -91,6 +95,6 @@ def message_params
items: @items,
in_reply_to: @in_reply_to,
echo_id: @params[:echo_id]
}.merge(external_created_at).merge(automation_rule_id).merge(campaign_id)
}.merge(external_created_at).merge(automation_rule_id).merge(campaign_id).merge(template_params)
end
end
48 changes: 48 additions & 0 deletions app/controllers/api/v1/accounts/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
before_action :portal
before_action :fetch_article, except: [:index, :create]

def index
@articles = @portal.articles
@articles.search(list_params) if params[:payload].present?
end

def create
@article = @portal.articles.create!(article_params)
end

def edit; end

def show; end

def update
@article.update!(article_params)
end

def destroy
@article.destroy!
head :ok
end

private

def fetch_article
@article = @portal.articles.find(params[:id])
end

def portal
@portal ||= Current.account.portals.find_by(slug: params[:portal_id])
end

def article_params
params.require(:article).permit(
:title, :content, :description, :position, :category_id, :author_id
)
end

def list_params
params.require(:payload).permit(
:category_slug, :locale, :query
)
end
end
24 changes: 24 additions & 0 deletions app/controllers/api/v1/accounts/assignable_agents_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Api::V1::Accounts::AssignableAgentsController < Api::V1::Accounts::BaseController
before_action :fetch_inboxes

def index
agent_ids = @inboxes.map do |inbox|
authorize inbox, :show?
member_ids = inbox.members.pluck(:user_id)
member_ids
end
agent_ids = agent_ids.inject(:&)
agents = Current.account.users.where(id: agent_ids)
@assignable_agents = (agents + Current.account.administrators).uniq
end

private

def fetch_inboxes
@inboxes = Current.account.inboxes.find(permitted_params[:inbox_ids])
end

def permitted_params
params.permit(inbox_ids: [])
end
end
14 changes: 10 additions & 4 deletions app/controllers/api/v1/accounts/automation_rules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def index
def create
@automation_rule = Current.account.automation_rules.new(automation_rules_permit)
@automation_rule.actions = params[:actions]
@automation_rule.conditions = params[:conditions]

render json: { error: @automation_rule.errors.messages }, status: :unprocessable_entity and return unless @automation_rule.valid?

Expand All @@ -31,9 +32,7 @@ def show; end

def update
ActiveRecord::Base.transaction do
@automation_rule.update!(automation_rules_permit)
@automation_rule.actions = params[:actions] if params[:actions]
@automation_rule.save!
automation_rule_update
process_attachments

rescue StandardError => e
Expand Down Expand Up @@ -67,10 +66,17 @@ def process_attachments

private

def automation_rule_update
@automation_rule.update!(automation_rules_permit)
@automation_rule.actions = params[:actions] if params[:actions]
@automation_rule.conditions = params[:conditions] if params[:conditions]
@automation_rule.save!
end

def automation_rules_permit
params.permit(
:name, :description, :event_name, :account_id, :active,
conditions: [:attribute_key, :filter_operator, :query_operator, { values: [] }],
conditions: [:attribute_key, :filter_operator, :query_operator, :custom_attribute_type, { values: [] }],
actions: [:action_name, { action_params: [] }]
)
end
Expand Down
Loading

0 comments on commit 374b367

Please sign in to comment.