Merge branch 'hotfix/1.2.4' into develop
This commit is contained in:
commit
2eac97c705
@ -5,6 +5,7 @@ class ContactMergeAction
|
|||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
validate_contacts
|
validate_contacts
|
||||||
merge_conversations
|
merge_conversations
|
||||||
|
merge_messages
|
||||||
merge_contact_inboxes
|
merge_contact_inboxes
|
||||||
remove_mergee_contact
|
remove_mergee_contact
|
||||||
end
|
end
|
||||||
@ -26,6 +27,10 @@ class ContactMergeAction
|
|||||||
Conversation.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
Conversation.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def merge_messages
|
||||||
|
Message.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
||||||
|
end
|
||||||
|
|
||||||
def merge_contact_inboxes
|
def merge_contact_inboxes
|
||||||
ContactInbox.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
ContactInbox.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class Contact < ApplicationRecord
|
|||||||
has_many :conversations, dependent: :destroy
|
has_many :conversations, dependent: :destroy
|
||||||
has_many :contact_inboxes, dependent: :destroy
|
has_many :contact_inboxes, dependent: :destroy
|
||||||
has_many :inboxes, through: :contact_inboxes
|
has_many :inboxes, through: :contact_inboxes
|
||||||
|
has_many :messages, dependent: :destroy
|
||||||
|
|
||||||
def get_source_id(inbox_id)
|
def get_source_id(inbox_id)
|
||||||
contact_inboxes.find_by!(inbox_id: inbox_id).source_id
|
contact_inboxes.find_by!(inbox_id: inbox_id).source_id
|
||||||
|
|||||||
@ -83,13 +83,16 @@ Rails.application.configure do
|
|||||||
config.log_formatter = ::Logger::Formatter.new
|
config.log_formatter = ::Logger::Formatter.new
|
||||||
|
|
||||||
# Use a different logger for distributed setups.
|
# Use a different logger for distributed setups.
|
||||||
# require 'syslog/logger'
|
|
||||||
config.logger = ActiveSupport::Logger.new(Rails.root.join('log', Rails.env + '.log'), 1, ENV.fetch('LOG_SIZE', '1024').to_i.megabytes)
|
|
||||||
|
|
||||||
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
||||||
logger = ActiveSupport::Logger.new(STDOUT)
|
logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
logger.formatter = config.log_formatter
|
logger.formatter = config.log_formatter
|
||||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||||
|
else
|
||||||
|
config.logger = ActiveSupport::Logger.new(
|
||||||
|
Rails.root.join('log', Rails.env + '.log'),
|
||||||
|
1,
|
||||||
|
ENV.fetch('LOG_SIZE', '1024').to_i.megabytes
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Do not dump schema after migrations.
|
# Do not dump schema after migrations.
|
||||||
|
|||||||
@ -47,7 +47,7 @@ COPY . /app
|
|||||||
|
|
||||||
# generate production assets if production environment
|
# generate production assets if production environment
|
||||||
RUN if [ "$RAILS_ENV" = "production" ]; then \
|
RUN if [ "$RAILS_ENV" = "production" ]; then \
|
||||||
SECRET_KEY_BASE=precompile_placeholder bundle exec rake assets:precompile; \
|
SECRET_KEY_BASE=precompile_placeholder RAILS_LOG_TO_STDOUT=enabled bundle exec rake assets:precompile; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# final build stage
|
# final build stage
|
||||||
|
|||||||
@ -10,6 +10,7 @@ describe ::ContactMergeAction do
|
|||||||
before do
|
before do
|
||||||
2.times.each { create(:conversation, contact: base_contact) }
|
2.times.each { create(:conversation, contact: base_contact) }
|
||||||
2.times.each { create(:conversation, contact: mergee_contact) }
|
2.times.each { create(:conversation, contact: mergee_contact) }
|
||||||
|
2.times.each { create(:message, contact: mergee_contact) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
@ -32,6 +33,13 @@ describe ::ContactMergeAction do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when mergee contact has messages' do
|
||||||
|
it 'moves the messages to base contact' do
|
||||||
|
contact_merge
|
||||||
|
expect(base_contact.messages.count).to be 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when contacts belong to a different account' do
|
context 'when contacts belong to a different account' do
|
||||||
it 'throws an exception' do
|
it 'throws an exception' do
|
||||||
new_account = create(:account)
|
new_account = create(:account)
|
||||||
|
|||||||
12
yarn.lock
12
yarn.lock
@ -8810,14 +8810,14 @@ regenerator-runtime@^0.13.3:
|
|||||||
integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==
|
integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==
|
||||||
|
|
||||||
regenerator-runtime@^0.13.4:
|
regenerator-runtime@^0.13.4:
|
||||||
version "0.13.4"
|
version "0.13.5"
|
||||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz#e96bf612a3362d12bb69f7e8f74ffeab25c7ac91"
|
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697"
|
||||||
integrity sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==
|
integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==
|
||||||
|
|
||||||
regenerator-transform@^0.14.2:
|
regenerator-transform@^0.14.2:
|
||||||
version "0.14.2"
|
version "0.14.4"
|
||||||
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.2.tgz#949d9d87468ff88d5a7e4734ebb994a892de1ff2"
|
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.4.tgz#5266857896518d1616a78a0479337a30ea974cc7"
|
||||||
integrity sha512-V4+lGplCM/ikqi5/mkkpJ06e9Bujq1NFmNLvsCs56zg3ZbzrnUzAtizZ24TXxtRX/W2jcdScwQCnbL0CICTFkQ==
|
integrity sha512-EaJaKPBI9GvKpvUz2mz4fhx7WPgvwRLY9v3hlNHWmAuJHI13T4nwKnNvm5RWJzEdnI5g5UwtOww+S8IdoUC2bw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.8.4"
|
"@babel/runtime" "^7.8.4"
|
||||||
private "^0.1.8"
|
private "^0.1.8"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user