chore: Add validation for processed content field (#7306)

* logging the messages id for message validation exception

* Update the processed_message_content validation over length

* codeclimate

* specs failing for contacts
This commit is contained in:
Tejaswini Chile
2023-06-14 18:28:42 +05:30
committed by GitHub
parent 6eb4fa41ff
commit 1ee6a8fe90
3 changed files with 7 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ class Message < ApplicationRecord
validates :content_type, presence: true
validates :content, length: { maximum: 150_000 }
validates :processed_message_content, length: { maximum: 150_000 }
# when you have a temperory id in your frontend and want it echoed back via action cable
attr_accessor :echo_id
@@ -220,7 +221,8 @@ class Message < ApplicationRecord
text_content_quoted = content_attributes.dig(:email, :text_content, :quoted)
html_content_quoted = content_attributes.dig(:email, :html_content, :quoted)
self.processed_message_content = text_content_quoted || html_content_quoted || content
message_content = text_content_quoted || html_content_quoted || content
self.processed_message_content = message_content&.truncate(150_000)
end
def ensure_content_type