chore: Revert the migration for inbox name changes (#4919)

This commit is contained in:
Pranav Raj S
2022-06-23 20:36:46 +05:30
committed by GitHub
parent f39c10395a
commit dcbca173ac
4 changed files with 8 additions and 18 deletions

View File

@@ -326,7 +326,7 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { shouldBeUrl, isValidName } from 'shared/helpers/Validators'; import { shouldBeUrl } from 'shared/helpers/Validators';
import configMixin from 'shared/mixins/configMixin'; import configMixin from 'shared/mixins/configMixin';
import alertMixin from 'shared/mixins/alertMixin'; import alertMixin from 'shared/mixins/alertMixin';
import SettingIntroBanner from 'dashboard/components/widgets/SettingIntroBanner'; import SettingIntroBanner from 'dashboard/components/widgets/SettingIntroBanner';
@@ -571,7 +571,7 @@ export default {
webhookUrl: { webhookUrl: {
shouldBeUrl, shouldBeUrl,
}, },
selectedInboxName: { isValidName }, selectedInboxName: {},
}, },
}; };
</script> </script>

View File

@@ -16,4 +16,3 @@ export const isValidPassword = value => {
containsSpecialCharacter containsSpecialCharacter
); );
}; };
export const isValidName = value => /^\b[\w\s]*\b$/.test(value);

View File

@@ -33,7 +33,7 @@ class Inbox < ApplicationRecord
include Avatarable include Avatarable
include OutOfOffisable include OutOfOffisable
validates :name, presence: true, format: { with: /^\b[\w\s]*\b$/, multiline: true } validates :name, presence: true
validates :account_id, presence: true validates :account_id, presence: true
validates :timezone, inclusion: { in: TZInfo::Timezone.all_identifiers } validates :timezone, inclusion: { in: TZInfo::Timezone.all_identifiers }
validate :ensure_valid_max_assignment_limit validate :ensure_valid_max_assignment_limit

View File

@@ -1,17 +1,8 @@
class RemoveSpecialCharactersFromInboxName < ActiveRecord::Migration[6.1] class RemoveSpecialCharactersFromInboxName < ActiveRecord::Migration[6.1]
def change # This PR tried to remove special characters from the inbox name
remove_special_characters_from_inbox_name # It broke in the Chatwoot Cloud as there were inboxes with valid special characters
end # We had to push a temporary fix to continue the deployment by removing the logic
# from this migration. Keeping this migration here to remove inconsistency.
private def change; end
def remove_special_characters_from_inbox_name
::Inbox.find_in_batches do |inbox_batch|
Rails.logger.info "Migrated till #{inbox_batch.first.id}\n"
inbox_batch.each do |inbox|
inbox.name = inbox.name.gsub(/[^\w\s_]/, '')
inbox.save!
end
end
end
end end