fix: Add validation for the inbox name to avoid special characters (#4920)
This commit is contained in:
@@ -33,7 +33,10 @@ class Inbox < ApplicationRecord
|
||||
include Avatarable
|
||||
include OutOfOffisable
|
||||
|
||||
# Not allowing characters:
|
||||
validates :name, presence: true
|
||||
validates :name, if: :check_channel_type?, format: { with: %r{^^\b[^/\\<>@]*\b$}, multiline: true,
|
||||
message: I18n.t('errors.inboxes.validations.name') }
|
||||
validates :account_id, presence: true
|
||||
validates :timezone, inclusion: { in: TZInfo::Timezone.all_identifiers }
|
||||
validate :ensure_valid_max_assignment_limit
|
||||
@@ -133,6 +136,10 @@ class Inbox < ApplicationRecord
|
||||
def delete_round_robin_agents
|
||||
::RoundRobin::ManageService.new(inbox: self).clear_queue
|
||||
end
|
||||
|
||||
def check_channel_type?
|
||||
['Channel::Email', 'Channel::Api', 'Channel::WebWidget'].include?(channel_type)
|
||||
end
|
||||
end
|
||||
|
||||
Inbox.prepend_mod_with('Inbox')
|
||||
|
||||
Reference in New Issue
Block a user