@@ -5,7 +5,7 @@
|
||||
# id :integer not null, primary key
|
||||
# content :text
|
||||
# content_attributes :json
|
||||
# content_type :integer default("text")
|
||||
# content_type :integer default("text"), not null
|
||||
# external_source_ids :jsonb
|
||||
# message_type :integer not null
|
||||
# private :boolean default(FALSE)
|
||||
@@ -32,10 +32,13 @@ class Message < ApplicationRecord
|
||||
include MessageFilterHelpers
|
||||
NUMBER_OF_PERMITTED_ATTACHMENTS = 15
|
||||
|
||||
before_validation :ensure_content_type
|
||||
|
||||
validates :account_id, presence: true
|
||||
validates :inbox_id, presence: true
|
||||
validates :conversation_id, presence: true
|
||||
validates_with ContentAttributeValidator
|
||||
validates :content_type, presence: true
|
||||
|
||||
# when you have a temperory id in your frontend and want it echoed back via action cable
|
||||
attr_accessor :echo_id
|
||||
@@ -133,6 +136,10 @@ class Message < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def ensure_content_type
|
||||
self.content_type ||= Message.content_types[:text]
|
||||
end
|
||||
|
||||
def execute_after_create_commit_callbacks
|
||||
# rails issue with order of active record callbacks being executed https://github.com/rails/rails/issues/20911
|
||||
reopen_conversation
|
||||
|
||||
Reference in New Issue
Block a user